本文整理汇总了C++中VisBaseEntity_cl::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ VisBaseEntity_cl::GetPosition方法的具体用法?C++ VisBaseEntity_cl::GetPosition怎么用?C++ VisBaseEntity_cl::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisBaseEntity_cl
的用法示例。
在下文中一共展示了VisBaseEntity_cl::GetPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PerFrameUpdate
void VLineFollowerComponent::PerFrameUpdate()
{
VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner();
if (!pOwner || !m_pFollowPath)
return;
hkvVec3 vPos;
hkvVec3 vDir;
m_pFollowPath->EvalPoint(m_fCurrentPathPos, vPos, &vDir);
vPos.z = pOwner->GetPosition().z;
float fDiff = Vision::GetTimer()->GetTimeDifference();
if((vPos - pOwner->GetPosition()).getLength() < Path_TriggerDistance)
{
if(fDiff>0.1)
m_fCurrentPathPos += (3/Path_NumberSteps);
else
m_fCurrentPathPos += (1/Path_NumberSteps);
if (m_fCurrentPathPos>1.f)
{
if (m_pFollowPath->IsClosed())
m_fCurrentPathPos = hkvMath::mod (m_fCurrentPathPos,1.f);
else
m_fCurrentPathPos = 1.f;
}
m_pFollowPath->EvalPoint(m_fCurrentPathPos, vPos, &vDir);
vPos.z = pOwner->GetPosition().z;
if(Vision::Editor.IsAnimatingOrPlaying() && Debug_DisplayBoxes)
Vision::Game.DrawCube(vPos,80.f);
}
else
{
if(Vision::Editor.IsAnimatingOrPlaying() && Debug_DisplayBoxes)
Vision::Game.DrawCube(vPos,80.f,V_RGBA_YELLOW);
}
// Orient the entity in the right direction
hkvMat3 mRot(hkvNoInitialization);
mRot.setLookInDirectionMatrix (vPos - pOwner->GetPosition());
mRot = mRot.multiply (m_mDeltaRotation);
pOwner->SetRotationMatrix(mRot);
// The animation we are playing should have motion delta which will
// move towards the target position. No animation, well lets add at
// least some motion delta
if (!m_bPlayingAnim)
{
pOwner->SetMotionDeltaLocalSpace( hkvVec3(1.f,0.f,0.f)*(Model_CapsuleRadius*fDiff) );
}
}
示例2: OnAnimationEvent
void VAnimationEventEffectTrigger::OnAnimationEvent()
{
// Get the active event trigger info
VEventEffectTriggerInfo_t* info = (VEventEffectTriggerInfo_t*) m_pActiveTriggerInfo;
// Check if effect file is specified
if (info == NULL || info->m_spEffectFile == NULL)
return;
// Get bone translation and orientation (if bone ID is 0 no bone has been specified)
VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner;
hkvVec3 vPos = pEntity->GetPosition() + info->m_vPositionOffset;
hkvVec3 vOri = pEntity->GetOrientation() + info->m_vOrientationOffset;
if (info->m_iAttachToBone != -1)
{
hkvQuat vRot;
pEntity->GetBoneCurrentWorldSpaceTransformation(info->m_iAttachToBone, vPos, vRot);
// Add position and orientation offset
vPos = PositionOffset + vPos;
hkvQuat vOffsetRot; vOffsetRot.setFromEulerAngles (vOri.data[2], vOri.data[1], vOri.data[0]);
vRot = vRot.multiplyReverse (vOffsetRot);
vRot.getAsEulerAngles (vOri.z, vOri.y, vOri.x);
}
// Trigger effect
VisParticleEffect_cl* pEffectInstance = info->m_spEffectFile->CreateParticleEffectInstance(vPos, vOri);
pEffectInstance->SetRemoveWhenFinished(true);
}
示例3: OnAnimationEvent
void VFmodAnimationEventSoundTrigger::OnAnimationEvent()
{
// Get the active event trigger info
VFmodEventSoundTriggerInfo_t* info = (VFmodEventSoundTriggerInfo_t*) m_pActiveTriggerInfo;
// Check if effect file is specified
if (info == NULL || info->m_spSoundResource == NULL)
return;
// Get entity position
VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner;
hkvVec3 vPos = pEntity->GetPosition();
// Trigger sound effect
VFmodSoundObject* pSound = info->m_spSoundResource->CreateInstance(vPos, VFMOD_FLAG_NONE);
if(pSound)
pSound->Play();
}
示例4: LoadMap
// ---------------------------------------------------------------------------------
// Method: LoadMap
// Notes:
// ---------------------------------------------------------------------------------
void LoadMap(int iMap, BOOL bLoadEntities)
{
g_spMap = NULL;
// load map
strcpy(g_pszCurrentMap, g_pszMaps[iMap]);
g_iCurrentMap = iMap;
spApp->LoadScene(g_pszCurrentMap);
hkvVec3 vStart;
// try to find the Player_Start placeholder entity
VisBaseEntity_cl* pStart = Vision::Game.SearchEntity("Player_Start");
if (pStart)
vStart = pStart->GetPosition();
else
vStart.set (-350.f, 200.f, 200.f);
if ( bLoadEntities )
{
// create player entity (in case the entities are not loaded from the savegame)
Vision::Game.CreateEntity("SerializePlayer_cl", vStart);
// create 3 spotlight entities
hkvVec3 Placement;
Placement.set ( -200, 500, 200 );
Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement );
Placement.set ( -300, 0, 100 );
Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement );
Placement.set ( 40, -600, 100 );
Vision::Game.CreateEntity("SerializeSpotlight_cl", Placement );
}
// create some screen masks
int w = Vision::Video.GetXRes();
int h = Vision::Video.GetYRes();
// set up "current map" screen mask
g_spMap = new VisScreenMask_cl(g_pszMapIcons[iMap], TEXTURE_LOADING_FLAGS);
g_spMap->SetPos( w - 48.f - 8.f, (float)h - 48.f - 8.f );
g_spMap->SetTransparency(VIS_TRANSP_ALPHA);
g_spMap->SetColor(g_iOverlayColor);
g_spMap->SetVisible(TRUE);
}
示例5: InitPhysics
void VLineFollowerComponent::InitPhysics(float fPathPos)
{
VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner();
if (!pOwner)
return;
hkvVec3 vPos;
hkvVec3 vDir;
hkvAlignedBBox bbox;
m_fCurrentPathPos = fPathPos;
if(m_pFollowPath)
m_pFollowPath->EvalPoint(fPathPos, vPos, &vDir);
else
vPos = pOwner->GetPosition();
// to determine correct height on the ground, perform a ray-cast:
if (Vision::GetApplication()->GetPhysicsModule()!=NULL && Model_CapsuleHeight>0)
{
hkvVec3 vRayStart(vPos.x,vPos.y,vPos.z+Model_CapsuleHeight);
hkvVec3 vRayEnd(vPos.x,vPos.y,vPos.z-Model_CapsuleHeight);
VisPhysicsHit_t hitPoint;
if (Vision::GetApplication()->GetPhysicsModule()->Raycast(vRayStart, vRayEnd, hitPoint)) // hit?
{
vPos.z = hitPoint.vImpactPoint.z + 5.f*Vision::World.GetGlobalUnitScaling(); // add some margin
}
}
VDynamicMesh *pMesh = pOwner->GetMesh();
if (pMesh)
{
pMesh->GetCollisionBoundingBox(bbox);
vPos.z -= bbox.m_vMin.z;
// Use model size if not set
if (Model_CapsuleRadius<=0.f) Model_CapsuleRadius = hkvMath::Min( bbox.getSizeX(), bbox.getSizeY() )/2.f;
if (Model_CapsuleHeight<=0.f) Model_CapsuleHeight = bbox.getSizeZ();
} else
{
// No model - set some sane values if not set
if (Model_CapsuleRadius<=0.f) Model_CapsuleRadius = 40.f;
if (Model_CapsuleHeight<=0.f) Model_CapsuleHeight = 90.f;
}
// Create the physics object
pOwner->SetPosition(vPos);
if (!m_pPhys)
{
m_pPhys = new vHavokCharacterController();
m_pPhys->Capsule_Radius = Model_CapsuleRadius;
float h = Model_CapsuleHeight * 0.5f;
float fPivot = Model_GroundOffset;
m_pPhys->Character_Top.set(0, 0, h - fPivot);
m_pPhys->Character_Bottom.set(0, 0, -h - fPivot);
pOwner->AddComponent(m_pPhys);
}
// Update position
m_pPhys->SetPosition(vPos);
// Enable debug rendering
m_pPhys->SetDebugRendering(Debug_RenderMesh);
m_pPhys->SetDebugColor(V_RGBA_RED);
}
示例6: OnHandleCallback
void VLineFollowerComponent::OnHandleCallback(IVisCallbackDataObject_cl *pData)
{
VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner();
if (!pOwner)
return;
// Update callback
if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneFinished)
{
// Update
PerFrameUpdate();
// Debug Render
if (!Vision::Editor.IsAnimatingOrPlaying())
{
if (Debug_RenderMesh)
{
hkvVec3 pos = pOwner->GetPosition();
hkvMat3 rotMat;
// Setup all coordinates of a single spline
hkvVec3 p1(0,0,-Model_CapsuleHeight*0.5f-Model_CapsuleRadius);
hkvVec3 p2(Model_CapsuleRadius*0.7f,0,-Model_CapsuleHeight*0.5f-Model_CapsuleRadius*0.7f);
hkvVec3 p3(Model_CapsuleRadius,0,-Model_CapsuleHeight*0.5f);
hkvVec3 p4(Model_CapsuleRadius,0,Model_CapsuleHeight*0.5f);
hkvVec3 p5(Model_CapsuleRadius*0.7f,0,Model_CapsuleHeight*0.5f+Model_CapsuleRadius*0.7f);
hkvVec3 p6(0,0,Model_CapsuleHeight*0.5f+Model_CapsuleRadius);
rotMat.setRotationMatrix (hkvVec3(0,0,1), 60.f);
pos.z -= Model_GroundOffset;
// Draw and rotate the spline (6 times)
int i;
for(i=0;i<6;i++)
{
Vision::Game.DrawSingleLine(pos-p1, pos-p2,V_RGBA_RED);
Vision::Game.DrawSingleLine(pos-p2, pos-p3,V_RGBA_RED);
Vision::Game.DrawSingleLine(pos-p3, pos-p4,V_RGBA_RED);
Vision::Game.DrawSingleLine(pos-p4, pos-p5,V_RGBA_RED);
Vision::Game.DrawSingleLine(pos-p5, pos-p6,V_RGBA_RED);
p1 = rotMat.transformDirection(p1);
p2 = rotMat.transformDirection(p2);
p3 = rotMat.transformDirection(p3);
p4 = rotMat.transformDirection(p4);
p5 = rotMat.transformDirection(p5);
p6 = rotMat.transformDirection(p6);
}
}
}
}
// Initialization
if (pData->m_pSender == &Vision::Callbacks.OnAfterSceneLoaded)
{
// Find the path to follow
if (m_pFollowPath==NULL && Path_Key[0])
{
m_pFollowPath = Vision::Game.SearchPath(Path_Key);
InitPhysics(hkvMath::mod (Path_InitialOffset, 1.f));
}
return;
}
// Event handling
if (pData->m_pSender==&PathCameraAction::OnTriggerEvent)
{
TiXmlElement *pEventNode = ((VPathEventCallbackDataObject *)pData)->m_pEventNode;
const char *szEntityKey = pEventNode->Attribute(ENTITY_PROPERTY);
if (szEntityKey && pOwner->GetEntityKey() && !_stricmp(szEntityKey, pOwner->GetEntityKey()))
{
const char *szAction = pEventNode->Attribute(ACTION_PROPERTY);
if(szAction && !_stricmp(szAction,RESET_ACTION))
{
InitPhysics(hkvMath::mod (Path_InitialOffset, 1.f));
}
else if(szAction && !_stricmp(szAction,SET_ACTION))
{
const char *szPos = pEventNode->Attribute(TO_PROPERTY);
float fPos = Path_InitialOffset;
if(szPos) fPos = hkvMath::mod ((float)atof(szPos),1.f);
InitPhysics(fPos);
}
}
return;
}
}