mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-21 04:39:45 +00:00
Change all CRLF-text files to LF-text files
to match H'uru for patching
This commit is contained in:
@ -1,377 +1,377 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plAudioInterface.h"
|
||||
#include "plAudible.h"
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "plCoordinateInterface.h"
|
||||
#include "../pnMessage/plNodeRefMsg.h"
|
||||
#include "../pnMessage/plProxyDrawMsg.h"
|
||||
#include "../pnNetCommon/plNetApp.h"
|
||||
#include "hsTimer.h"
|
||||
|
||||
|
||||
plAudioInterface::plAudioInterface()
|
||||
: fAudible(nil), fAudibleInited( false )
|
||||
{
|
||||
fRegisteredForASysMsg = false;
|
||||
}
|
||||
|
||||
plAudioInterface::~plAudioInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void plAudioInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on);
|
||||
|
||||
if( fAudible )
|
||||
fAudible->SetProperty(prop, on);
|
||||
}
|
||||
|
||||
plSound* plAudioInterface::GetSound(int i) const
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetSound(i);
|
||||
return nil;
|
||||
}
|
||||
|
||||
int plAudioInterface::GetSoundIndex(const char *keyname)
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetSoundIndex(keyname);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int plAudioInterface::GetNumSounds() const
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetNumSounds();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set the filename of sound[index] within the audible
|
||||
void plAudioInterface::SetSoundFilename(int index, const char *filename, bool isCompressed)
|
||||
{
|
||||
if(fAudible)
|
||||
fAudible->SetFilename(index, filename, isCompressed);
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetSceneNode(plKey key)
|
||||
{
|
||||
if( fAudible )
|
||||
{
|
||||
fAudible->SetSceneNode(key);
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
int isLocal = IsLocallyOwned();
|
||||
|
||||
plKey localKey = ( plNetClientApp::GetInstance() != nil ) ? plNetClientApp::GetInstance()->GetLocalPlayerKey() : nil;
|
||||
if( fOwner && fOwner->GetKey() == localKey )
|
||||
isLocal = true;
|
||||
else
|
||||
isLocal = false;
|
||||
|
||||
fAudible->Init( isLocal );//( isLocal == plSynchedObject::kYes ) );
|
||||
fAudibleInited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetOwner(plSceneObject* owner)
|
||||
{
|
||||
plObjInterface::ISetOwner(owner);
|
||||
|
||||
if( owner && !fRegisteredForASysMsg )
|
||||
{
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plAudioSysMsg::Index(), GetKey());
|
||||
fRegisteredForASysMsg = true;
|
||||
}
|
||||
else if( owner == nil && fRegisteredForASysMsg )
|
||||
{
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plAudioSysMsg::Index(), GetKey());
|
||||
fRegisteredForASysMsg = false;
|
||||
}
|
||||
|
||||
if (fAudible)
|
||||
fAudible->SetSceneObject(owner ? owner->GetKey() : nil);
|
||||
}
|
||||
|
||||
|
||||
void plAudioInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetTransform(l2w, w2l);
|
||||
}
|
||||
|
||||
void plAudioInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kAudible);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
void plAudioInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
mgr->WriteKey(s,fAudible);
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetAudible(plAudible* aud)
|
||||
{
|
||||
fAudible = aud;
|
||||
if( fAudible )
|
||||
{
|
||||
fAudible->SetSceneNode(GetSceneNode());
|
||||
if (fOwner)
|
||||
fAudible->SetSceneObject(fOwner->GetKey());
|
||||
}
|
||||
|
||||
plAudioSysMsg* pMsg = TRACKED_NEW plAudioSysMsg( plAudioSysMsg::kPing );
|
||||
pMsg->SetSender(GetKey());
|
||||
// pMsg->SetBCastFlag(plMessage::kBCastByExactType, false);
|
||||
plgDispatch::MsgSend( pMsg );
|
||||
}
|
||||
|
||||
void plAudioInterface::IRemoveAudible(plAudible* aud)
|
||||
{
|
||||
hsAssert(aud == fAudible, "Removing Audible I don't have");
|
||||
fAudible = nil;
|
||||
}
|
||||
|
||||
hsBool plAudioInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kAudible:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
IRemoveAudible(plAudible::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetAudible(plAudible::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
plSoundMsg* pSoundMsg = plSoundMsg::ConvertNoRef( msg );
|
||||
if (pSoundMsg)
|
||||
{
|
||||
if (!fAudible)
|
||||
return false;
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kAddCallbacks))
|
||||
fAudible->AddCallbacks( pSoundMsg );
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kRemoveCallbacks))
|
||||
fAudible->RemoveCallbacks( pSoundMsg );
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kStop ) )
|
||||
fAudible->Stop(pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGoToTime ) )
|
||||
fAudible->SetTime(pSoundMsg->fTime, pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kPlay ) )
|
||||
fAudible->Play(pSoundMsg->fIndex);
|
||||
if(pSoundMsg->Cmd( plSoundMsg::kSynchedPlay))
|
||||
fAudible->SynchedPlay(pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kSetLooping ) )
|
||||
fAudible->SetLooping(true,pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kUnSetLooping ) )
|
||||
fAudible->SetLooping(false,pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kToggleState ) )
|
||||
{
|
||||
if (fAudible->IsPlaying(pSoundMsg->fIndex))
|
||||
fAudible->Stop(pSoundMsg->fIndex);
|
||||
else
|
||||
fAudible->Play(pSoundMsg->fIndex);
|
||||
}
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGetStatus ) )
|
||||
{
|
||||
fAudible->GetStatus(pSoundMsg);
|
||||
}
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGetNumSounds ) )
|
||||
{
|
||||
plSoundMsg* pReply = TRACKED_NEW plSoundMsg;
|
||||
pReply->fIndex = fAudible->GetNumSounds();
|
||||
pReply->AddReceiver(pSoundMsg->GetSender());
|
||||
pReply->SetCmd( plSoundMsg::kGetNumSounds );
|
||||
plgDispatch::MsgSend(pReply);
|
||||
}
|
||||
if( pSoundMsg->Cmd( plSoundMsg::kSetVolume ) )
|
||||
{
|
||||
fAudible->SetVolume( pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetTalkIcon ) )
|
||||
{
|
||||
fAudible->SetTalkIcon(pSoundMsg->fIndex, pSoundMsg->fNameStr);
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kClearTalkIcon ) )
|
||||
{
|
||||
fAudible->ClearTalkIcon();
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetFadeIn ) )
|
||||
{
|
||||
fAudible->SetFadeIn( (int)pSoundMsg->fFadeType, pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetFadeOut ) )
|
||||
{
|
||||
fAudible->SetFadeOut( (int)pSoundMsg->fFadeType, pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if( pSoundMsg->Cmd( plSoundMsg::kFastForwardPlay ) )
|
||||
{
|
||||
fAudible->FastForwardPlay(pSoundMsg->fIndex);
|
||||
}
|
||||
if(pSoundMsg->Cmd(plSoundMsg::kFastForwardToggle) )
|
||||
{
|
||||
fAudible->FastForwardToggle(pSoundMsg->fIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
plAudioSysMsg* pASMsg = plAudioSysMsg::ConvertNoRef( msg );
|
||||
if (pASMsg)
|
||||
{
|
||||
if (pASMsg->GetAudFlag() == plAudioSysMsg::kActivate)
|
||||
{
|
||||
if( fAudible )
|
||||
{
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
int isLocal = IsLocallyOwned();
|
||||
fAudible->Init( ( isLocal == plSynchedObject::kYes ) );
|
||||
fAudibleInited = true;
|
||||
}
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
// Arrgh, can't activate yet, so attempt to re-activate some time in the near future
|
||||
pASMsg = TRACKED_NEW plAudioSysMsg( plAudioSysMsg::kActivate );
|
||||
pASMsg->SetBCastFlag( plMessage::kBCastByExactType, false );
|
||||
pASMsg->SetBCastFlag( plMessage::kNetPropagate, false );
|
||||
pASMsg->SetTimeStamp( hsTimer::GetSysSeconds() + 1.f );
|
||||
pASMsg->Send( GetKey() );
|
||||
return true;
|
||||
}
|
||||
fAudible->Activate();
|
||||
if (GetOwner() && GetOwner()->GetCoordinateInterface())
|
||||
{
|
||||
hsMatrix44 l2w = GetOwner()->GetCoordinateInterface()->GetLocalToWorld();
|
||||
hsMatrix44 w2l = GetOwner()->GetCoordinateInterface()->GetWorldToLocal();;
|
||||
fAudible->SetTransform(l2w,w2l);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pASMsg->GetAudFlag() == plAudioSysMsg::kDeActivate)
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->DeActivate();
|
||||
}
|
||||
if( pASMsg->GetAudFlag() == plAudioSysMsg::kMuteAll )
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetMuted( true );
|
||||
}
|
||||
else if( pASMsg->GetAudFlag() == plAudioSysMsg::kUnmuteAll )
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetMuted( false );
|
||||
}
|
||||
else if( pASMsg->GetAudFlag() == plAudioSysMsg::kChannelVolChanged )
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->MsgReceive( msg );
|
||||
}
|
||||
}
|
||||
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef( msg );
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty( kDisable, pEnableMsg->Cmd(kDisable) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// proxyDrawMsg handling--just pass it on to the audible
|
||||
plProxyDrawMsg *pdMsg = plProxyDrawMsg::ConvertNoRef( msg );
|
||||
if( pdMsg != nil )
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->MsgReceive( pdMsg );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
|
||||
void plAudioInterface::ReleaseData()
|
||||
{
|
||||
if (fAudible)
|
||||
{
|
||||
// To get rid of our data, we need to release our active ref and tell the SceneNode
|
||||
// to dump it. It will autodestruct after those two active refs are released, unless
|
||||
// someone else has a ref on it as well (in which case we don't want to be nuking it
|
||||
// anyway).
|
||||
fAudible->SetSceneNode(nil);
|
||||
// Audible key is gone already, I guess the audioInterface doesn't have a ref -Colin
|
||||
// GetKey()->Release(fAudible->GetKey());
|
||||
}
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plAudioInterface.h"
|
||||
#include "plAudible.h"
|
||||
#include "../pnMessage/plAudioSysMsg.h"
|
||||
#include "../pnMessage/plSoundMsg.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "plCoordinateInterface.h"
|
||||
#include "../pnMessage/plNodeRefMsg.h"
|
||||
#include "../pnMessage/plProxyDrawMsg.h"
|
||||
#include "../pnNetCommon/plNetApp.h"
|
||||
#include "hsTimer.h"
|
||||
|
||||
|
||||
plAudioInterface::plAudioInterface()
|
||||
: fAudible(nil), fAudibleInited( false )
|
||||
{
|
||||
fRegisteredForASysMsg = false;
|
||||
}
|
||||
|
||||
plAudioInterface::~plAudioInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void plAudioInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on);
|
||||
|
||||
if( fAudible )
|
||||
fAudible->SetProperty(prop, on);
|
||||
}
|
||||
|
||||
plSound* plAudioInterface::GetSound(int i) const
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetSound(i);
|
||||
return nil;
|
||||
}
|
||||
|
||||
int plAudioInterface::GetSoundIndex(const char *keyname)
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetSoundIndex(keyname);
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
int plAudioInterface::GetNumSounds() const
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->GetNumSounds();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set the filename of sound[index] within the audible
|
||||
void plAudioInterface::SetSoundFilename(int index, const char *filename, bool isCompressed)
|
||||
{
|
||||
if(fAudible)
|
||||
fAudible->SetFilename(index, filename, isCompressed);
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetSceneNode(plKey key)
|
||||
{
|
||||
if( fAudible )
|
||||
{
|
||||
fAudible->SetSceneNode(key);
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
int isLocal = IsLocallyOwned();
|
||||
|
||||
plKey localKey = ( plNetClientApp::GetInstance() != nil ) ? plNetClientApp::GetInstance()->GetLocalPlayerKey() : nil;
|
||||
if( fOwner && fOwner->GetKey() == localKey )
|
||||
isLocal = true;
|
||||
else
|
||||
isLocal = false;
|
||||
|
||||
fAudible->Init( isLocal );//( isLocal == plSynchedObject::kYes ) );
|
||||
fAudibleInited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetOwner(plSceneObject* owner)
|
||||
{
|
||||
plObjInterface::ISetOwner(owner);
|
||||
|
||||
if( owner && !fRegisteredForASysMsg )
|
||||
{
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plAudioSysMsg::Index(), GetKey());
|
||||
fRegisteredForASysMsg = true;
|
||||
}
|
||||
else if( owner == nil && fRegisteredForASysMsg )
|
||||
{
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plAudioSysMsg::Index(), GetKey());
|
||||
fRegisteredForASysMsg = false;
|
||||
}
|
||||
|
||||
if (fAudible)
|
||||
fAudible->SetSceneObject(owner ? owner->GetKey() : nil);
|
||||
}
|
||||
|
||||
|
||||
void plAudioInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetTransform(l2w, w2l);
|
||||
}
|
||||
|
||||
void plAudioInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kAudible);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
void plAudioInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
mgr->WriteKey(s,fAudible);
|
||||
}
|
||||
|
||||
void plAudioInterface::ISetAudible(plAudible* aud)
|
||||
{
|
||||
fAudible = aud;
|
||||
if( fAudible )
|
||||
{
|
||||
fAudible->SetSceneNode(GetSceneNode());
|
||||
if (fOwner)
|
||||
fAudible->SetSceneObject(fOwner->GetKey());
|
||||
}
|
||||
|
||||
plAudioSysMsg* pMsg = TRACKED_NEW plAudioSysMsg( plAudioSysMsg::kPing );
|
||||
pMsg->SetSender(GetKey());
|
||||
// pMsg->SetBCastFlag(plMessage::kBCastByExactType, false);
|
||||
plgDispatch::MsgSend( pMsg );
|
||||
}
|
||||
|
||||
void plAudioInterface::IRemoveAudible(plAudible* aud)
|
||||
{
|
||||
hsAssert(aud == fAudible, "Removing Audible I don't have");
|
||||
fAudible = nil;
|
||||
}
|
||||
|
||||
hsBool plAudioInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kAudible:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
IRemoveAudible(plAudible::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetAudible(plAudible::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
plSoundMsg* pSoundMsg = plSoundMsg::ConvertNoRef( msg );
|
||||
if (pSoundMsg)
|
||||
{
|
||||
if (!fAudible)
|
||||
return false;
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kAddCallbacks))
|
||||
fAudible->AddCallbacks( pSoundMsg );
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kRemoveCallbacks))
|
||||
fAudible->RemoveCallbacks( pSoundMsg );
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kStop ) )
|
||||
fAudible->Stop(pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGoToTime ) )
|
||||
fAudible->SetTime(pSoundMsg->fTime, pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kPlay ) )
|
||||
fAudible->Play(pSoundMsg->fIndex);
|
||||
if(pSoundMsg->Cmd( plSoundMsg::kSynchedPlay))
|
||||
fAudible->SynchedPlay(pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kSetLooping ) )
|
||||
fAudible->SetLooping(true,pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kUnSetLooping ) )
|
||||
fAudible->SetLooping(false,pSoundMsg->fIndex);
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kToggleState ) )
|
||||
{
|
||||
if (fAudible->IsPlaying(pSoundMsg->fIndex))
|
||||
fAudible->Stop(pSoundMsg->fIndex);
|
||||
else
|
||||
fAudible->Play(pSoundMsg->fIndex);
|
||||
}
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGetStatus ) )
|
||||
{
|
||||
fAudible->GetStatus(pSoundMsg);
|
||||
}
|
||||
if (pSoundMsg->Cmd( plSoundMsg::kGetNumSounds ) )
|
||||
{
|
||||
plSoundMsg* pReply = TRACKED_NEW plSoundMsg;
|
||||
pReply->fIndex = fAudible->GetNumSounds();
|
||||
pReply->AddReceiver(pSoundMsg->GetSender());
|
||||
pReply->SetCmd( plSoundMsg::kGetNumSounds );
|
||||
plgDispatch::MsgSend(pReply);
|
||||
}
|
||||
if( pSoundMsg->Cmd( plSoundMsg::kSetVolume ) )
|
||||
{
|
||||
fAudible->SetVolume( pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetTalkIcon ) )
|
||||
{
|
||||
fAudible->SetTalkIcon(pSoundMsg->fIndex, pSoundMsg->fNameStr);
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kClearTalkIcon ) )
|
||||
{
|
||||
fAudible->ClearTalkIcon();
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetFadeIn ) )
|
||||
{
|
||||
fAudible->SetFadeIn( (int)pSoundMsg->fFadeType, pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if ( pSoundMsg->Cmd( plSoundMsg::kSetFadeOut ) )
|
||||
{
|
||||
fAudible->SetFadeOut( (int)pSoundMsg->fFadeType, pSoundMsg->fVolume, pSoundMsg->fIndex );
|
||||
}
|
||||
if( pSoundMsg->Cmd( plSoundMsg::kFastForwardPlay ) )
|
||||
{
|
||||
fAudible->FastForwardPlay(pSoundMsg->fIndex);
|
||||
}
|
||||
if(pSoundMsg->Cmd(plSoundMsg::kFastForwardToggle) )
|
||||
{
|
||||
fAudible->FastForwardToggle(pSoundMsg->fIndex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
plAudioSysMsg* pASMsg = plAudioSysMsg::ConvertNoRef( msg );
|
||||
if (pASMsg)
|
||||
{
|
||||
if (pASMsg->GetAudFlag() == plAudioSysMsg::kActivate)
|
||||
{
|
||||
if( fAudible )
|
||||
{
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
int isLocal = IsLocallyOwned();
|
||||
fAudible->Init( ( isLocal == plSynchedObject::kYes ) );
|
||||
fAudibleInited = true;
|
||||
}
|
||||
if( !fAudibleInited )
|
||||
{
|
||||
// Arrgh, can't activate yet, so attempt to re-activate some time in the near future
|
||||
pASMsg = TRACKED_NEW plAudioSysMsg( plAudioSysMsg::kActivate );
|
||||
pASMsg->SetBCastFlag( plMessage::kBCastByExactType, false );
|
||||
pASMsg->SetBCastFlag( plMessage::kNetPropagate, false );
|
||||
pASMsg->SetTimeStamp( hsTimer::GetSysSeconds() + 1.f );
|
||||
pASMsg->Send( GetKey() );
|
||||
return true;
|
||||
}
|
||||
fAudible->Activate();
|
||||
if (GetOwner() && GetOwner()->GetCoordinateInterface())
|
||||
{
|
||||
hsMatrix44 l2w = GetOwner()->GetCoordinateInterface()->GetLocalToWorld();
|
||||
hsMatrix44 w2l = GetOwner()->GetCoordinateInterface()->GetWorldToLocal();;
|
||||
fAudible->SetTransform(l2w,w2l);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pASMsg->GetAudFlag() == plAudioSysMsg::kDeActivate)
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->DeActivate();
|
||||
}
|
||||
if( pASMsg->GetAudFlag() == plAudioSysMsg::kMuteAll )
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetMuted( true );
|
||||
}
|
||||
else if( pASMsg->GetAudFlag() == plAudioSysMsg::kUnmuteAll )
|
||||
{
|
||||
if( fAudible )
|
||||
fAudible->SetMuted( false );
|
||||
}
|
||||
else if( pASMsg->GetAudFlag() == plAudioSysMsg::kChannelVolChanged )
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->MsgReceive( msg );
|
||||
}
|
||||
}
|
||||
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef( msg );
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty( kDisable, pEnableMsg->Cmd(kDisable) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// proxyDrawMsg handling--just pass it on to the audible
|
||||
plProxyDrawMsg *pdMsg = plProxyDrawMsg::ConvertNoRef( msg );
|
||||
if( pdMsg != nil )
|
||||
{
|
||||
if( fAudible )
|
||||
return fAudible->MsgReceive( pdMsg );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
|
||||
void plAudioInterface::ReleaseData()
|
||||
{
|
||||
if (fAudible)
|
||||
{
|
||||
// To get rid of our data, we need to release our active ref and tell the SceneNode
|
||||
// to dump it. It will autodestruct after those two active refs are released, unless
|
||||
// someone else has a ref on it as well (in which case we don't want to be nuking it
|
||||
// anyway).
|
||||
fAudible->SetSceneNode(nil);
|
||||
// Audible key is gone already, I guess the audioInterface doesn't have a ref -Colin
|
||||
// GetKey()->Release(fAudible->GetKey());
|
||||
}
|
||||
}
|
||||
|
@ -1,110 +1,110 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef plAudioInterface_inc
|
||||
#define plAudioInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plSound;
|
||||
class plAudible;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
|
||||
|
||||
class plAudioInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plAudioProperties {
|
||||
kDisable = 0, // prop 0 is always disable, declared in plObjInterface
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
protected:
|
||||
plAudible* fAudible; // references into system pools
|
||||
|
||||
hsBool fRegisteredForASysMsg, fAudibleInited;
|
||||
|
||||
void ISetAudible(plAudible* aud);
|
||||
void IRemoveAudible(plAudible* aud);
|
||||
|
||||
virtual void ISetOwner(plSceneObject* owner);
|
||||
virtual void ISetSceneNode(plKey node);
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plAudioInterface();
|
||||
~plAudioInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plAudioInterface );
|
||||
GETINTERFACE_ANY( plAudioInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
plSound* GetSound(int i) const;
|
||||
int GetNumSounds() const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
// for export only!!!!!
|
||||
plAudible* GetAudible() const { return fAudible; }
|
||||
/// don't call this otherwise!
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
void SetSoundFilename(int index, const char *filename, bool isCompressed);
|
||||
int GetSoundIndex(const char *keyname);
|
||||
};
|
||||
|
||||
|
||||
#endif // plAudioInterface_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef plAudioInterface_inc
|
||||
#define plAudioInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plSound;
|
||||
class plAudible;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
|
||||
|
||||
class plAudioInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plAudioProperties {
|
||||
kDisable = 0, // prop 0 is always disable, declared in plObjInterface
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
protected:
|
||||
plAudible* fAudible; // references into system pools
|
||||
|
||||
hsBool fRegisteredForASysMsg, fAudibleInited;
|
||||
|
||||
void ISetAudible(plAudible* aud);
|
||||
void IRemoveAudible(plAudible* aud);
|
||||
|
||||
virtual void ISetOwner(plSceneObject* owner);
|
||||
virtual void ISetSceneNode(plKey node);
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plAudioInterface();
|
||||
~plAudioInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plAudioInterface );
|
||||
GETINTERFACE_ANY( plAudioInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
plSound* GetSound(int i) const;
|
||||
int GetNumSounds() const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
// for export only!!!!!
|
||||
plAudible* GetAudible() const { return fAudible; }
|
||||
/// don't call this otherwise!
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
void SetSoundFilename(int index, const char *filename, bool isCompressed);
|
||||
int GetSoundIndex(const char *keyname);
|
||||
};
|
||||
|
||||
|
||||
#endif // plAudioInterface_inc
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,203 +1,203 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef plCoordinateInterface_inc
|
||||
#define plCoordinateInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsMatrix44.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
|
||||
|
||||
class plCoordinateInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
enum plCoordinateProperties {
|
||||
kDisable = 0, // prop 0 is always disable, declared in plObjInterface
|
||||
kCanEverDelayTransform = 1, // we can sometimes delay our transform eval (i.e. we're on a physics object)
|
||||
kDelayedTransformEval = 2, // we're currently registering for the DelayedTransformMsg (we, and all our
|
||||
// descendants, have the kCanEverDelayTransform prop)
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
|
||||
enum plCoordinateTransformPhases
|
||||
{
|
||||
kTransformPhaseNormal,
|
||||
kTransformPhaseDelayed,
|
||||
};
|
||||
|
||||
protected:
|
||||
enum {
|
||||
kTransformDirty = 0x1,
|
||||
kWarp = 0x2,
|
||||
|
||||
kMaxState = 0xffff
|
||||
};
|
||||
enum plAttachFlags {
|
||||
kMaintainWorldPosition = 0x1,
|
||||
kMaintainSceneNode = 0x2,
|
||||
kAboutToAttach = 0x4
|
||||
};
|
||||
enum Reason {
|
||||
kReasonUnknown = 0x1, // somebody moved us
|
||||
kReasonPhysics = 0x2, // physics moved us
|
||||
kMaxReasons = 0xffff // sixteen bits
|
||||
};
|
||||
|
||||
// Set by the client in IUpdate(). This tells us where we are in the update loop so that we know
|
||||
// which transform message to register for when our transform is dirtied.
|
||||
static UInt8 fTransformPhase;
|
||||
|
||||
// Temp debugging tool, so we can quickly (dis/en)able delayed transforms at runtime.
|
||||
static hsBool fDelayedTransformsEnabled;
|
||||
|
||||
UInt16 fState;
|
||||
UInt16 fReason; // why we've changed position (if we have)
|
||||
|
||||
hsTArray<plSceneObject*> fChildren;
|
||||
plCoordinateInterface* fParent; // if this changes, marks us as dirty
|
||||
|
||||
hsMatrix44 fLocalToParent;
|
||||
hsMatrix44 fParentToLocal;
|
||||
|
||||
hsMatrix44 fLocalToWorld;
|
||||
hsMatrix44 fWorldToLocal;
|
||||
|
||||
virtual void ISetOwner(plSceneObject* so);
|
||||
|
||||
virtual void ISetParent(plCoordinateInterface* par); // don't use, use AddChild on parent
|
||||
virtual void ISetSceneNode(plKey newNode);
|
||||
// objectToo moves the sceneObject to the new room, else just move the data and remove
|
||||
// the object from whatever room he's in.
|
||||
|
||||
// Network only strange functions. Do not emulate or generalize this functionality.
|
||||
void ISetNetGroupRecur(plNetGroupId netGroup);
|
||||
|
||||
virtual void ISetChild(plSceneObject* child, int which); // sets parent on child
|
||||
virtual void IAddChild(plSceneObject* child); // sets parent on child
|
||||
virtual void IRemoveChild(plSceneObject* child); // removes this as parent of child
|
||||
virtual void IRemoveChild(int i); // removes this as parent of child
|
||||
virtual void IAttachChild(plSceneObject* child, UInt8 flags); // physically attaches child to us
|
||||
virtual void IDetachChild(plSceneObject* child, UInt8 flags); // physically detach this child from us
|
||||
virtual void IUpdateDelayProp(); // Called whenever a child is added/removed
|
||||
|
||||
virtual void IRecalcTransforms(); // Called by ITransformChanged when we need to re-examine our relationship with our parent.
|
||||
virtual void ITransformChanged(hsBool force, UInt16 reasons, hsBool checkForDelay); // called by SceneObject on TransformChanged messsage
|
||||
|
||||
void IDirtyTransform();
|
||||
void IRegisterForTransformMessage(hsBool delayed);
|
||||
void IUnRegisterForTransformMessage();
|
||||
plCoordinateInterface* IGetRoot();
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plCoordinateInterface();
|
||||
~plCoordinateInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plCoordinateInterface );
|
||||
GETINTERFACE_ANY( plCoordinateInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
virtual void SetLocalToParent(const hsMatrix44& l2p, const hsMatrix44& p2l);
|
||||
// special version for setting transform from physics.
|
||||
// separate to keep from changing interface to add "reason" parameter
|
||||
virtual void SetTransformPhysical(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
virtual void MultTransformLocal(const hsMatrix44& move, const hsMatrix44& invMove);
|
||||
virtual void WarpToWorld(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
virtual void WarpToLocal(const hsMatrix44& l2p, const hsMatrix44& p2l);
|
||||
|
||||
// Force an immediate re-sync of the transforms in the hierarchy this object belongs to,
|
||||
// as opposed to waiting for the plTransformMsg to resync.
|
||||
// There are two uses for this:
|
||||
// a) You need the transforms for this object to be valid NOW, can't wait till after a TransforMsg
|
||||
// In this case, you want to flush from the root, because something higher up the hierarchy
|
||||
// may be dirty, which invalidates this object's transforms
|
||||
// b) You've just dirtied this object's transform, and need it to propagate downward from here NOW
|
||||
// In this case, fromRoot should be false, because you haven't dirtied anything higher up
|
||||
// the hierarchy.
|
||||
// Another way to look at it is, if the transforms for the tree were correct before you messed with
|
||||
// this object, you only need to flush the transforms for this object and its recursive children,
|
||||
// so fromRoot=false.
|
||||
// If the entire tree is potentially dirty and you need to read from it, you want the entire tree
|
||||
// synced up, so fromRoot=true.
|
||||
// fromRoot=true is always safe, just potentially wasteful, so if you don't know, use fromRoot=true or
|
||||
// preferably, don't use this function.
|
||||
void FlushTransform(hsBool fromRoot=true);
|
||||
|
||||
virtual const hsMatrix44& GetLocalToParent() const { return fLocalToParent; }
|
||||
virtual const hsMatrix44& GetParentToLocal() const { return fParentToLocal; }
|
||||
|
||||
virtual const hsMatrix44& GetLocalToWorld() const { return fLocalToWorld; }
|
||||
virtual const hsMatrix44& GetWorldToLocal() const { return fWorldToLocal; }
|
||||
|
||||
virtual const hsPoint3 GetWorldPos() const { return fLocalToWorld.GetTranslate(); }
|
||||
|
||||
virtual int GetNumChildren() const { return fChildren.GetCount(); }
|
||||
virtual plCoordinateInterface* GetChild(int i) const;
|
||||
virtual plCoordinateInterface* GetParent() const { return fParent; }
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
UInt16 GetReasons();
|
||||
void ClearReasons();
|
||||
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
static UInt8 GetTransformPhase() { return fTransformPhase; }
|
||||
static void SetTransformPhase(UInt8 phase) { fTransformPhase = phase; }
|
||||
|
||||
static hsBool GetDelayedTransformsEnabled() { return fDelayedTransformsEnabled; }
|
||||
static void SetDelayedTransformsEnabled(hsBool val) { fDelayedTransformsEnabled = val; }
|
||||
};
|
||||
|
||||
|
||||
#endif // plCoordinateInterface_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
|
||||
#ifndef plCoordinateInterface_inc
|
||||
#define plCoordinateInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsMatrix44.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
|
||||
|
||||
class plCoordinateInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
enum plCoordinateProperties {
|
||||
kDisable = 0, // prop 0 is always disable, declared in plObjInterface
|
||||
kCanEverDelayTransform = 1, // we can sometimes delay our transform eval (i.e. we're on a physics object)
|
||||
kDelayedTransformEval = 2, // we're currently registering for the DelayedTransformMsg (we, and all our
|
||||
// descendants, have the kCanEverDelayTransform prop)
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
|
||||
enum plCoordinateTransformPhases
|
||||
{
|
||||
kTransformPhaseNormal,
|
||||
kTransformPhaseDelayed,
|
||||
};
|
||||
|
||||
protected:
|
||||
enum {
|
||||
kTransformDirty = 0x1,
|
||||
kWarp = 0x2,
|
||||
|
||||
kMaxState = 0xffff
|
||||
};
|
||||
enum plAttachFlags {
|
||||
kMaintainWorldPosition = 0x1,
|
||||
kMaintainSceneNode = 0x2,
|
||||
kAboutToAttach = 0x4
|
||||
};
|
||||
enum Reason {
|
||||
kReasonUnknown = 0x1, // somebody moved us
|
||||
kReasonPhysics = 0x2, // physics moved us
|
||||
kMaxReasons = 0xffff // sixteen bits
|
||||
};
|
||||
|
||||
// Set by the client in IUpdate(). This tells us where we are in the update loop so that we know
|
||||
// which transform message to register for when our transform is dirtied.
|
||||
static UInt8 fTransformPhase;
|
||||
|
||||
// Temp debugging tool, so we can quickly (dis/en)able delayed transforms at runtime.
|
||||
static hsBool fDelayedTransformsEnabled;
|
||||
|
||||
UInt16 fState;
|
||||
UInt16 fReason; // why we've changed position (if we have)
|
||||
|
||||
hsTArray<plSceneObject*> fChildren;
|
||||
plCoordinateInterface* fParent; // if this changes, marks us as dirty
|
||||
|
||||
hsMatrix44 fLocalToParent;
|
||||
hsMatrix44 fParentToLocal;
|
||||
|
||||
hsMatrix44 fLocalToWorld;
|
||||
hsMatrix44 fWorldToLocal;
|
||||
|
||||
virtual void ISetOwner(plSceneObject* so);
|
||||
|
||||
virtual void ISetParent(plCoordinateInterface* par); // don't use, use AddChild on parent
|
||||
virtual void ISetSceneNode(plKey newNode);
|
||||
// objectToo moves the sceneObject to the new room, else just move the data and remove
|
||||
// the object from whatever room he's in.
|
||||
|
||||
// Network only strange functions. Do not emulate or generalize this functionality.
|
||||
void ISetNetGroupRecur(plNetGroupId netGroup);
|
||||
|
||||
virtual void ISetChild(plSceneObject* child, int which); // sets parent on child
|
||||
virtual void IAddChild(plSceneObject* child); // sets parent on child
|
||||
virtual void IRemoveChild(plSceneObject* child); // removes this as parent of child
|
||||
virtual void IRemoveChild(int i); // removes this as parent of child
|
||||
virtual void IAttachChild(plSceneObject* child, UInt8 flags); // physically attaches child to us
|
||||
virtual void IDetachChild(plSceneObject* child, UInt8 flags); // physically detach this child from us
|
||||
virtual void IUpdateDelayProp(); // Called whenever a child is added/removed
|
||||
|
||||
virtual void IRecalcTransforms(); // Called by ITransformChanged when we need to re-examine our relationship with our parent.
|
||||
virtual void ITransformChanged(hsBool force, UInt16 reasons, hsBool checkForDelay); // called by SceneObject on TransformChanged messsage
|
||||
|
||||
void IDirtyTransform();
|
||||
void IRegisterForTransformMessage(hsBool delayed);
|
||||
void IUnRegisterForTransformMessage();
|
||||
plCoordinateInterface* IGetRoot();
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plCoordinateInterface();
|
||||
~plCoordinateInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plCoordinateInterface );
|
||||
GETINTERFACE_ANY( plCoordinateInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
virtual void SetLocalToParent(const hsMatrix44& l2p, const hsMatrix44& p2l);
|
||||
// special version for setting transform from physics.
|
||||
// separate to keep from changing interface to add "reason" parameter
|
||||
virtual void SetTransformPhysical(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
virtual void MultTransformLocal(const hsMatrix44& move, const hsMatrix44& invMove);
|
||||
virtual void WarpToWorld(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
virtual void WarpToLocal(const hsMatrix44& l2p, const hsMatrix44& p2l);
|
||||
|
||||
// Force an immediate re-sync of the transforms in the hierarchy this object belongs to,
|
||||
// as opposed to waiting for the plTransformMsg to resync.
|
||||
// There are two uses for this:
|
||||
// a) You need the transforms for this object to be valid NOW, can't wait till after a TransforMsg
|
||||
// In this case, you want to flush from the root, because something higher up the hierarchy
|
||||
// may be dirty, which invalidates this object's transforms
|
||||
// b) You've just dirtied this object's transform, and need it to propagate downward from here NOW
|
||||
// In this case, fromRoot should be false, because you haven't dirtied anything higher up
|
||||
// the hierarchy.
|
||||
// Another way to look at it is, if the transforms for the tree were correct before you messed with
|
||||
// this object, you only need to flush the transforms for this object and its recursive children,
|
||||
// so fromRoot=false.
|
||||
// If the entire tree is potentially dirty and you need to read from it, you want the entire tree
|
||||
// synced up, so fromRoot=true.
|
||||
// fromRoot=true is always safe, just potentially wasteful, so if you don't know, use fromRoot=true or
|
||||
// preferably, don't use this function.
|
||||
void FlushTransform(hsBool fromRoot=true);
|
||||
|
||||
virtual const hsMatrix44& GetLocalToParent() const { return fLocalToParent; }
|
||||
virtual const hsMatrix44& GetParentToLocal() const { return fParentToLocal; }
|
||||
|
||||
virtual const hsMatrix44& GetLocalToWorld() const { return fLocalToWorld; }
|
||||
virtual const hsMatrix44& GetWorldToLocal() const { return fWorldToLocal; }
|
||||
|
||||
virtual const hsPoint3 GetWorldPos() const { return fLocalToWorld.GetTranslate(); }
|
||||
|
||||
virtual int GetNumChildren() const { return fChildren.GetCount(); }
|
||||
virtual plCoordinateInterface* GetChild(int i) const;
|
||||
virtual plCoordinateInterface* GetParent() const { return fParent; }
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
UInt16 GetReasons();
|
||||
void ClearReasons();
|
||||
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
static UInt8 GetTransformPhase() { return fTransformPhase; }
|
||||
static void SetTransformPhase(UInt8 phase) { fTransformPhase = phase; }
|
||||
|
||||
static hsBool GetDelayedTransformsEnabled() { return fDelayedTransformsEnabled; }
|
||||
static void SetDelayedTransformsEnabled(hsBool val) { fDelayedTransformsEnabled = val; }
|
||||
};
|
||||
|
||||
|
||||
#endif // plCoordinateInterface_inc
|
||||
|
@ -1,387 +1,387 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plDrawInterface.h"
|
||||
#include "plDrawable.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plDISpansMsg.h"
|
||||
|
||||
plDrawInterface::plDrawInterface()
|
||||
{
|
||||
}
|
||||
|
||||
plDrawInterface::~plDrawInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void plDrawInterface::SetDrawableMeshIndex( UInt8 which, UInt32 index )
|
||||
{
|
||||
ICheckDrawableIndex(which);
|
||||
|
||||
fDrawableIndices[which] = index;
|
||||
}
|
||||
|
||||
void plDrawInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on);
|
||||
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetProperty(fDrawableIndices[i], prop, on);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetSceneNode(plKey newNode)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetSceneNode(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if( !GetProperty(kDisable) )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetTransform( fDrawableIndices[i], l2w, w2l );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetLocalBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetLocalBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetWorldBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetWorldBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetMaxWorldBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetMaxWorldBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void plDrawInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
int nDrawables = s->ReadSwap32();
|
||||
if (nDrawables > 0)
|
||||
ICheckDrawableIndex(nDrawables-1);
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
fDrawableIndices[i] = s->ReadSwap32();
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, i, plIntRefMsg::kDrawable);
|
||||
mgr->ReadKeyNotifyMe(s,refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
int nReg = s->ReadSwap32();
|
||||
fRegions.SetCountAndZero(nReg);
|
||||
for( i = 0; i < nReg; i++ )
|
||||
{
|
||||
plGenRefMsg* refMsg = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisRegion);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
s->WriteSwap32(fDrawables.GetCount());
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
s->WriteSwap32(fDrawableIndices[i]);
|
||||
|
||||
mgr->WriteKey(s, fDrawables[i]);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fRegions.GetCount());
|
||||
for( i = 0; i < fRegions.GetCount(); i++ )
|
||||
{
|
||||
mgr->WriteKey(s, fRegions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//// ReleaseData //////////////////////////////////////////////////////////////
|
||||
// Called by SceneViewer to release the data for this given object (when
|
||||
// its parent sceneObject is deleted).
|
||||
|
||||
void plDrawInterface::ReleaseData( void )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] && (fDrawableIndices[i] != UInt32(-1)) )
|
||||
{
|
||||
plDISpansMsg* diMsg = TRACKED_NEW plDISpansMsg(fDrawables[i]->GetKey(), plDISpansMsg::kRemovingSpan, fDrawableIndices[i], 0);
|
||||
diMsg->SetSender(GetKey());
|
||||
diMsg->Send();
|
||||
}
|
||||
//fDrawableIndices[i] = UInt32(-1);
|
||||
fDrawables.Reset();
|
||||
fDrawableIndices.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ICheckDrawableIndex(UInt8 which)
|
||||
{
|
||||
if( which >= fDrawableIndices.GetCount() )
|
||||
{
|
||||
fDrawables.ExpandAndZero(which+1);
|
||||
|
||||
int n = fDrawableIndices.GetCount();
|
||||
fDrawableIndices.ExpandAndZero(which+1);
|
||||
int i;
|
||||
for( i = n; i <= which; i++ )
|
||||
fDrawableIndices[i] = UInt32(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetDrawable(UInt8 which, plDrawable* dr)
|
||||
{
|
||||
ICheckDrawableIndex(which);
|
||||
fDrawables[which] = dr;
|
||||
|
||||
if( dr )
|
||||
dr->SetSceneNode(GetSceneNode());
|
||||
|
||||
// We might read the vis regions before the drawables, so
|
||||
// we have to check for any already loaded.
|
||||
ISetVisRegions(which);
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
if( fDrawableIndices[which] != (UInt32)-1 )
|
||||
{
|
||||
plDISpansMsg* diMsg = TRACKED_NEW plDISpansMsg(dr->GetKey(), plDISpansMsg::kAddingSpan, fDrawableIndices[which], 0);
|
||||
diMsg->SetSender(GetKey());
|
||||
diMsg->Send();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void plDrawInterface::IRemoveDrawable(plDrawable *dr)
|
||||
{
|
||||
int idx = fDrawables.Find(dr);
|
||||
if( fDrawables.kMissingIndex != idx )
|
||||
{
|
||||
fDrawables[idx] = nil;
|
||||
fDrawableIndices[idx] = UInt32(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
hsAssert(false, "Trying to remove a drawable that doesn't belong to us");
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetVisRegion(hsKeyedObject* reg, hsBool on)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] && (fDrawableIndices[i] != UInt32(-1)) )
|
||||
{
|
||||
fDrawables[i]->SetDISpanVisSet(fDrawableIndices[i], reg, on);
|
||||
}
|
||||
}
|
||||
int idx = fRegions.Find(reg);
|
||||
if( on )
|
||||
{
|
||||
if( idx == fRegions.kMissingIndex )
|
||||
fRegions.Append(reg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( idx != fRegions.kMissingIndex )
|
||||
fRegions.Remove(idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetVisRegions(int iDraw)
|
||||
{
|
||||
if( fDrawables[iDraw] && (fDrawableIndices[iDraw] != UInt32(-1)) )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fRegions.GetCount(); i++ )
|
||||
{
|
||||
fDrawables[iDraw]->SetDISpanVisSet(fDrawableIndices[iDraw], fRegions[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export only. Use messages for runtime
|
||||
void plDrawInterface::SetDrawable(UInt8 which, plDrawable *dr)
|
||||
{
|
||||
if( dr )
|
||||
{
|
||||
// This is a little convoluted, but it makes GCC happy and doesn't hurt anybody.
|
||||
plIntRefMsg* intRefMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, which, plIntRefMsg::kDrawable);
|
||||
plRefMsg* refMsg = intRefMsg;
|
||||
// hsgResMgr::ResMgr()->SendRef(dr->GetKey(), intRefMsg, plRefFlags::kActiveRef); // THIS WON'T COMPILE UNDER GCC
|
||||
hsgResMgr::ResMgr()->SendRef(dr, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetDrawable(which, nil);
|
||||
}
|
||||
}
|
||||
|
||||
hsBool plDrawInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kDrawable:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
IRemoveDrawable(plDrawable::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetDrawable((UInt8)intRefMsg->fWhich, plDrawable::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
plGenRefMsg* genRefMsg = plGenRefMsg::ConvertNoRef(msg);
|
||||
if( genRefMsg )
|
||||
{
|
||||
switch( genRefMsg->fType )
|
||||
{
|
||||
case kRefVisRegion:
|
||||
if( genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) )
|
||||
ISetVisRegion(genRefMsg->GetRef(), true);
|
||||
else
|
||||
ISetVisRegion(genRefMsg->GetRef(), false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef( msg );
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty(kDisable, pEnableMsg->Cmd(plEnableMsg::kDisable));
|
||||
if( GetOwner() )
|
||||
SetTransform(GetOwner()->GetLocalToWorld(), GetOwner()->GetWorldToLocal());
|
||||
return true;
|
||||
}
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
void plDrawInterface::SetUpForParticleSystem( UInt32 maxNumEmitters, UInt32 maxNumParticles, hsGMaterial *material, hsTArray<plKey>& lights )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
SetDrawableMeshIndex( 0, fDrawables[0]->CreateParticleSystem( maxNumEmitters, maxNumParticles, material ) );
|
||||
int i;
|
||||
for( i = 0; i < lights.GetCount(); i++ )
|
||||
{
|
||||
hsgResMgr::ResMgr()->AddViaNotify(lights[i], TRACKED_NEW plGenRefMsg(fDrawables[0]->GetKey(), plRefMsg::kOnCreate, fDrawableIndices[0], plDrawable::kMsgPermaLightDI), plRefFlags::kPassiveRef);
|
||||
}
|
||||
|
||||
ISetVisRegions(0);
|
||||
}
|
||||
|
||||
void plDrawInterface::ResetParticleSystem( void )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
fDrawables[0]->ResetParticleSystem( fDrawableIndices[0] );
|
||||
}
|
||||
|
||||
void plDrawInterface::AssignEmitterToParticleSystem( plParticleEmitter *emitter )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
fDrawables[0]->AssignEmitterToParticleSystem( fDrawableIndices[0], emitter );
|
||||
}
|
||||
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plDrawInterface.h"
|
||||
#include "plDrawable.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plDISpansMsg.h"
|
||||
|
||||
plDrawInterface::plDrawInterface()
|
||||
{
|
||||
}
|
||||
|
||||
plDrawInterface::~plDrawInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void plDrawInterface::SetDrawableMeshIndex( UInt8 which, UInt32 index )
|
||||
{
|
||||
ICheckDrawableIndex(which);
|
||||
|
||||
fDrawableIndices[which] = index;
|
||||
}
|
||||
|
||||
void plDrawInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on);
|
||||
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetProperty(fDrawableIndices[i], prop, on);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetSceneNode(plKey newNode)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetSceneNode(newNode);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if( !GetProperty(kDisable) )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
fDrawables[i]->SetTransform( fDrawableIndices[i], l2w, w2l );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetLocalBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetLocalBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetWorldBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetWorldBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
const hsBounds3Ext plDrawInterface::GetMaxWorldBounds() const
|
||||
{
|
||||
hsBounds3Ext retVal;
|
||||
retVal.MakeEmpty();
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] )
|
||||
retVal.Union(&fDrawables[i]->GetMaxWorldBounds(fDrawableIndices[i]));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void plDrawInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
int nDrawables = s->ReadSwap32();
|
||||
if (nDrawables > 0)
|
||||
ICheckDrawableIndex(nDrawables-1);
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
fDrawableIndices[i] = s->ReadSwap32();
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, i, plIntRefMsg::kDrawable);
|
||||
mgr->ReadKeyNotifyMe(s,refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
int nReg = s->ReadSwap32();
|
||||
fRegions.SetCountAndZero(nReg);
|
||||
for( i = 0; i < nReg; i++ )
|
||||
{
|
||||
plGenRefMsg* refMsg = TRACKED_NEW plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisRegion);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
s->WriteSwap32(fDrawables.GetCount());
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
s->WriteSwap32(fDrawableIndices[i]);
|
||||
|
||||
mgr->WriteKey(s, fDrawables[i]);
|
||||
}
|
||||
|
||||
s->WriteSwap32(fRegions.GetCount());
|
||||
for( i = 0; i < fRegions.GetCount(); i++ )
|
||||
{
|
||||
mgr->WriteKey(s, fRegions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//// ReleaseData //////////////////////////////////////////////////////////////
|
||||
// Called by SceneViewer to release the data for this given object (when
|
||||
// its parent sceneObject is deleted).
|
||||
|
||||
void plDrawInterface::ReleaseData( void )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] && (fDrawableIndices[i] != UInt32(-1)) )
|
||||
{
|
||||
plDISpansMsg* diMsg = TRACKED_NEW plDISpansMsg(fDrawables[i]->GetKey(), plDISpansMsg::kRemovingSpan, fDrawableIndices[i], 0);
|
||||
diMsg->SetSender(GetKey());
|
||||
diMsg->Send();
|
||||
}
|
||||
//fDrawableIndices[i] = UInt32(-1);
|
||||
fDrawables.Reset();
|
||||
fDrawableIndices.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ICheckDrawableIndex(UInt8 which)
|
||||
{
|
||||
if( which >= fDrawableIndices.GetCount() )
|
||||
{
|
||||
fDrawables.ExpandAndZero(which+1);
|
||||
|
||||
int n = fDrawableIndices.GetCount();
|
||||
fDrawableIndices.ExpandAndZero(which+1);
|
||||
int i;
|
||||
for( i = n; i <= which; i++ )
|
||||
fDrawableIndices[i] = UInt32(-1);
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetDrawable(UInt8 which, plDrawable* dr)
|
||||
{
|
||||
ICheckDrawableIndex(which);
|
||||
fDrawables[which] = dr;
|
||||
|
||||
if( dr )
|
||||
dr->SetSceneNode(GetSceneNode());
|
||||
|
||||
// We might read the vis regions before the drawables, so
|
||||
// we have to check for any already loaded.
|
||||
ISetVisRegions(which);
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
if( fDrawableIndices[which] != (UInt32)-1 )
|
||||
{
|
||||
plDISpansMsg* diMsg = TRACKED_NEW plDISpansMsg(dr->GetKey(), plDISpansMsg::kAddingSpan, fDrawableIndices[which], 0);
|
||||
diMsg->SetSender(GetKey());
|
||||
diMsg->Send();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void plDrawInterface::IRemoveDrawable(plDrawable *dr)
|
||||
{
|
||||
int idx = fDrawables.Find(dr);
|
||||
if( fDrawables.kMissingIndex != idx )
|
||||
{
|
||||
fDrawables[idx] = nil;
|
||||
fDrawableIndices[idx] = UInt32(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
hsAssert(false, "Trying to remove a drawable that doesn't belong to us");
|
||||
}
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetVisRegion(hsKeyedObject* reg, hsBool on)
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fDrawables.GetCount(); i++ )
|
||||
{
|
||||
if( fDrawables[i] && (fDrawableIndices[i] != UInt32(-1)) )
|
||||
{
|
||||
fDrawables[i]->SetDISpanVisSet(fDrawableIndices[i], reg, on);
|
||||
}
|
||||
}
|
||||
int idx = fRegions.Find(reg);
|
||||
if( on )
|
||||
{
|
||||
if( idx == fRegions.kMissingIndex )
|
||||
fRegions.Append(reg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( idx != fRegions.kMissingIndex )
|
||||
fRegions.Remove(idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void plDrawInterface::ISetVisRegions(int iDraw)
|
||||
{
|
||||
if( fDrawables[iDraw] && (fDrawableIndices[iDraw] != UInt32(-1)) )
|
||||
{
|
||||
int i;
|
||||
for( i = 0; i < fRegions.GetCount(); i++ )
|
||||
{
|
||||
fDrawables[iDraw]->SetDISpanVisSet(fDrawableIndices[iDraw], fRegions[i], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export only. Use messages for runtime
|
||||
void plDrawInterface::SetDrawable(UInt8 which, plDrawable *dr)
|
||||
{
|
||||
if( dr )
|
||||
{
|
||||
// This is a little convoluted, but it makes GCC happy and doesn't hurt anybody.
|
||||
plIntRefMsg* intRefMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, which, plIntRefMsg::kDrawable);
|
||||
plRefMsg* refMsg = intRefMsg;
|
||||
// hsgResMgr::ResMgr()->SendRef(dr->GetKey(), intRefMsg, plRefFlags::kActiveRef); // THIS WON'T COMPILE UNDER GCC
|
||||
hsgResMgr::ResMgr()->SendRef(dr, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetDrawable(which, nil);
|
||||
}
|
||||
}
|
||||
|
||||
hsBool plDrawInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kDrawable:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
IRemoveDrawable(plDrawable::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
else
|
||||
{
|
||||
ISetDrawable((UInt8)intRefMsg->fWhich, plDrawable::ConvertNoRef(intRefMsg->GetRef()));
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
plGenRefMsg* genRefMsg = plGenRefMsg::ConvertNoRef(msg);
|
||||
if( genRefMsg )
|
||||
{
|
||||
switch( genRefMsg->fType )
|
||||
{
|
||||
case kRefVisRegion:
|
||||
if( genRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) )
|
||||
ISetVisRegion(genRefMsg->GetRef(), true);
|
||||
else
|
||||
ISetVisRegion(genRefMsg->GetRef(), false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef( msg );
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty(kDisable, pEnableMsg->Cmd(plEnableMsg::kDisable));
|
||||
if( GetOwner() )
|
||||
SetTransform(GetOwner()->GetLocalToWorld(), GetOwner()->GetWorldToLocal());
|
||||
return true;
|
||||
}
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
void plDrawInterface::SetUpForParticleSystem( UInt32 maxNumEmitters, UInt32 maxNumParticles, hsGMaterial *material, hsTArray<plKey>& lights )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
SetDrawableMeshIndex( 0, fDrawables[0]->CreateParticleSystem( maxNumEmitters, maxNumParticles, material ) );
|
||||
int i;
|
||||
for( i = 0; i < lights.GetCount(); i++ )
|
||||
{
|
||||
hsgResMgr::ResMgr()->AddViaNotify(lights[i], TRACKED_NEW plGenRefMsg(fDrawables[0]->GetKey(), plRefMsg::kOnCreate, fDrawableIndices[0], plDrawable::kMsgPermaLightDI), plRefFlags::kPassiveRef);
|
||||
}
|
||||
|
||||
ISetVisRegions(0);
|
||||
}
|
||||
|
||||
void plDrawInterface::ResetParticleSystem( void )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
fDrawables[0]->ResetParticleSystem( fDrawableIndices[0] );
|
||||
}
|
||||
|
||||
void plDrawInterface::AssignEmitterToParticleSystem( plParticleEmitter *emitter )
|
||||
{
|
||||
hsAssert( fDrawables[0] != nil, "No drawable to use for particle system!" );
|
||||
fDrawables[0]->AssignEmitterToParticleSystem( fDrawableIndices[0], emitter );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,124 +1,124 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plDrawInterface_inc
|
||||
#define plDrawInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plDrawable;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
class hsGMaterial;
|
||||
class plParticleEmitter;
|
||||
|
||||
class plDrawInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plDrawProperties {
|
||||
kDisable = 0,
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
enum {
|
||||
kRefVisRegion
|
||||
};
|
||||
|
||||
protected:
|
||||
hsTArray<plDrawable*> fDrawables;
|
||||
hsTArray<UInt32> fDrawableIndices;
|
||||
|
||||
hsTArray<hsKeyedObject*> fRegions;
|
||||
|
||||
void ISetVisRegions(int iDraw);
|
||||
void ISetVisRegion(hsKeyedObject* ref, hsBool on);
|
||||
void ISetDrawable(UInt8 which, plDrawable* dr);
|
||||
void IRemoveDrawable(plDrawable* dr);
|
||||
void ISetSceneNode(plKey newNode);
|
||||
virtual void ICheckDrawableIndex(UInt8 which);
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plDrawInterface();
|
||||
virtual ~plDrawInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plDrawInterface );
|
||||
GETINTERFACE_ANY( plDrawInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
// Bounds are gettable only, they are computed on the drawable.
|
||||
const hsBounds3Ext GetLocalBounds() const;
|
||||
const hsBounds3Ext GetWorldBounds() const;
|
||||
const hsBounds3Ext GetMaxWorldBounds() const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
|
||||
/// Funky particle system functions
|
||||
void SetUpForParticleSystem( UInt32 maxNumEmitters, UInt32 maxNumParticles, hsGMaterial *material, hsTArray<plKey>& lights );
|
||||
void ResetParticleSystem( void );
|
||||
void AssignEmitterToParticleSystem( plParticleEmitter *emitter );
|
||||
|
||||
/// EXPORT-ONLY
|
||||
void SetDrawable(UInt8 which, plDrawable* dr);
|
||||
plDrawable* GetDrawable( UInt8 which ) const { return which < fDrawables.GetCount() ? fDrawables[which] : nil; }
|
||||
UInt32 GetNumDrawables() const { return fDrawables.GetCount(); }
|
||||
// Sets the triMesh index to be used when referring to our spans in the drawable
|
||||
void SetDrawableMeshIndex( UInt8 which, UInt32 index );
|
||||
UInt32 GetDrawableMeshIndex( UInt8 which ) const { return which < fDrawableIndices.GetCount() ? fDrawableIndices[which] : UInt32(-1); }
|
||||
};
|
||||
|
||||
|
||||
#endif // plDrawInterface_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plDrawInterface_inc
|
||||
#define plDrawInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plDrawable;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
class hsGMaterial;
|
||||
class plParticleEmitter;
|
||||
|
||||
class plDrawInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plDrawProperties {
|
||||
kDisable = 0,
|
||||
|
||||
kNumProps // last in the list
|
||||
};
|
||||
enum {
|
||||
kRefVisRegion
|
||||
};
|
||||
|
||||
protected:
|
||||
hsTArray<plDrawable*> fDrawables;
|
||||
hsTArray<UInt32> fDrawableIndices;
|
||||
|
||||
hsTArray<hsKeyedObject*> fRegions;
|
||||
|
||||
void ISetVisRegions(int iDraw);
|
||||
void ISetVisRegion(hsKeyedObject* ref, hsBool on);
|
||||
void ISetDrawable(UInt8 which, plDrawable* dr);
|
||||
void IRemoveDrawable(plDrawable* dr);
|
||||
void ISetSceneNode(plKey newNode);
|
||||
virtual void ICheckDrawableIndex(UInt8 which);
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
public:
|
||||
plDrawInterface();
|
||||
virtual ~plDrawInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plDrawInterface );
|
||||
GETINTERFACE_ANY( plDrawInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
// Bounds are gettable only, they are computed on the drawable.
|
||||
const hsBounds3Ext GetLocalBounds() const;
|
||||
const hsBounds3Ext GetWorldBounds() const;
|
||||
const hsBounds3Ext GetMaxWorldBounds() const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
|
||||
/// Funky particle system functions
|
||||
void SetUpForParticleSystem( UInt32 maxNumEmitters, UInt32 maxNumParticles, hsGMaterial *material, hsTArray<plKey>& lights );
|
||||
void ResetParticleSystem( void );
|
||||
void AssignEmitterToParticleSystem( plParticleEmitter *emitter );
|
||||
|
||||
/// EXPORT-ONLY
|
||||
void SetDrawable(UInt8 which, plDrawable* dr);
|
||||
plDrawable* GetDrawable( UInt8 which ) const { return which < fDrawables.GetCount() ? fDrawables[which] : nil; }
|
||||
UInt32 GetNumDrawables() const { return fDrawables.GetCount(); }
|
||||
// Sets the triMesh index to be used when referring to our spans in the drawable
|
||||
void SetDrawableMeshIndex( UInt8 which, UInt32 index );
|
||||
UInt32 GetDrawableMeshIndex( UInt8 which ) const { return which < fDrawableIndices.GetCount() ? fDrawableIndices[which] : UInt32(-1); }
|
||||
};
|
||||
|
||||
|
||||
#endif // plDrawInterface_inc
|
||||
|
@ -1,132 +1,132 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plObjInterface.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
|
||||
|
||||
plObjInterface::plObjInterface()
|
||||
: fOwner(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plObjInterface::~plObjInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void plObjInterface::ISetOwner(plSceneObject* owner)
|
||||
{
|
||||
if( fOwner != owner )
|
||||
{
|
||||
fOwner = owner;
|
||||
if( fOwner )
|
||||
fOwner->ISetInterface(this);
|
||||
}
|
||||
}
|
||||
|
||||
void plObjInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plSynchedObject::Read(s, mgr);
|
||||
|
||||
mgr->ReadKeyNotifyMe(s, TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kOwner), plRefFlags::kPassiveRef);
|
||||
|
||||
fProps.Read(s);
|
||||
}
|
||||
|
||||
void plObjInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plSynchedObject::Write(s, mgr);
|
||||
|
||||
mgr->WriteKey(s, fOwner);
|
||||
fProps.Write(s);
|
||||
}
|
||||
|
||||
hsBool plObjInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
hsBool retVal = false;
|
||||
|
||||
plEnableMsg* enaMsg = plEnableMsg::ConvertNoRef(msg);
|
||||
if( enaMsg )
|
||||
{
|
||||
SetProperty(kDisable, enaMsg->Cmd(plEnableMsg::kDisable));
|
||||
return true;
|
||||
}
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kOwner:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) )
|
||||
{
|
||||
plSceneObject* owner = plSceneObject::ConvertNoRef(intRefMsg->GetRef());
|
||||
ISetOwner(owner);
|
||||
}
|
||||
else if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
ISetOwner(nil);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return plSynchedObject::MsgReceive(msg);
|
||||
}
|
||||
|
||||
//
|
||||
// assign and update my properties from the bitVector passed in
|
||||
//
|
||||
void plObjInterface::ISetAllProperties(const hsBitVector& b)
|
||||
{
|
||||
// if (&b != &fProps) // don't copy if they are the same variable
|
||||
|
||||
fProps = b;
|
||||
|
||||
int i;
|
||||
for(i=0;i<GetNumProperties(); i++)
|
||||
SetProperty(i, GetProperty(i));
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plObjInterface.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
|
||||
|
||||
plObjInterface::plObjInterface()
|
||||
: fOwner(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plObjInterface::~plObjInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void plObjInterface::ISetOwner(plSceneObject* owner)
|
||||
{
|
||||
if( fOwner != owner )
|
||||
{
|
||||
fOwner = owner;
|
||||
if( fOwner )
|
||||
fOwner->ISetInterface(this);
|
||||
}
|
||||
}
|
||||
|
||||
void plObjInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plSynchedObject::Read(s, mgr);
|
||||
|
||||
mgr->ReadKeyNotifyMe(s, TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kOwner), plRefFlags::kPassiveRef);
|
||||
|
||||
fProps.Read(s);
|
||||
}
|
||||
|
||||
void plObjInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plSynchedObject::Write(s, mgr);
|
||||
|
||||
mgr->WriteKey(s, fOwner);
|
||||
fProps.Write(s);
|
||||
}
|
||||
|
||||
hsBool plObjInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
hsBool retVal = false;
|
||||
|
||||
plEnableMsg* enaMsg = plEnableMsg::ConvertNoRef(msg);
|
||||
if( enaMsg )
|
||||
{
|
||||
SetProperty(kDisable, enaMsg->Cmd(plEnableMsg::kDisable));
|
||||
return true;
|
||||
}
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if( intRefMsg )
|
||||
{
|
||||
switch( intRefMsg->fType )
|
||||
{
|
||||
case plIntRefMsg::kOwner:
|
||||
if( intRefMsg->GetContext() & (plRefMsg::kOnCreate|plRefMsg::kOnRequest|plRefMsg::kOnReplace) )
|
||||
{
|
||||
plSceneObject* owner = plSceneObject::ConvertNoRef(intRefMsg->GetRef());
|
||||
ISetOwner(owner);
|
||||
}
|
||||
else if( intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove) )
|
||||
{
|
||||
ISetOwner(nil);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return plSynchedObject::MsgReceive(msg);
|
||||
}
|
||||
|
||||
//
|
||||
// assign and update my properties from the bitVector passed in
|
||||
//
|
||||
void plObjInterface::ISetAllProperties(const hsBitVector& b)
|
||||
{
|
||||
// if (&b != &fProps) // don't copy if they are the same variable
|
||||
|
||||
fProps = b;
|
||||
|
||||
int i;
|
||||
for(i=0;i<GetNumProperties(); i++)
|
||||
SetProperty(i, GetProperty(i));
|
||||
}
|
||||
|
||||
|
@ -1,119 +1,119 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plInterface_inc
|
||||
#define plInterface_inc
|
||||
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "hsStream.h"
|
||||
#include "../pnNetCommon/plSynchedObject.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
class hsResMgr;
|
||||
class plDrawInterface;
|
||||
class plSimulationInterface;
|
||||
class plCoordinateInterface;
|
||||
class plAudioInterface;
|
||||
|
||||
//
|
||||
// Since interfaces are keyed objects with valid uoids and
|
||||
// may have dynamic data (coordinate interface), they are
|
||||
// synched (saved) objects
|
||||
//
|
||||
class plObjInterface : public plSynchedObject
|
||||
{
|
||||
protected:
|
||||
enum {
|
||||
kDisable = 0x0 // Derived interfaces duplicate this, so if you add more here, they need to know.
|
||||
};
|
||||
friend class plSynchedValueBase;
|
||||
friend class plSceneObject;
|
||||
protected:
|
||||
plSceneObject* fOwner;
|
||||
hsBitVector fProps;
|
||||
|
||||
// SetSceneNode just called by owner. If we're an interface to external data,
|
||||
// we need to pass the change on. Otherwise, do nothing.
|
||||
virtual void ISetSceneNode(plKey node) {}
|
||||
plSceneObject* IGetOwner() const { return fOwner; }
|
||||
virtual void ISetOwner(plSceneObject* owner);
|
||||
void ISetAllProperties(const hsBitVector& b);
|
||||
|
||||
plDrawInterface* IGetOwnerDrawInterface() { return fOwner ? fOwner->GetVolatileDrawInterface() : nil; }
|
||||
plSimulationInterface* IGetOwnerSimulationInterface() { return fOwner ? fOwner->GetVolatileSimulationInterface() : nil; }
|
||||
plCoordinateInterface* IGetOwnerCoordinateInterface() { return fOwner ? fOwner->GetVolatileCoordinateInterface() : nil; }
|
||||
plAudioInterface* IGetOwnerAudioInterface() { return fOwner ? fOwner->GetVolatileAudioInterface() : nil; }
|
||||
public:
|
||||
|
||||
plObjInterface();
|
||||
~plObjInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plObjInterface );
|
||||
GETINTERFACE_ANY( plObjInterface, plSynchedObject );
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
const plSceneObject* GetOwner() const { return IGetOwner(); }
|
||||
plKey GetOwnerKey() const { return IGetOwner() ? IGetOwner()->GetKey() : nil; }
|
||||
|
||||
virtual plKey GetSceneNode() const { return IGetOwner() ? IGetOwner()->GetSceneNode() : nil; }
|
||||
|
||||
// override SetProperty to pass the prop down to the pool objects
|
||||
virtual void SetProperty(int prop, hsBool on) { fProps.SetBit(prop, on); }
|
||||
|
||||
// shouldn't need to override GetProperty()
|
||||
hsBool GetProperty(int prop) const { return fProps.IsBitSet(prop); }
|
||||
virtual Int32 GetNumProperties() const = 0;
|
||||
|
||||
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l) = 0;
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual void ReleaseData( void ) { }
|
||||
};
|
||||
|
||||
|
||||
#endif // plInterface_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plInterface_inc
|
||||
#define plInterface_inc
|
||||
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "hsStream.h"
|
||||
#include "../pnNetCommon/plSynchedObject.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
class hsResMgr;
|
||||
class plDrawInterface;
|
||||
class plSimulationInterface;
|
||||
class plCoordinateInterface;
|
||||
class plAudioInterface;
|
||||
|
||||
//
|
||||
// Since interfaces are keyed objects with valid uoids and
|
||||
// may have dynamic data (coordinate interface), they are
|
||||
// synched (saved) objects
|
||||
//
|
||||
class plObjInterface : public plSynchedObject
|
||||
{
|
||||
protected:
|
||||
enum {
|
||||
kDisable = 0x0 // Derived interfaces duplicate this, so if you add more here, they need to know.
|
||||
};
|
||||
friend class plSynchedValueBase;
|
||||
friend class plSceneObject;
|
||||
protected:
|
||||
plSceneObject* fOwner;
|
||||
hsBitVector fProps;
|
||||
|
||||
// SetSceneNode just called by owner. If we're an interface to external data,
|
||||
// we need to pass the change on. Otherwise, do nothing.
|
||||
virtual void ISetSceneNode(plKey node) {}
|
||||
plSceneObject* IGetOwner() const { return fOwner; }
|
||||
virtual void ISetOwner(plSceneObject* owner);
|
||||
void ISetAllProperties(const hsBitVector& b);
|
||||
|
||||
plDrawInterface* IGetOwnerDrawInterface() { return fOwner ? fOwner->GetVolatileDrawInterface() : nil; }
|
||||
plSimulationInterface* IGetOwnerSimulationInterface() { return fOwner ? fOwner->GetVolatileSimulationInterface() : nil; }
|
||||
plCoordinateInterface* IGetOwnerCoordinateInterface() { return fOwner ? fOwner->GetVolatileCoordinateInterface() : nil; }
|
||||
plAudioInterface* IGetOwnerAudioInterface() { return fOwner ? fOwner->GetVolatileAudioInterface() : nil; }
|
||||
public:
|
||||
|
||||
plObjInterface();
|
||||
~plObjInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plObjInterface );
|
||||
GETINTERFACE_ANY( plObjInterface, plSynchedObject );
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
const plSceneObject* GetOwner() const { return IGetOwner(); }
|
||||
plKey GetOwnerKey() const { return IGetOwner() ? IGetOwner()->GetKey() : nil; }
|
||||
|
||||
virtual plKey GetSceneNode() const { return IGetOwner() ? IGetOwner()->GetSceneNode() : nil; }
|
||||
|
||||
// override SetProperty to pass the prop down to the pool objects
|
||||
virtual void SetProperty(int prop, hsBool on) { fProps.SetBit(prop, on); }
|
||||
|
||||
// shouldn't need to override GetProperty()
|
||||
hsBool GetProperty(int prop) const { return fProps.IsBitSet(prop); }
|
||||
virtual Int32 GetNumProperties() const = 0;
|
||||
|
||||
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l) = 0;
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual void ReleaseData( void ) { }
|
||||
};
|
||||
|
||||
|
||||
#endif // plInterface_inc
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,181 +1,181 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plSceneObject_inc
|
||||
#define plSceneObject_inc
|
||||
|
||||
#include "hsBitVector.h"
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "../pnNetCommon/plSynchedObject.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
#include "../pnModifier/plModifier.h"
|
||||
#include "hsStream.h"
|
||||
|
||||
class plObjInterface;
|
||||
class plDrawInterface;
|
||||
class plSimulationInterface;
|
||||
class plCoordinateInterface;
|
||||
class plAudioInterface;
|
||||
class plMessage;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
class plMessage;
|
||||
class plDispatchBase;
|
||||
struct hsMatrix44;
|
||||
|
||||
// The following two aren't dragging the Conversion side into the runtime.
|
||||
// They are just to let the converter do things we don't want done at runtime.
|
||||
// Nice that we can make friends with these opaque classes.
|
||||
class plMaxNode;
|
||||
class plMaxNodeBase;
|
||||
|
||||
class plSceneObject : public plSynchedObject {
|
||||
friend class plSynchedValueBase;
|
||||
private:
|
||||
plDrawInterface* GetVolatileDrawInterface() { return fDrawInterface; }
|
||||
plSimulationInterface* GetVolatileSimulationInterface() { return fSimulationInterface; }
|
||||
plCoordinateInterface* GetVolatileCoordinateInterface() { return fCoordinateInterface; }
|
||||
plAudioInterface* GetVolatileAudioInterface() { return fAudioInterface; }
|
||||
plObjInterface* GetVolatileGenericInterface(UInt16 classIdx) const;
|
||||
|
||||
plModifier* GetVolatileModifier(int i) { return fModifiers[i]; }
|
||||
|
||||
plKey fSceneNode;
|
||||
|
||||
friend class plModifier;
|
||||
friend class plCoordinateInterface;
|
||||
friend class plObjInterface;
|
||||
friend class plMaxNode;
|
||||
friend class plMaxNodeBase;
|
||||
|
||||
hsBool IMsgHandle(plMessage* msg);
|
||||
protected:
|
||||
|
||||
plDrawInterface* fDrawInterface;
|
||||
plSimulationInterface* fSimulationInterface;
|
||||
plCoordinateInterface* fCoordinateInterface;
|
||||
plAudioInterface* fAudioInterface;
|
||||
|
||||
hsTArray<plModifier*> fModifiers;
|
||||
|
||||
hsTArray<plObjInterface*> fGenerics;
|
||||
|
||||
void ISetDrawInterface(plDrawInterface* di);
|
||||
void ISetSimulationInterface(plSimulationInterface* si);
|
||||
void ISetAudioInterface(plAudioInterface* ai);
|
||||
void ISetCoordinateInterface(plCoordinateInterface* ci);
|
||||
|
||||
void IAddGeneric(plObjInterface* gen);
|
||||
void IRemoveGeneric(plObjInterface* gen);
|
||||
void IRemoveAllGenerics();
|
||||
void IPropagateToGenerics(plMessage* msg);
|
||||
void IPropagateToGenerics(const hsBitVector& types, plMessage* msg);
|
||||
|
||||
void IAddModifier(plModifier* mo, int i);
|
||||
void IRemoveModifier(plModifier* mo);
|
||||
hsBool IPropagateToModifiers(plMessage* msg);
|
||||
|
||||
void ISetInterface(plObjInterface* iface);
|
||||
void IRemoveInterface(plObjInterface* iface);
|
||||
void IRemoveInterface(Int16 idx, plObjInterface* iface=nil);
|
||||
|
||||
void ISetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
public:
|
||||
|
||||
plSceneObject();
|
||||
virtual ~plSceneObject();
|
||||
|
||||
CLASSNAME_REGISTER( plSceneObject );
|
||||
GETINTERFACE_ANY( plSceneObject, plSynchedObject );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual const plDrawInterface* GetDrawInterface() const { return fDrawInterface; }
|
||||
virtual const plSimulationInterface* GetSimulationInterface() const { return fSimulationInterface; }
|
||||
virtual const plCoordinateInterface* GetCoordinateInterface() const { return fCoordinateInterface; }
|
||||
virtual const plAudioInterface* GetAudioInterface() const { return fAudioInterface; }
|
||||
|
||||
int GetNumGenerics() const { return fGenerics.GetCount(); }
|
||||
const plObjInterface* GetGeneric(int i) const { return fGenerics[i]; }
|
||||
|
||||
plObjInterface* GetGenericInterface(UInt16 classIdx) const { return GetVolatileGenericInterface(classIdx); }
|
||||
|
||||
int GetNumModifiers() const { return fModifiers.GetCount(); }
|
||||
const plModifier* GetModifier(int i) const { return fModifiers[i]; }
|
||||
const plModifier* GetModifierByType(UInt16 classIdx) const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
virtual hsBool Eval(double secs, hsScalar del);
|
||||
|
||||
void SetSceneNode(plKey newNode);
|
||||
plKey GetSceneNode() const;
|
||||
|
||||
// Network only strange function. Do not emulate or generalize this functionality.
|
||||
virtual void SetNetGroup(plNetGroupId netGroup);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
|
||||
// Force an immediate re-sync of the transforms in the hierarchy this object belongs to,
|
||||
// as opposed to waiting for the plTransformMsg to resync.
|
||||
void FlushTransform();
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
hsMatrix44 GetLocalToWorld() const;
|
||||
hsMatrix44 GetWorldToLocal() const;
|
||||
hsMatrix44 GetLocalToParent() const;
|
||||
hsMatrix44 GetParentToLocal() const;
|
||||
|
||||
hsBool IsFinal(); // "is ready to process Loads"
|
||||
|
||||
// Export only
|
||||
virtual void SetDrawInterface(plDrawInterface* di);
|
||||
virtual void SetSimulationInterface(plSimulationInterface* si);
|
||||
virtual void SetAudioInterface(plAudioInterface* ai);
|
||||
virtual void SetCoordinateInterface(plCoordinateInterface* ci);
|
||||
|
||||
virtual void AddModifier(plModifier* mo);
|
||||
virtual void RemoveModifier(plModifier* mo);
|
||||
};
|
||||
|
||||
#endif // plSceneObject_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plSceneObject_inc
|
||||
#define plSceneObject_inc
|
||||
|
||||
#include "hsBitVector.h"
|
||||
#include "../pnKeyedObject/hsKeyedObject.h"
|
||||
#include "../pnMessage/plRefMsg.h"
|
||||
#include "../pnNetCommon/plSynchedObject.h"
|
||||
#include "../pnNetCommon/plSynchedValue.h"
|
||||
#include "../pnModifier/plModifier.h"
|
||||
#include "hsStream.h"
|
||||
|
||||
class plObjInterface;
|
||||
class plDrawInterface;
|
||||
class plSimulationInterface;
|
||||
class plCoordinateInterface;
|
||||
class plAudioInterface;
|
||||
class plMessage;
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
class plMessage;
|
||||
class plDispatchBase;
|
||||
struct hsMatrix44;
|
||||
|
||||
// The following two aren't dragging the Conversion side into the runtime.
|
||||
// They are just to let the converter do things we don't want done at runtime.
|
||||
// Nice that we can make friends with these opaque classes.
|
||||
class plMaxNode;
|
||||
class plMaxNodeBase;
|
||||
|
||||
class plSceneObject : public plSynchedObject {
|
||||
friend class plSynchedValueBase;
|
||||
private:
|
||||
plDrawInterface* GetVolatileDrawInterface() { return fDrawInterface; }
|
||||
plSimulationInterface* GetVolatileSimulationInterface() { return fSimulationInterface; }
|
||||
plCoordinateInterface* GetVolatileCoordinateInterface() { return fCoordinateInterface; }
|
||||
plAudioInterface* GetVolatileAudioInterface() { return fAudioInterface; }
|
||||
plObjInterface* GetVolatileGenericInterface(UInt16 classIdx) const;
|
||||
|
||||
plModifier* GetVolatileModifier(int i) { return fModifiers[i]; }
|
||||
|
||||
plKey fSceneNode;
|
||||
|
||||
friend class plModifier;
|
||||
friend class plCoordinateInterface;
|
||||
friend class plObjInterface;
|
||||
friend class plMaxNode;
|
||||
friend class plMaxNodeBase;
|
||||
|
||||
hsBool IMsgHandle(plMessage* msg);
|
||||
protected:
|
||||
|
||||
plDrawInterface* fDrawInterface;
|
||||
plSimulationInterface* fSimulationInterface;
|
||||
plCoordinateInterface* fCoordinateInterface;
|
||||
plAudioInterface* fAudioInterface;
|
||||
|
||||
hsTArray<plModifier*> fModifiers;
|
||||
|
||||
hsTArray<plObjInterface*> fGenerics;
|
||||
|
||||
void ISetDrawInterface(plDrawInterface* di);
|
||||
void ISetSimulationInterface(plSimulationInterface* si);
|
||||
void ISetAudioInterface(plAudioInterface* ai);
|
||||
void ISetCoordinateInterface(plCoordinateInterface* ci);
|
||||
|
||||
void IAddGeneric(plObjInterface* gen);
|
||||
void IRemoveGeneric(plObjInterface* gen);
|
||||
void IRemoveAllGenerics();
|
||||
void IPropagateToGenerics(plMessage* msg);
|
||||
void IPropagateToGenerics(const hsBitVector& types, plMessage* msg);
|
||||
|
||||
void IAddModifier(plModifier* mo, int i);
|
||||
void IRemoveModifier(plModifier* mo);
|
||||
hsBool IPropagateToModifiers(plMessage* msg);
|
||||
|
||||
void ISetInterface(plObjInterface* iface);
|
||||
void IRemoveInterface(plObjInterface* iface);
|
||||
void IRemoveInterface(Int16 idx, plObjInterface* iface=nil);
|
||||
|
||||
void ISetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
public:
|
||||
|
||||
plSceneObject();
|
||||
virtual ~plSceneObject();
|
||||
|
||||
CLASSNAME_REGISTER( plSceneObject );
|
||||
GETINTERFACE_ANY( plSceneObject, plSynchedObject );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
virtual const plDrawInterface* GetDrawInterface() const { return fDrawInterface; }
|
||||
virtual const plSimulationInterface* GetSimulationInterface() const { return fSimulationInterface; }
|
||||
virtual const plCoordinateInterface* GetCoordinateInterface() const { return fCoordinateInterface; }
|
||||
virtual const plAudioInterface* GetAudioInterface() const { return fAudioInterface; }
|
||||
|
||||
int GetNumGenerics() const { return fGenerics.GetCount(); }
|
||||
const plObjInterface* GetGeneric(int i) const { return fGenerics[i]; }
|
||||
|
||||
plObjInterface* GetGenericInterface(UInt16 classIdx) const { return GetVolatileGenericInterface(classIdx); }
|
||||
|
||||
int GetNumModifiers() const { return fModifiers.GetCount(); }
|
||||
const plModifier* GetModifier(int i) const { return fModifiers[i]; }
|
||||
const plModifier* GetModifierByType(UInt16 classIdx) const;
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
virtual hsBool Eval(double secs, hsScalar del);
|
||||
|
||||
void SetSceneNode(plKey newNode);
|
||||
plKey GetSceneNode() const;
|
||||
|
||||
// Network only strange function. Do not emulate or generalize this functionality.
|
||||
virtual void SetNetGroup(plNetGroupId netGroup);
|
||||
|
||||
virtual void ReleaseData( void );
|
||||
|
||||
// Force an immediate re-sync of the transforms in the hierarchy this object belongs to,
|
||||
// as opposed to waiting for the plTransformMsg to resync.
|
||||
void FlushTransform();
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
hsMatrix44 GetLocalToWorld() const;
|
||||
hsMatrix44 GetWorldToLocal() const;
|
||||
hsMatrix44 GetLocalToParent() const;
|
||||
hsMatrix44 GetParentToLocal() const;
|
||||
|
||||
hsBool IsFinal(); // "is ready to process Loads"
|
||||
|
||||
// Export only
|
||||
virtual void SetDrawInterface(plDrawInterface* di);
|
||||
virtual void SetSimulationInterface(plSimulationInterface* si);
|
||||
virtual void SetAudioInterface(plAudioInterface* ai);
|
||||
virtual void SetCoordinateInterface(plCoordinateInterface* ci);
|
||||
|
||||
virtual void AddModifier(plModifier* mo);
|
||||
virtual void RemoveModifier(plModifier* mo);
|
||||
};
|
||||
|
||||
#endif // plSceneObject_inc
|
||||
|
@ -1,209 +1,209 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plSimulationInterface.h"
|
||||
|
||||
#include "plgDispatch.h"
|
||||
#include "plPhysical.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plWarpMsg.h"
|
||||
#include "../pnMessage/plSimulationSynchMsg.h"
|
||||
#include "../pnMessage/plSimulationMsg.h"
|
||||
#include "../pnMessage/plNodeRefMsg.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
|
||||
plSimulationInterface::plSimulationInterface() : fPhysical(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plSimulationInterface::~plSimulationInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void plSimulationInterface::ISetSceneNode(plKey newNode)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->SetSceneNode(newNode);
|
||||
}
|
||||
|
||||
void plSimulationInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on); // set the property locally
|
||||
|
||||
if (fPhysical)
|
||||
fPhysical->SetProperty(prop, on ? true : false);
|
||||
}
|
||||
|
||||
void plSimulationInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->SetTransform(l2w, w2l);
|
||||
}
|
||||
|
||||
void plSimulationInterface::ClearLinearVelocity()
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->ClearLinearVelocity();
|
||||
}
|
||||
|
||||
void plSimulationInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
// fProps is already read by plObjInterface, but we'll do it again here to
|
||||
// avoid breaking the format
|
||||
fProps.Read(s);
|
||||
// Also unnecessary
|
||||
int poop = s->ReadSwap32();
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kPhysical, 0);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
void plSimulationInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
// Legacy crap
|
||||
fProps.Write(s);
|
||||
s->WriteSwap32(0);
|
||||
|
||||
mgr->WriteKey(s, fPhysical);
|
||||
}
|
||||
|
||||
void plSimulationInterface::ReleaseData()
|
||||
{
|
||||
plPhysical *physical = fPhysical;
|
||||
|
||||
if (physical)
|
||||
{
|
||||
// To get rid of our data, we need to release our active ref and tell the SceneNode
|
||||
// to dump it. It will autodestruct after those two active refs are released, unless
|
||||
// someone else has a ref on it as well (in which case we don't want to be nuking it
|
||||
// anyway).
|
||||
if (physical->GetSceneNode())
|
||||
{
|
||||
plKey nodeKey = physical->GetSceneNode();
|
||||
|
||||
nodeKey->Release(physical->GetKey());
|
||||
}
|
||||
|
||||
GetKey()->Release(physical->GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
hsBool plSimulationInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if (intRefMsg)
|
||||
{
|
||||
switch (intRefMsg->fType)
|
||||
{
|
||||
case plIntRefMsg::kPhysical:
|
||||
if (intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove))
|
||||
{
|
||||
plPhysical* phys = plPhysical::ConvertNoRef(intRefMsg->GetRef());
|
||||
// *** for some reason, we sometimes get a null pointer here
|
||||
// *** if we do, we're just going to ignore it for now
|
||||
if (phys)
|
||||
{
|
||||
hsAssert(phys == fPhysical, "Removing Physical I don't have");
|
||||
fPhysical = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fPhysical = plPhysical::ConvertNoRef(intRefMsg->GetRef());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef(msg);
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty(kDisable, pEnableMsg->Cmd(kDisable));
|
||||
SetProperty(kPinned, pEnableMsg->Cmd(kDisable));
|
||||
return true;
|
||||
}
|
||||
|
||||
plWarpMsg* pWarpMsg = plWarpMsg::ConvertNoRef(msg);
|
||||
if (pWarpMsg)
|
||||
{
|
||||
if (fPhysical)
|
||||
{
|
||||
hsMatrix44 l2w = pWarpMsg->GetTransform();
|
||||
hsMatrix44 inv;
|
||||
l2w.GetInverse(&inv);
|
||||
SetTransform(l2w, inv);
|
||||
if (pWarpMsg->GetWarpFlags() & plWarpMsg::kZeroVelocity)
|
||||
{
|
||||
ClearLinearVelocity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plSimulationMsg* pSimMsg = plSimulationMsg::ConvertNoRef(msg);
|
||||
if (pSimMsg)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->MsgReceive(pSimMsg);
|
||||
}
|
||||
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
// Export only. Use messages for runtime.
|
||||
void plSimulationInterface::SetPhysical(plPhysical* ph)
|
||||
{
|
||||
fPhysical = ph;
|
||||
}
|
||||
|
||||
plPhysical* plSimulationInterface::GetPhysical() const
|
||||
{
|
||||
return fPhysical;
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plSimulationInterface.h"
|
||||
|
||||
#include "plgDispatch.h"
|
||||
#include "plPhysical.h"
|
||||
#include "hsBounds.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "plSceneObject.h"
|
||||
#include "../pnMessage/plEnableMsg.h"
|
||||
#include "../pnMessage/plIntRefMsg.h"
|
||||
#include "../pnMessage/plWarpMsg.h"
|
||||
#include "../pnMessage/plSimulationSynchMsg.h"
|
||||
#include "../pnMessage/plSimulationMsg.h"
|
||||
#include "../pnMessage/plNodeRefMsg.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
|
||||
plSimulationInterface::plSimulationInterface() : fPhysical(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plSimulationInterface::~plSimulationInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void plSimulationInterface::ISetSceneNode(plKey newNode)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->SetSceneNode(newNode);
|
||||
}
|
||||
|
||||
void plSimulationInterface::SetProperty(int prop, hsBool on)
|
||||
{
|
||||
plObjInterface::SetProperty(prop, on); // set the property locally
|
||||
|
||||
if (fPhysical)
|
||||
fPhysical->SetProperty(prop, on ? true : false);
|
||||
}
|
||||
|
||||
void plSimulationInterface::SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->SetTransform(l2w, w2l);
|
||||
}
|
||||
|
||||
void plSimulationInterface::ClearLinearVelocity()
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->ClearLinearVelocity();
|
||||
}
|
||||
|
||||
void plSimulationInterface::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Read(s, mgr);
|
||||
|
||||
// fProps is already read by plObjInterface, but we'll do it again here to
|
||||
// avoid breaking the format
|
||||
fProps.Read(s);
|
||||
// Also unnecessary
|
||||
int poop = s->ReadSwap32();
|
||||
|
||||
plIntRefMsg* refMsg = TRACKED_NEW plIntRefMsg(GetKey(), plRefMsg::kOnCreate, 0, plIntRefMsg::kPhysical, 0);
|
||||
mgr->ReadKeyNotifyMe(s, refMsg, plRefFlags::kActiveRef);
|
||||
}
|
||||
|
||||
void plSimulationInterface::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plObjInterface::Write(s, mgr);
|
||||
|
||||
// Legacy crap
|
||||
fProps.Write(s);
|
||||
s->WriteSwap32(0);
|
||||
|
||||
mgr->WriteKey(s, fPhysical);
|
||||
}
|
||||
|
||||
void plSimulationInterface::ReleaseData()
|
||||
{
|
||||
plPhysical *physical = fPhysical;
|
||||
|
||||
if (physical)
|
||||
{
|
||||
// To get rid of our data, we need to release our active ref and tell the SceneNode
|
||||
// to dump it. It will autodestruct after those two active refs are released, unless
|
||||
// someone else has a ref on it as well (in which case we don't want to be nuking it
|
||||
// anyway).
|
||||
if (physical->GetSceneNode())
|
||||
{
|
||||
plKey nodeKey = physical->GetSceneNode();
|
||||
|
||||
nodeKey->Release(physical->GetKey());
|
||||
}
|
||||
|
||||
GetKey()->Release(physical->GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
hsBool plSimulationInterface::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plIntRefMsg* intRefMsg = plIntRefMsg::ConvertNoRef(msg);
|
||||
if (intRefMsg)
|
||||
{
|
||||
switch (intRefMsg->fType)
|
||||
{
|
||||
case plIntRefMsg::kPhysical:
|
||||
if (intRefMsg->GetContext() & (plRefMsg::kOnDestroy|plRefMsg::kOnRemove))
|
||||
{
|
||||
plPhysical* phys = plPhysical::ConvertNoRef(intRefMsg->GetRef());
|
||||
// *** for some reason, we sometimes get a null pointer here
|
||||
// *** if we do, we're just going to ignore it for now
|
||||
if (phys)
|
||||
{
|
||||
hsAssert(phys == fPhysical, "Removing Physical I don't have");
|
||||
fPhysical = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fPhysical = plPhysical::ConvertNoRef(intRefMsg->GetRef());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
plEnableMsg* pEnableMsg = plEnableMsg::ConvertNoRef(msg);
|
||||
if (pEnableMsg)
|
||||
{
|
||||
SetProperty(kDisable, pEnableMsg->Cmd(kDisable));
|
||||
SetProperty(kPinned, pEnableMsg->Cmd(kDisable));
|
||||
return true;
|
||||
}
|
||||
|
||||
plWarpMsg* pWarpMsg = plWarpMsg::ConvertNoRef(msg);
|
||||
if (pWarpMsg)
|
||||
{
|
||||
if (fPhysical)
|
||||
{
|
||||
hsMatrix44 l2w = pWarpMsg->GetTransform();
|
||||
hsMatrix44 inv;
|
||||
l2w.GetInverse(&inv);
|
||||
SetTransform(l2w, inv);
|
||||
if (pWarpMsg->GetWarpFlags() & plWarpMsg::kZeroVelocity)
|
||||
{
|
||||
ClearLinearVelocity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plSimulationMsg* pSimMsg = plSimulationMsg::ConvertNoRef(msg);
|
||||
if (pSimMsg)
|
||||
{
|
||||
if (fPhysical)
|
||||
fPhysical->MsgReceive(pSimMsg);
|
||||
}
|
||||
|
||||
return plObjInterface::MsgReceive(msg);
|
||||
}
|
||||
|
||||
// Export only. Use messages for runtime.
|
||||
void plSimulationInterface::SetPhysical(plPhysical* ph)
|
||||
{
|
||||
fPhysical = ph;
|
||||
}
|
||||
|
||||
plPhysical* plSimulationInterface::GetPhysical() const
|
||||
{
|
||||
return fPhysical;
|
||||
}
|
||||
|
||||
|
@ -1,113 +1,113 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plSimulationInterface_inc
|
||||
#define plSimulationInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plPhysical;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
|
||||
class plSimulationInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plSimulationProperties {
|
||||
// prop 0 is always disable, , declared in plObjInterface
|
||||
kDisable = 0, // no more interaction. no interference detection
|
||||
kWeightless_DEAD, // unaffected by gravity, but not massless
|
||||
kPinned, // stop moving. keep colliding.
|
||||
kWarp_DEAD, // keep moving, no colliding (a pattern is emerging here...)
|
||||
kUpright_DEAD, // stand upright (mainly for the player)
|
||||
kPassive, // don't push new positions to sceneobject
|
||||
kRotationForces_DEAD, // rotate using forces
|
||||
kCameraAvoidObject_DEAD, // camera will try and fly around this obsticle
|
||||
kPhysAnim, // this object is animated, and the animation can apply force
|
||||
kStartInactive, // deactive this object at start time. will reactivate when hit
|
||||
kNoSynchronize, // don't synchronize this physical
|
||||
kSuppressed_DEAD, // physical still exists but is not in simulation: no forces, contact, or reports
|
||||
kNoOwnershipChange, // Don't automatically change net ownership on this physical when it is collided with
|
||||
kAvAnimPushable, // Something the avatar should react to and push against
|
||||
kNumProps
|
||||
};
|
||||
|
||||
protected:
|
||||
plPhysical* fPhysical;
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
virtual void ISetSceneNode(plKey newNode);
|
||||
|
||||
public:
|
||||
plSimulationInterface();
|
||||
~plSimulationInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plSimulationInterface );
|
||||
GETINTERFACE_ANY( plSimulationInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
// Bounds are gettable only, they are computed on the physical.
|
||||
const hsBounds3Ext GetLocalBounds();
|
||||
const hsBounds3Ext GetWorldBounds() const;
|
||||
const hsBounds3Ext GetMaxWorldBounds();
|
||||
void ClearLinearVelocity();
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
// Export only.
|
||||
void SetPhysical(plPhysical* phys);
|
||||
void ReleaseData();
|
||||
|
||||
plPhysical* GetPhysical() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // plSimulationInterface_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plSimulationInterface_inc
|
||||
#define plSimulationInterface_inc
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
class plPhysical;
|
||||
struct hsMatrix44;
|
||||
class hsBounds3Ext;
|
||||
|
||||
class plSimulationInterface : public plObjInterface
|
||||
{
|
||||
public:
|
||||
// Props inc by 1 (bit shift in bitvector).
|
||||
enum plSimulationProperties {
|
||||
// prop 0 is always disable, , declared in plObjInterface
|
||||
kDisable = 0, // no more interaction. no interference detection
|
||||
kWeightless_DEAD, // unaffected by gravity, but not massless
|
||||
kPinned, // stop moving. keep colliding.
|
||||
kWarp_DEAD, // keep moving, no colliding (a pattern is emerging here...)
|
||||
kUpright_DEAD, // stand upright (mainly for the player)
|
||||
kPassive, // don't push new positions to sceneobject
|
||||
kRotationForces_DEAD, // rotate using forces
|
||||
kCameraAvoidObject_DEAD, // camera will try and fly around this obsticle
|
||||
kPhysAnim, // this object is animated, and the animation can apply force
|
||||
kStartInactive, // deactive this object at start time. will reactivate when hit
|
||||
kNoSynchronize, // don't synchronize this physical
|
||||
kSuppressed_DEAD, // physical still exists but is not in simulation: no forces, contact, or reports
|
||||
kNoOwnershipChange, // Don't automatically change net ownership on this physical when it is collided with
|
||||
kAvAnimPushable, // Something the avatar should react to and push against
|
||||
kNumProps
|
||||
};
|
||||
|
||||
protected:
|
||||
plPhysical* fPhysical;
|
||||
|
||||
friend class plSceneObject;
|
||||
|
||||
virtual void ISetSceneNode(plKey newNode);
|
||||
|
||||
public:
|
||||
plSimulationInterface();
|
||||
~plSimulationInterface();
|
||||
|
||||
CLASSNAME_REGISTER( plSimulationInterface );
|
||||
GETINTERFACE_ANY( plSimulationInterface, plObjInterface );
|
||||
|
||||
virtual void Read(hsStream* stream, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* stream, hsResMgr* mgr);
|
||||
|
||||
void SetProperty(int prop, hsBool on);
|
||||
Int32 GetNumProperties() const { return kNumProps; }
|
||||
|
||||
// Transform settable only, if you want it get it from the coordinate interface.
|
||||
void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l);
|
||||
|
||||
// Bounds are gettable only, they are computed on the physical.
|
||||
const hsBounds3Ext GetLocalBounds();
|
||||
const hsBounds3Ext GetWorldBounds() const;
|
||||
const hsBounds3Ext GetMaxWorldBounds();
|
||||
void ClearLinearVelocity();
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
// Export only.
|
||||
void SetPhysical(plPhysical* phys);
|
||||
void ReleaseData();
|
||||
|
||||
plPhysical* GetPhysical() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // plSimulationInterface_inc
|
||||
|
@ -1,73 +1,73 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plSceneObjectCreatable_inc
|
||||
#define plSceneObjectCreatable_inc
|
||||
|
||||
#include "../pnFactory/plCreator.h"
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
REGISTER_NONCREATABLE( plObjInterface );
|
||||
|
||||
#include "plAudioInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plAudioInterface );
|
||||
|
||||
#include "plCoordinateInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plCoordinateInterface );
|
||||
|
||||
#include "plDrawInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plDrawInterface );
|
||||
|
||||
#include "plSimulationInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plSimulationInterface );
|
||||
|
||||
#include "plSceneObject.h"
|
||||
|
||||
REGISTER_CREATABLE( plSceneObject );
|
||||
|
||||
|
||||
#endif // plSceneObjectCreatable_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Additional permissions under GNU GPL version 3 section 7
|
||||
|
||||
If you modify this Program, or any covered work, by linking or
|
||||
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
|
||||
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
|
||||
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
|
||||
(or a modified version of those libraries),
|
||||
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
|
||||
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
|
||||
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
|
||||
licensors of this Program grant you additional
|
||||
permission to convey the resulting work. Corresponding Source for a
|
||||
non-source form of such a combination shall include the source code for
|
||||
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
|
||||
work.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plSceneObjectCreatable_inc
|
||||
#define plSceneObjectCreatable_inc
|
||||
|
||||
#include "../pnFactory/plCreator.h"
|
||||
|
||||
#include "plObjInterface.h"
|
||||
|
||||
REGISTER_NONCREATABLE( plObjInterface );
|
||||
|
||||
#include "plAudioInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plAudioInterface );
|
||||
|
||||
#include "plCoordinateInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plCoordinateInterface );
|
||||
|
||||
#include "plDrawInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plDrawInterface );
|
||||
|
||||
#include "plSimulationInterface.h"
|
||||
|
||||
REGISTER_CREATABLE( plSimulationInterface );
|
||||
|
||||
#include "plSceneObject.h"
|
||||
|
||||
REGISTER_CREATABLE( plSceneObject );
|
||||
|
||||
|
||||
#endif // plSceneObjectCreatable_inc
|
||||
|
Reference in New Issue
Block a user