本文整理汇总了C++中ogre::Vector3::isZeroLength方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::isZeroLength方法的具体用法?C++ Vector3::isZeroLength怎么用?C++ Vector3::isZeroLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Vector3
的用法示例。
在下文中一共展示了Vector3::isZeroLength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDirection
void Arrow::setDirection( const Ogre::Vector3& direction )
{
if( !direction.isZeroLength() )
{
setOrientation( Ogre::Vector3::NEGATIVE_UNIT_Z.getRotationTo( direction ));
}
}
示例2: translate
void SmallShip::translate(Ogre::Vector3 _up, Ogre::Vector3 _right, Ogre::Vector3 _forward)
{
if(!_up.isZeroLength()){
up = _up;
drift_Direction += _up * accel_Rate;
}
if(!_right.isZeroLength()){
right = _right;
drift_Direction += _right * accel_Rate;
}
if(!_forward.isZeroLength()){
direction = _forward;
drift_Direction += _forward * accel_Rate;
}
m_pNode->needUpdate();
}
示例3: alignAnimalToCamera
void AnimalThirdPersonControler::alignAnimalToCamera(double i_timeSinceLastFrame)
{
if (!(m_pAnimal != nullptr && m_pCamera != nullptr))
return;
// Find new orientation of avatar
Ogre::Vector3 camY = m_pCamera->getDirection();
Ogre::Vector3 aniX = m_pAnimal->m_pNode->getOrientation().xAxis();
Ogre::Vector3 aniY = m_pAnimal->m_pNode->getOrientation().yAxis();
Ogre::Vector3 newAniX = camY.dotProduct(aniX) * aniX + camY.dotProduct(aniY) * aniY;
if (newAniX.isZeroLength())
return;
newAniX.normalise();
m_pAnimal->turn(newAniX, i_timeSinceLastFrame);
}
示例4: Response
void CollisionResponse::Response(IPhysical* object, Ogre::Vector3 point, Ogre::Vector3 normal)
{
Ogre::Vector3 vretreat = object->GetPosition()-Owner->GetPosition();
vretreat.normalise();
object->SetForces(Ogre::Vector3::ZERO);
object->AddCollisionImpulse(point, (normal+vretreat)*Owner->GetMass()/object->GetMass(), &Owner->GetDescriptor()); //*object->GetMass()/10
Ogre::Vector3 linvel = object->GetLinVelocity();
Ogre::Vector3 throttle = object->GetThrottle();
if (!throttle.isZeroLength())
object->SetThrottle(-throttle);
else
object->AddForce(point, (normal+vretreat)*Owner->GetMass()/object->GetMass()); //*object->GetMass()/2
object->SetCollided(true); //Descriptor->Collided=true;
}
示例5: Step
void AIInConeAttackStrategy::Step(unsigned timeMs)
{
IScenable *scen = Parent->GetScenable();
if (TargetID<0)
{
return;
}
if (TargetID==0)
{
if (Owner)
{
TargetID = Owner->SelectTargetID();
}
if (TargetID<=0)
{
TargetID=-1;
IEquipped *eq = Parent->GetEquipped();
eq->SetTargetPosition(Ogre::Vector3::ZERO);
eq->SetShooting(false);
return;
}
}
IAAObject *obj = CommonDeclarations::GetIDObject(TargetID);
if (NULL==obj)
{
TargetID=0;
return;
}
IScenable* Target;
Target = obj->GetScenable();
if (NULL==Target/* || phys->IsCollided()*/)
return;
if(RotationUnit.mRotating)
{
RotationUnit.Step();
if(RotationUnit.mRotating) // Process timed rotation
{
Ogre::Quaternion delta = RotationUnit.Slerp();
scen->SetOrientation(delta);
}
}// else
{
int actual_rotation_speed = RotationSpeed;
IPhysical *phys = Parent->GetPhysical();
AICommander *commander = Owner->GetCommander();
Ogre::Vector3 src = Ogre::Vector3::ZERO;
if (commander)
{
IAAObject *obj = commander->GetParent();
if (obj)
{
IScenable *scen = obj->GetScenable();
if (scen)
{
src = scen->GetOrientation()*Ogre::Vector3::NEGATIVE_UNIT_Z;
}
}
} else
{
src = -phys->GetForwardDirection(); //OurOrientation * Ogre::Vector3::NEGATIVE_UNIT_Z;
}
Ogre::Vector3 direction = Target->GetPosition()-scen->GetPosition();
direction.normalise();
Ogre::Real cs = src.dotProduct(direction);
if (src.isZeroLength() || cs>=AngleCosinusModule)
{
actual_rotation_speed = actual_rotation_speed/2;
/*char log[100];
sprintf(log,"in cone %f %f %f\n",direction.x, direction.y, direction.z);
Debugging::Log("icas",log);*/
} else
{
direction = src;
/*char log[100];
sprintf(log,"not in cone %f %f %f\n",direction.x, direction.y, direction.z);
Debugging::Log("icas",log);*/
}
Ogre::Vector3 up =CommonDeclarations::GetUpVector();
Ogre::Quaternion OurOrientation = scen->GetOrientation();
Vector3 xVec = up.crossProduct(direction);
xVec.normalise();
Vector3 yVec = direction.crossProduct(xVec);
yVec.normalise();
Quaternion unitZToTarget = Quaternion(xVec, yVec, direction);
Quaternion targetOrientation = Quaternion(-unitZToTarget.y, -unitZToTarget.z, unitZToTarget.w, unitZToTarget.x);
RotationUnit.StartRotation(OurOrientation, targetOrientation, actual_rotation_speed);
}
std::pair<bool, Ogre::Real> intersection_res;
//.........这里部分代码省略.........
示例6: appFrameStarted
//.........这里部分代码省略.........
// Check for object type.
if (std::string::npos != s.rfind("box"))
{
outputString += " box";
type = OBJECT_TYPE_BOX;
makeObject = true;
}
else if (std::string::npos != s.rfind("sphere"))
{
outputString += " sphere";
type = OBJECT_TYPE_SPHERE;
makeObject = true;
}
else if (std::string::npos != s.rfind("wall"))
{
outputString += " wall";
type = OBJECT_TYPE_WALL;
makeObject = true;
}
else if (std::string::npos != s.rfind("tower"))
{
outputString += " tower";
type = OBJECT_TYPE_TOWER;
makeObject = true;
}
else if (std::string::npos != s.rfind("character"))
{
outputString += " character";
type = OBJECT_TYPE_RAGDOLL;
makeObject = true;
}
if (makeObject)
{
voce::synthesize(outputString);
createObject(material, type);
}
}
// Update the grasping spring line.
if (mPhysicalCamera->isGrasping())
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (!pickingSphere->isVisible())
{
pickingSphere->setVisible(true);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (!springLine->isVisible())
{
springLine->setVisible(true);
}
opal::Point3r desiredPos =
mPhysicalCamera->getGraspGlobalPos();
Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]);
opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos();
Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]);
pickingSphere->getParentSceneNode()->setPosition(point1);
Ogre::Vector3 lineVec = point0 - point1;
if (!lineVec.isZeroLength())
{
Ogre::SceneNode* springLineNode =
springLine->getParentSceneNode();
springLineNode->setPosition(0.5 * (point0 + point1));
springLineNode->setDirection(lineVec);
springLineNode->setScale(0.1, 0.1, lineVec.length());
}
else
{
springLine->setVisible(false);
}
}
else
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (pickingSphere->isVisible())
{
pickingSphere->setVisible(false);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (springLine->isVisible())
{
springLine->setVisible(false);
}
}
// Return true to continue looping.
return keepLooping;
}
示例7: appFrameStarted
bool PlaypenApp::appFrameStarted(opal::real dt)
{
// Do per-frame application-specific things here.
// Update the grasping spring line.
if (mPhysicalCamera->isGrasping())
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (!pickingSphere->isVisible())
{
pickingSphere->setVisible(true);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (!springLine->isVisible())
{
springLine->setVisible(true);
}
opal::Point3r desiredPos =
mPhysicalCamera->getGraspGlobalPos();
Ogre::Vector3 point0(desiredPos[0], desiredPos[1], desiredPos[2]);
opal::Point3r attachPos = mPhysicalCamera->getAttachGlobalPos();
Ogre::Vector3 point1(attachPos[0], attachPos[1], attachPos[2]);
pickingSphere->getParentSceneNode()->setPosition(point1);
Ogre::Vector3 lineVec = point0 - point1;
if (!lineVec.isZeroLength())
{
Ogre::SceneNode* springLineNode =
springLine->getParentSceneNode();
springLineNode->setPosition(0.5 * (point0 + point1));
springLineNode->setDirection(lineVec, Ogre::Node::TS_WORLD);
springLineNode->setScale(0.1, 0.1, lineVec.length());
}
else
{
springLine->setVisible(false);
}
}
else
{
Ogre::Entity* pickingSphere =
mSceneMgr->getEntity("pickingSphere");
if (pickingSphere->isVisible())
{
pickingSphere->setVisible(false);
}
Ogre::Entity* springLine =
mSceneMgr->getEntity("springLine");
if (springLine->isVisible())
{
springLine->setVisible(false);
}
}
// Return true to continue looping.
return true;
}
示例8: Frame
void AACamera::Frame(unsigned timeMs)
{
//Ogre::Quaternion q = Ogre::Quaternion::IDENTITY;
/*if(CameraAdditionalRotation.mRotating)
{
CameraAdditionalRotation.Step();
if(CameraAdditionalRotation.mRotating)
{
RelativeOrientation = CameraAdditionalRotation.Slerp();
q = RelativeOrientation;
}
}*/
Ogre::Vector3 accel = -PlayersObject->GetPhysical()->GetThrottle();
accel.normalise();
/*char log[100];
sprintf(log,"1 %f %f %f\n", accel.x, accel.y, accel.z);
Debugging::Log("cam",log);*/
bool accel_is_zero = accel.isZeroLength();
if (!accel_is_zero)
{
if (accel.x==0) {
AdditionalRelativePosition.x*=RelativeShiftCoeffDump;
}
if (accel.y==0) {
AdditionalRelativePosition.y*=RelativeShiftCoeffDump;
}
if (accel.z==0) {
AdditionalRelativePosition.z*=RelativeShiftCoeffDump;
}
Ogre::Vector3 shift_size;
shift_size.x = abs(AdditionalRelativePosition.x);
shift_size.y = abs(AdditionalRelativePosition.y);
shift_size.z = abs(AdditionalRelativePosition.z);
if (shift_size.x>=RelativeShiftMax) {
accel.x=0;
} else
if (shift_size.x>RelativeShiftMax-RelativeShiftSlowerBuffer)
{
accel.x/=2;
}
if (abs(AdditionalRelativePosition.y)>=RelativeShiftMax) {
accel.y=0;
} else
if (shift_size.y>RelativeShiftMax-RelativeShiftSlowerBuffer)
{
accel.y/=2;
}
if (abs(AdditionalRelativePosition.z)>=RelativeShiftMax) {
accel.z=0;
} else
if (shift_size.z>RelativeShiftMax-RelativeShiftSlowerBuffer)
{
accel.z/=2;
}
if (!accel.isZeroLength())
AdditionalRelativePosition+=accel*RelativeShiftCoeffGrow;
}
else
if (accel_is_zero && !AdditionalRelativePosition.isZeroLength())
AdditionalRelativePosition*=RelativeShiftCoeffDump;
//Node->setPosition(Position+AdditionalRelativePosition);
HandleCameraCollision();
UpdatePosition();
}
示例9: Step
void AILookStrategy::Step(unsigned timeMs)
{
IPhysical *phys = Parent->GetPhysical();
IScenable *scen = Parent->GetScenable();
if(RotationUnit.mRotating)
{
RotationUnit.Step();
if(RotationUnit.mRotating) // Process timed rotation
{
Ogre::Quaternion delta = RotationUnit.Slerp();
scen->SetOrientation(delta);
}
} else
{
Ogre::Quaternion OurOrientation = scen->GetOrientation();
//Ogre::Vector3 src = OurOrientation * Ogre::Vector3::NEGATIVE_UNIT_Z;
Ogre::Vector3 direction = Ogre::Vector3::ZERO;
switch(LookType) {
case LT_FORWARD:
direction = -phys->GetForwardDirection();
break;
case LT_DIRECTION:
direction = Direction;
break;
case LT_OBJECT:
{
if (TargetID<0)
{
assert(false);
}
if (TargetID==0)
{
if (Owner)
{
TargetID = Owner->SelectTargetID();
}
}
IAAObject *obj = CommonDeclarations::GetIDObject(TargetID);
//assert(obj);
if (obj)
direction = obj->GetPosition()-scen->GetPosition();
break;
}
};
if (!direction.isZeroLength())
{
Vector3 xVec = Ogre::Vector3::UNIT_Y.crossProduct(direction);
xVec.normalise();
Vector3 yVec = direction.crossProduct(xVec);
yVec.normalise();
Quaternion unitZToTarget = Quaternion(xVec, yVec, direction);
Quaternion targetOrientation = Quaternion(-unitZToTarget.y, -unitZToTarget.z, unitZToTarget.w, unitZToTarget.x);
RotationUnit.StartRotation(OurOrientation, targetOrientation);
}
}
}