///////////////////////////////////////////////////// ///////////////////////////////////////////////////// // // PositionSound // ///////////////////////////////////////////////////// ///////////////////////////////////////////////////// #include "CKALL.h" CKERROR CreatePositionSoundBehaviorProto(CKBehaviorPrototype **pproto); int DoPositionSound(const CKBehaviorContext& behcontext); CKObjectDeclaration *FillBehaviorPositionSoundDecl() { CKObjectDeclaration *od = CreateCKObjectDeclaration("Position Sound"); od->SetDescription("Attaches a sound to an object."); /* rem: In: triggers the process
Out: is activated when the process is completed.

Object: object to which the sound will be attached (NULL = world).
Position: position of the sound, in the referential of the attached object, or in the world.
Direction: direction of the sound, in the referential of the attached object, or in the world.
Relative To Listener: specify if you want the sound to be positionned relative to the listener (when the listener will move the sound will move with it).

If the object is different from NULL, the sound will follow it.

*/ od->SetCategory("Sounds/3D Properties"); od->SetType(CKDLL_BEHAVIORPROTOTYPE); od->SetGuid(CKGUID(0x4ba42a5b,0x3ca030dd)); od->SetAuthorGuid(VIRTOOLS_GUID); od->SetAuthorName("Virtools"); od->SetVersion(0x00010000); od->SetCreationFunction(CreatePositionSoundBehaviorProto); od->SetCompatibleClassId(CKCID_WAVESOUND); od->NeedManager(SOUND_MANAGER_GUID); return od; } CKERROR CreatePositionSoundBehaviorProto(CKBehaviorPrototype **pproto) { CKBehaviorPrototype *proto = CreateCKBehaviorPrototype("Position Sound"); if(!proto) return CKERR_OUTOFMEMORY; proto->DeclareInput("In"); proto->DeclareOutput("Out"); proto->DeclareInParameter("Object",CKPGUID_3DENTITY); proto->DeclareInParameter("Position",CKPGUID_VECTOR,"0,0,0"); proto->DeclareInParameter("Direction",CKPGUID_VECTOR,"0,0,1"); // proto->DeclareInParameter("Relative To Listener",CKPGUID_BOOL,"FALSE"); proto->SetFlags(CK_BEHAVIORPROTOTYPE_NORMAL); proto->SetFunction(DoPositionSound); proto->SetBehaviorFlags(CKBEHAVIOR_TARGETABLE); *pproto = proto; return CK_OK; } int DoPositionSound(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; beh->ActivateInput(0,FALSE); beh->ActivateOutput(0); CKWaveSound* wave=(CKWaveSound*)beh->GetTarget(); if( !wave) return CKBR_OK; CK3dEntity* object = (CK3dEntity*)beh->GetInputParameterObject(0); VxVector pos(0,0,0),dir(0,0,1); // Position beh->GetInputParameterValue(1,&pos); // Orientation beh->GetInputParameterValue(2,&dir); // The core wave->PositionSound(object,&pos,&dir); /* BOOL headr = FALSE; beh->GetInputParameterValue(3,&headr); wave->SetHeadRelative(headr); */ return CKBR_OK; }