本文整理汇总了C++中math::Vector3::normalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::normalize方法的具体用法?C++ Vector3::normalize怎么用?C++ Vector3::normalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类math::Vector3
的用法示例。
在下文中一共展示了Vector3::normalize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: launch
void GameProjectile::launch( const math::Vector3& direction )
{
setVelocity( direction.normalize() * m_launchVelocity );
m_removable = false;
m_hasHit = false;
m_age = 0;
m_movedDistance = 0;
}
示例2: normal
void TCurveBase::normal(Math::Vector3 &normal, const Math::Vector3 &point) const
{
Math::Vector2 d;
derivative(point.project_xy(), d);
normal = Math::Vector3(d.x(), d.y(), -1.0);
normal.normalize();
}
示例3:
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
//see http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4152&hilit=raytest
//for reference
void
PhysicsZone::rayCast(Math::Ray _ray, Math::Real _maxDistance, I_CollisionVisitor& _visitor)
{
Math::Vector3 offset = _ray.getDirection();
offset.normalize();
offset *= _maxDistance;
Math::Point3 endpoint = _ray.getOrigin() + offset;
//(m_pZone, _ray.getOrigin().m_array, endpoint.m_array, rayCastFilter, &rayCastQuery, rayCastPrefilter);
btVector3 tquatFrom = btVector3(_ray.getOrigin().m_x,_ray.getOrigin().m_y,_ray.getOrigin().m_z);
btVector3 tquatTo = btVector3(_ray.getOrigin().m_x,_ray.getOrigin().m_y,_ray.getOrigin().m_z);
RayResultCallback resultCallback(tquatFrom,tquatTo);
m_pZone->rayTest(tquatFrom,tquatTo,resultCallback);
}
示例4: evenData
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// set the transformation of a rigid body
void
PhysicsActor::TransformCallback(const NewtonBody* _body, const Zen::Math::Real* _matrix)
{
void* pBody = NewtonBodyGetUserData(_body);
if (pBody != NULL)
{
PhysicsActor* pShape = static_cast<PhysicsActor*>(pBody);
// Only use the transform callback if the state is active
if (pShape->m_activationState != 0)
{
Math::Matrix4 transform;
for(int x = 0; x < 16; x++)
{
transform.m_array[x] = _matrix[x];
}
TransformEventData evenData(*pShape, transform);
pShape->onTransformEvent(evenData);
}
}
#if 0
// HACK Keep the object to a constant velocity
Math::Vector3 velocity;
NewtonBodyGetVelocity(_body, velocity.m_array);
velocity.normalize();
velocity = velocity * 50;
NewtonBodySetVelocity(_body, velocity.m_array);
#endif
//std::cout << "TransformCallback()" << std::endl;
#if 0
RenderPrimitive* primitive;
// get the graphic object form the rigid body
primitive = (RenderPrimitive*) NewtonBodyGetUserData (body);
// set the transformation matrix for this rigid body
dMatrix& mat = *((dMatrix*)matrix);
primitive->SetMatrix (mat);
#endif
}