本文整理汇总了C++中Transform::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Transform::GetPosition方法的具体用法?C++ Transform::GetPosition怎么用?C++ Transform::GetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform::GetPosition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void LightComponent::Update(float dt)
{
Transform* tr = (Transform*)GetSibling(CT_Transform);
Graphics* gSys = (Graphics*) Engine::GetCore()->GetSystem(ST_Graphics);
Vector3 curPos = tr->GetPosition();
if(gSys->GetSceneConstants().rotate)
{
//have to update this shit because it says so.
tr->SetPosition(RotateAround(Vector3(0.0f, 1.0f, 0.0f), dt / 10.0f, curPos));
}
curPos = tr->GetPosition();
switch(light_type_)
{
case WickedSick::LightType::SpotLight:
if(curPos != info_.spot.position)
{
Dirty();
info_.spot.position = curPos;
}
break;
case WickedSick::LightType::PointLight:
if(curPos != info_.point.position)
{
Dirty();
info_.point.position = curPos;
}
break;
default:
break;
}
}
示例2: Add
PhysicsEntity* PhysicsWorld::Add(const PhysicsEntityDef &def)
{
Transform *t = entGetTransform(def.entity);
if(def.type == BodyType_Dynamic)
{
DynamicPhysicsEntity *d = new DynamicPhysicsEntity;
d->type = def.type;
d->ent = def.entity;
d->position = t->GetPosition();
d->velocity = def.velocity;
dynamicEntities.push_back(d);
return d;
}
else if(def.type == BodyType_Static)
{
StaticPhysicsEntity *s = new StaticPhysicsEntity;
s->type = def.type;
s->ent = def.entity;
s->position = t->GetPosition();
staticEntities.push_back(s);
return s;
} else assert(0);
return 0;
}
示例3: Update
// Updates this game manager
void GameManager::Update()
{
HandleGameState();
HandleUI();
// If there is a current arrow, let's modify its rotation
if ( _currentArrow )
{
// Get the transform and rigidbody
Transform* transform = _currentArrow->GetTransform();
Rigidbody* rigidbody = _currentArrow->GetComponent<Rigidbody>();
XMFLOAT3 currentArrowPos = transform->GetPosition();
// Set the rotation based on the velocity
XMFLOAT3 velocity = rigidbody->GetVelocity();
float yaw = -XM_PIDIV2;
float pitch = atan2( currentArrowPos.y - _lastArrowPos.y,
currentArrowPos.x - _lastArrowPos.x );
if ( velocity.x < 0.0f )
{
yaw = -yaw;
pitch = -pitch + XM_PI;
}
transform->SetRotation( pitch, yaw, 0.0f );
_lastArrowPos = currentArrowPos;
}
}
示例4: StepPhysics
void PhysicsWorld::StepPhysics()
{
for(unsigned int i = 0; i < staticEntities.size(); i++)
{
StaticPhysicsEntity *s = staticEntities[i];
Transform *t = entGetTransform(s->ent);
s->position = t->GetPosition();
}
for(unsigned int j = 0; j < dynamicEntities.size(); j++)
{
DynamicPhysicsEntity *d = dynamicEntities[j];
Transform *t = entGetTransform(d->ent);
d->position = t->GetPosition();
d->position = vecAdd(d->position, d->velocity);
t->SetPosition(d->position);
}
}
示例5: VUpdate
void VUpdate(double milliseconds) override
{
InitializeCamera();
mPixelSize = { 1.0f / mRenderer->GetWindowWidth(), 1.0f / mRenderer->GetWindowWidth() };
int offset = OFFSET_COUNT / 2;
for (int i = 0; i < OFFSET_COUNT; i++) {
mBlurH.uvOffsets[i] = { mPixelSize.x * (i - offset) , 0.0f, 0.0f, 0.0f };
mBlurV.uvOffsets[i] = { 0.0f, mPixelSize.y * (i - offset), 0.0f, 0.0f };
}
ScreenPoint mousePosition = Input::SharedInstance().mousePosition;
if (Input::SharedInstance().GetMouseButton(MOUSEBUTTON_LEFT)) {
mCamera.RotatePitch(-(mousePosition.y - mMouseY) * RADIAN * CAMERA_ROTATION_SPEED);
mCamera.RotateYaw(-(mousePosition.x - mMouseX) * RADIAN * CAMERA_ROTATION_SPEED);
}
mMouseX = mousePosition.x;
mMouseY = mousePosition.y;
vec3f position = mCamera.GetPosition();
if (Input::SharedInstance().GetKey(KEYCODE_W)) {
position += mCamera.GetForward() * CAMERA_SPEED;
mCamera.SetPosition(position);
}
if (Input::SharedInstance().GetKey(KEYCODE_A)) {
position += mCamera.GetRight() * -CAMERA_SPEED;
mCamera.SetPosition(position);
}
if (Input::SharedInstance().GetKey(KEYCODE_D)) {
position += mCamera.GetRight() * CAMERA_SPEED;
mCamera.SetPosition(position);
}
if (Input::SharedInstance().GetKey(KEYCODE_S)) {
position += mCamera.GetForward() * -CAMERA_SPEED;
mCamera.SetPosition(position);
}
if (Input::SharedInstance().GetKey(KEYCODE_1)) {
mBlurType = BLUR_TYPE_NONE;
}
if (Input::SharedInstance().GetKey(KEYCODE_2)) {
mBlurType = BLUR_TYPE_GAUSSIAN;
}
if (Input::SharedInstance().GetKey(KEYCODE_3)) {
mBlurType = BLUR_TYPE_MOTION;
}
}
示例6: SweepAndPrune
/**
* @brief Helper method to enact sweep and prune broadphase method.
*/
void PhysicsWorld::SweepAndPrune()
{
PhysicsIT end = mObjects.end();
for(PhysicsIT it = mObjects.begin(); it != end; ++it)
{
PhysicsObject *itObject = *it;
if(!itObject->IsActive())
continue;
HashString itName = itObject->GetOwner()->GetName();
Transform *itTransform = itObject->GetOwner()->GET<Transform>();
for(PhysicsIT it2 = it; it2 != end; ++it2)
{
PhysicsObject *it2Object = *it2;
if(!it2Object->IsActive())
continue;
HashString it2Name = it2Object->GetOwner()->GetName();
bool ignore = itObject->IgnoreObject(it2Name) || it2Object->IgnoreObject(itName);
if(itObject != it2Object && !ignore)
{
if((!itObject->IsStatic() || !it2Object->IsStatic()) &&
!mResolver.Find(itObject, it2Object))
{
float x1 = itTransform->GetPosition().x;
float x1Size = itObject->GetBroadSize().x;
float x2 = it2Object->GetOwner()->GET<Transform>()->GetPosition().x;
float x2Size = it2Object->GetBroadSize().x;
float xPosDiff = fabs(x1 - x2);
float xSizeTotal = x1Size + x2Size;
if(xSizeTotal > xPosDiff)
{
mResolver.AddPrelimPair(PotentialPair(itObject, it2Object));
}
else
{
break;
}
}
}
}
}
}
示例7: GetOwner
void JF::Component::SkyBox::Render()
{
// Declear)
float blendFactors[] = { 0.0f, 0.0f, 0.0f, 0.0f };
// 컴포넌트에 카메라가 없거나 메인카메라가 아니라면 패스.
Camera* pCamera = GetOwner()->GetComponent<Camera>();
if (pCamera == nullptr || Camera::g_pMainCamera != pCamera)
return;
//
Transform* pTransform = GetOwner()->GetComponent<Transform>();
if (pTransform == nullptr)
return;
// Set Layout And Topology
gRENDERER->DeviceContext()->IASetInputLayout(m_pInputLayout);
gRENDERER->DeviceContext()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
// Set VertexBuffer And IndexBuffer
UINT stride = m_Stride;
UINT offset = 0;
gRENDERER->DeviceContext()->IASetVertexBuffers(0, 1, &m_pVB, &stride, &offset);
gRENDERER->DeviceContext()->IASetIndexBuffer(m_pIB, DXGI_FORMAT_R32_UINT, 0);
// center Sky about eye in world space
XMFLOAT3 eyePos = pTransform->GetPosition();
XMMATRIX T = XMMatrixTranslation(eyePos.x, eyePos.y, eyePos.z);
XMMATRIX WVP = XMMatrixMultiply(T, pCamera->GetViewProj());
Effects::CubeMapFX->SetWorldViewProj(WVP);
Effects::CubeMapFX->SetCubeMap(m_pMainTexture->GetTexture());
ID3DX11EffectTechnique* tech = Effects::CubeMapFX->SkyTech;
D3DX11_TECHNIQUE_DESC techDesc;
tech->GetDesc(&techDesc);
for (UINT p = 0; p < techDesc.Passes; ++p)
{
tech->GetPassByIndex(p)->Apply(0, gRENDERER->DeviceContext());
gRENDERER->DeviceContext()->DrawIndexed(m_IndexCount, 0, 0);
}
// 기본 랜더상태로 복원한다.
gRENDERER->DeviceContext()->RSSetState(0);
gRENDERER->DeviceContext()->OMSetBlendState(0, blendFactors, 0xffffffff);
}
示例8: Update
PHYSICSDLL_API void OrbitComponent::Update(float dt)
{
if (targeting_)
{
Transform* tr = (Transform*)GetSibling(CT_Transform);
Vector3 forceVec = current_dir_;
Vector3 toTarget = target_ - tr->GetPosition();
float bias = toTarget.Length() / target_dist_;
forceVec += toTarget.GetNormalized() * bias;
PhysicsComponent* pComp = (PhysicsComponent*)GetSibling(CT_PhysicsComponent);
if (pComp)
{
pComp->GetRigidBody()->AddForce(forceVec);
current_dir_ = pComp->GetRigidBody()->GetState().Velocity.GetNormalized();
pComp->GetRigidBody()->GetState().Velocity = pComp->GetRigidBody()->GetState().Velocity.GetNormalized() * 2.0f;
}
}
}
示例9: ResolveCollisions
void PhysicsWorld::ResolveCollisions()
{
for(unsigned int i = 0; i < collidedObjectsCnt; i++)
{
CollisionInfo &inf = collidedObjects[i];
// Just push the contact out by the velocity so we never
// end up in a state where the two objects are still intersecting
Transform *t = entGetTransform(inf.obj->ent);
inf.obj->position = t->GetPosition();
inf.obj->position = vecSub(inf.obj->position, inf.obj->velocity);
inf.obj->velocity = vecReflect(inf.obj->velocity, inf.normal);
inf.obj->velocity = vecMul(inf.obj->velocity, vec(1, 1, 0, 0));
inf.obj->position = vecAdd(inf.obj->position, inf.obj->velocity);
t->SetPosition(inf.obj->position);
}
collidedObjectsCnt = 0;
}
示例10: OnUpdate
void EditorFloor::OnUpdate()
{
EditorGameObject::OnUpdate();
Camera *cam = SceneManager::GetActiveScene()->GetCamera();
Transform *camt = cam->gameObject->transform;
const float LineSize2 = (c_gridSize * c_tileSize) / 2.0f; // Half line length
int indexOffsetX = int(camt->GetPosition().x / c_tileSize);
int indexOffsetZ = int(camt->GetPosition().z / c_tileSize);
for (int i = 0; i <= c_gridSize; ++i)
{
SingleLineRenderer *lr = m_lineRenderers[i];
int j = i - c_gridSize / 2; // [ -GridSize/2, GridSize/2 ]
j += indexOffsetX;
Vector3 center = Vector3(c_tileSize * j, 0, c_tileSize * indexOffsetZ);
lr->SetOrigin ( Vector3(0, 0, -LineSize2) + center );
lr->SetDestiny( Vector3(0, 0, LineSize2) + center );
}
for (int i = 0; i <= c_gridSize; ++i)
{
SingleLineRenderer *lr = m_lineRenderers[i + c_gridSize + 1];
int j = i - c_gridSize / 2; // [ -GridSize/2, GridSize/2 ]
j += indexOffsetZ;
Vector3 center = Vector3(c_tileSize * indexOffsetX, 0, c_tileSize * j);
lr->SetOrigin ( Vector3(-LineSize2, 0, 0) + center );
lr->SetDestiny( Vector3( LineSize2, 0, 0) + center );
}
}
示例11: Update
void ModelComponent::Update(float dt)
{
Graphics* gSys = (Graphics*)Engine::GetCore()->GetSystem(ST_Graphics);
gSys->AddDebugModel(this);
Input* input = (Input*) Engine::GetCore()->GetSystem(ST_Input);
InputHandler* handler = input->GetHandler();
Transform* tr = (Transform*)GetSibling(CT_Transform);
PhysicsComponent* phys = (PhysicsComponent*) GetSibling(CT_PhysicsComponent);
if(handler->Check("MoveRight"))
{
tr->SetPosition(tr->GetPosition() + Vector3(1.0f,0.0f,0.0f) * dt);
phys->Reset();
}
Model* newModel = gSys->GetModel(model_);
if(newModel && base_ != newModel)
{
base_->RemoveInstance(this);
base_ = newModel;
base_->AddInstance(this);
}
}
示例12: RotateAway
void Transform::RotateAway(const Transform& target, float maxRotation)
{
this->RotateAway(target.GetPosition(), maxRotation);
}
示例13: Update
GRAPHICSDLL_API void CameraController::Update(float dt)
{
Input* input = (Input*)Engine::GetCore()->GetSystem(ST_Input);
InputHandler* handler = input->GetHandler();
if (handler->Check("Rotate"))
{
if(last_mouse_pos_ == Vector2i(-1, -1))
{
last_mouse_pos_ = handler->GetMousePos();
}
else if(handler->GetMousePos() != last_mouse_pos_)
{
Vector2i curPos = handler->GetMousePos();
Vector2 amountToRotate = (curPos - last_mouse_pos_).to_f() * dt;
CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
Vector3 lookAt = cameraComp->GetLookAt();
Transform* tr = (Transform*)GetSibling(CT_Transform);
Vector3 view = lookAt - tr->GetPosition();
view.Normalize();
view = RotateAround(Vector3(0, 1, 0), amountToRotate.x, view);
view.Normalize();
Vector3 right = Vector3(0,1,0).Cross(view);
right.Normalize();
view = RotateAround(right, amountToRotate.y, view);
lookAt = (tr->GetPosition() + view);
cameraComp->SetLookAt(lookAt);
last_mouse_pos_ = Vector2i(-1, -1);
}
}
else if(handler->Check("Move"))
{
if (last_mouse_pos_ == Vector2i(-1, -1))
{
last_mouse_pos_ = handler->GetMousePos();
}
else if (handler->GetMousePos() != last_mouse_pos_)
{
Vector2i curPos = handler->GetMousePos();
Vector2 amountToMove = (curPos - last_mouse_pos_).to_f() * dt;
CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
Vector3 lookAt = cameraComp->GetLookAt();
Transform* tr = (Transform*)GetSibling(CT_Transform);
Vector3 view = lookAt - tr->GetPosition();
view.Normalize();
Vector3 right = Vector3(0.0f,1.0f,0.0f).Cross(view);
right.Normalize();
Vector3 up = view.Cross(right);
up.Normalize();
Vector3 pos = tr->GetPosition();
amountToMove *= 5.0f;
pos += right * -amountToMove.x;
pos += up * amountToMove.y;
lookAt += right * -amountToMove.x;
lookAt += up * amountToMove.y;
tr->SetPosition(pos);
cameraComp->SetLookAt(lookAt);
last_mouse_pos_ = Vector2i(-1, -1);
}
}
else if (handler->Check("ZoomIn"))
{
CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
Vector3 lookAt = cameraComp->GetLookAt();
Transform* tr = (Transform*)GetSibling(CT_Transform);
Vector3 view = lookAt - tr->GetPosition();
view.Normalize();
view *= dt;
tr->SetPosition(tr->GetPosition() += view );
cameraComp->SetLookAt(lookAt += view );
}
else if (handler->Check("ZoomOut"))
{
CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
Vector3 lookAt = cameraComp->GetLookAt();
Transform* tr = (Transform*)GetSibling(CT_Transform);
Vector3 view = lookAt - tr->GetPosition();
view.Normalize();
view *= dt;
tr->SetPosition(tr->GetPosition() -= view);
cameraComp->SetLookAt(lookAt -= view);
}
else if (handler->GetScrollPos())
{
CameraComponent* cameraComp = (CameraComponent*)GetSibling(CT_CameraComponent);
Vector3 lookAt = cameraComp->GetLookAt();
Transform* tr = (Transform*)GetSibling(CT_Transform);
//.........这里部分代码省略.........
示例14: LookAt
void Transform::LookAt(const Transform &target, const Vector3 &worldUp)
{
LookAt(target.GetPosition(Space::WORLD), worldUp);
}