当前位置: 首页>>代码示例>>C++>>正文


C++ Vector3::dotProduct方法代码示例

本文整理汇总了C++中ogre::Vector3::dotProduct方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::dotProduct方法的具体用法?C++ Vector3::dotProduct怎么用?C++ Vector3::dotProduct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ogre::Vector3的用法示例。


在下文中一共展示了Vector3::dotProduct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: T

	Ogre::Vector3 plane_segment_intersection(const Ogre::Vector3& P1, const Ogre::Vector3& P2, const Ogre::Vector3& P3, const Ogre::Vector3& L1, const Ogre::Vector3& L2)
	{
		Ogre::Vector3 T(P2 - P1);
		Ogre::Vector3 N = T.crossProduct(P3 - P1);
		Ogre::Vector3 result = L1 + (N.dotProduct(P1 - L1) / N.dotProduct(L2 - L1)) * (L2 - L1);
		return result;
	}
开发者ID:alexeyknyshev,项目名称:kiog,代码行数:7,代码来源:mkSpaceSheet.cpp

示例2: setPropertiesFromCamera

void FPSViewController::setPropertiesFromCamera( Ogre::Camera* source_camera )
{
  Ogre::Quaternion quat = source_camera->getOrientation() * ROBOT_TO_CAMERA_ROTATION.Inverse();
  float yaw = quat.getRoll( false ).valueRadians(); // OGRE camera frame looks along -Z, so they call rotation around Z "roll".
  float pitch = quat.getYaw( false ).valueRadians(); // OGRE camera frame has +Y as "up", so they call rotation around Y "yaw".

  Ogre::Vector3 direction = quat * Ogre::Vector3::NEGATIVE_UNIT_Z;

  if ( direction.dotProduct( Ogre::Vector3::NEGATIVE_UNIT_Z ) < 0 )
  {
    if ( pitch > Ogre::Math::HALF_PI )
    {
      pitch -= Ogre::Math::PI;
    }
    else if ( pitch < -Ogre::Math::HALF_PI )
    {
      pitch += Ogre::Math::PI;
    }

    yaw = -yaw;

    if ( direction.dotProduct( Ogre::Vector3::UNIT_X ) < 0 )
    {
      yaw -= Ogre::Math::PI;
    }
    else
    {
      yaw += Ogre::Math::PI;
    }
  }

  pitch_property_->setFloat( pitch );
  yaw_property_->setFloat( mapAngleTo0_2Pi( yaw ));
  position_property_->setVector( source_camera->getPosition() );
}
开发者ID:jkammerl,项目名称:rviz,代码行数:35,代码来源:fps_view_controller.cpp

示例3: intersectSomeYzPlane

bool InteractiveMarkerControl::intersectSomeYzPlane( const Ogre::Ray& mouse_ray,
                                                     const Ogre::Vector3& point_on_plane,
                                                     const Ogre::Quaternion& plane_orientation,
                                                     Ogre::Vector3& intersection_3d,
                                                     Ogre::Vector2& intersection_2d,
                                                     float& ray_t )
{
  Ogre::Vector3 normal = plane_orientation * control_orientation_.xAxis();
  Ogre::Vector3 axis_1 = plane_orientation * control_orientation_.yAxis();
  Ogre::Vector3 axis_2 = plane_orientation * control_orientation_.zAxis();

  Ogre::Plane plane(normal, point_on_plane);

  Ogre::Vector2 origin_2d(point_on_plane.dotProduct(axis_1), point_on_plane.dotProduct(axis_2));

  std::pair<bool, Ogre::Real> intersection = mouse_ray.intersects(plane);
  if (intersection.first)
  {
    intersection_3d = mouse_ray.getPoint(intersection.second);
    intersection_2d = Ogre::Vector2(intersection_3d.dotProduct(axis_1), intersection_3d.dotProduct(axis_2));
    intersection_2d -= origin_2d;

    ray_t = intersection.second;
    return true;
  }

  ray_t = 0;
  return false;
}
开发者ID:F34140r,项目名称:visualization-userfriendly,代码行数:29,代码来源:interactive_marker_control.cpp

示例4: PerformRaySphereCollisionTest

bool PhysicsEngine::PerformRaySphereCollisionTest(const Ogre::FrameEvent &fe, PhysicsEntity *ray, PhysicsEntity *sphere)
{
	Ogre::Vector3 rayDirection = ray->getDerivedOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z;
	Ogre::Vector3 rayPosition = ray->getDerivedPosition();

	float ab2 = rayDirection.dotProduct(rayDirection);

	Ogre::Vector3 p = sphere->getDerivedPosition();
	Ogre::Vector3 ap = p - rayPosition;
	float ap_dot_dir = ap.dotProduct(rayDirection);
	float t = ap_dot_dir / ab2;

	if (t < 0.0f) t = 0.0f;

	Ogre::Vector3 q = rayPosition + rayDirection * t;

	Ogre::Vector3 pq = q - p;

	float radius = sphere->GetRadius();
	float r2 = radius * radius;

	if (pq.dotProduct(pq) < r2)
	{
		ray->Collide(fe, sphere);
		if (ray->GetBodyType() == ENTITY_BODY_RAY)
		{
			// sphere only detects collisions with physical rays
			sphere->Collide(fe, ray);
		}

		return true;
	}

	return false;
}
开发者ID:Elephly,项目名称:d00m3d,代码行数:35,代码来源:physics_engine.cpp

示例5: setOrientation

void FPSCamera::setOrientation( float x, float y, float z, float w )
{
  Ogre::Quaternion quat( w, x, y, z );
  yaw_ = quat.getYaw( false ).valueRadians();
  pitch_ = quat.getPitch( false ).valueRadians();

  Ogre::Vector3 direction = quat * Ogre::Vector3::NEGATIVE_UNIT_Z;
  if ( direction.dotProduct( Ogre::Vector3::NEGATIVE_UNIT_Z ) < 0 )
  {
    if ( pitch_ > Ogre::Math::HALF_PI )
    {
      pitch_ = -Ogre::Math::HALF_PI + (pitch_ - Ogre::Math::HALF_PI);
    }
    else if ( pitch_ < -Ogre::Math::HALF_PI )
    {
      pitch_ = Ogre::Math::HALF_PI - (-pitch_ - Ogre::Math::HALF_PI);
    }

    yaw_ = -yaw_;

    if ( direction.dotProduct( Ogre::Vector3::UNIT_X ) < 0 )
    {
      yaw_ -= Ogre::Math::PI;
    }
    else
    {
      yaw_ += Ogre::Math::PI;
    }
  }

  normalizePitch();
  normalizeYaw();

  update();
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:35,代码来源:fps_camera.cpp

示例6: axis

	Ogre::Vector3 ParticleChain::computeFrictionDamping(const Ogre::Vector3 &normal, const Ogre::Vector3 &velocity)
	{
		int minAxis = 0;
		if (normal.y*normal.y < normal.x*normal.x) minAxis = 1;
		Ogre::Vector3 axis(0, 0, 0);
		axis[minAxis] = 1;
		Ogre::Vector3 u = normal.crossProduct(axis);
		Ogre::Vector3 v = u.crossProduct(normal);
		return mFriction * (velocity.dotProduct(u) * u + velocity.dotProduct(v) * v);
	}
开发者ID:JohannKollmann,项目名称:blackstar-engine,代码行数:10,代码来源:FTLParticleChain.cpp

示例7: setBaseAnimation

void 
Agent::updateLocomote(Ogre::Real deltaTime)
{
	//This is the update locomotion from the previous assignment
	// Set idle animation
	if (mDirection == Ogre::Vector3::ZERO)
	{
		if (nextLocation()) 
        {
			Ogre::Vector3 src = mBodyNode->getOrientation() * Ogre::Vector3::UNIT_Z;
				if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) 
				{
					mBodyNode->yaw(Ogre::Degree(180));
				}
				else
				{
					Ogre::Quaternion quat = src.getRotationTo(mDirection);
					mBodyNode->rotate(quat);
				}
			setBaseAnimation(ANIM_RUN_BASE);
			setTopAnimation(ANIM_RUN_TOP);
		}
	}
	else
	{
       Ogre::Real move = mWalkSpeed * deltaTime;
       mDistance -= move;
	   if (mDistance <= 0.0f)
	   {
		   mBodyNode->setPosition(mDestination);
		   mDirection = Ogre::Vector3::ZERO;
		   if (!nextLocation())
		   {                  
			   setBaseAnimation(ANIM_IDLE_BASE);
			   setTopAnimation(ANIM_IDLE_TOP);
		   } 
		   else
		   {
			   Ogre::Vector3 src = mBodyNode->getOrientation() * Ogre::Vector3::UNIT_Z;
			   if ((1.0f + src.dotProduct(mDirection)) < 0.0001f) 
			   {
				   mBodyNode->yaw(Ogre::Degree(180));
			   }
			   else
			   {
				   Ogre::Quaternion quat = src.getRotationTo(mDirection);
				   mBodyNode->rotate(quat);
			   } 
		   }
	   }
	   else { mBodyNode->translate(mDirection * move); }
	}
	
}
开发者ID:Segobiano,项目名称:425_Final_Project,代码行数:54,代码来源:Agent.cpp

示例8: 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);
}
开发者ID:BeanOfLight,项目名称:BeanOfLight,代码行数:15,代码来源:AnimalThirdPersonControler.cpp

示例9: PerformSphereSphereCollisionTest

bool PhysicsEngine::PerformSphereSphereCollisionTest(const Ogre::FrameEvent &fe, PhysicsEntity *sphere1, PhysicsEntity *sphere2)
{
	float overlapMagnitude = (sphere1->GetRadius() + sphere2->GetRadius()) - sphere1->getPosition().distance(sphere2->getPosition());
	if (overlapMagnitude >= 0.0f)
	{
		Ogre::Vector3 d = sphere2->getPosition() - sphere1->getPosition();
		Ogre::Vector3 relativeVelocity = d * (d.dotProduct(sphere1->GetVelocity() - sphere2->GetVelocity()) / d.squaredLength());
		
		Ogre::Vector3 impulse1 = (((sphere2->GetRestitution() + 1.0f) * relativeVelocity) /
			((1 / sphere1->GetMass()) + (1 / sphere2->GetMass())));
		Ogre::Vector3 impulse2 = -(((sphere1->GetRestitution() + 1.0f) * relativeVelocity) /
			((1 / sphere1->GetMass()) + (1 / sphere2->GetMass())));
		
		//Ogre::Vector3 currentImpulse1 = d * (d.dotProduct(sphere1->GetAppliedForce()) / d.squaredLength());
		//Ogre::Vector3 currentImpulse2 = -d * (d.dotProduct(sphere2->GetAppliedForce()) / d.squaredLength());
		
		if (sphere1->GetBodyType() == ENTITY_BODY_SPHERE && sphere2->GetBodyType() == ENTITY_BODY_SPHERE)
		{
			sphere1->translate(-d.normalisedCopy() * (overlapMagnitude / 2.0f));
			sphere2->translate(d.normalisedCopy() * (overlapMagnitude / 2.0f));

			sphere2->ApplyForce(impulse1);// + currentImpulse1);
			sphere1->ApplyForce(impulse2);// + currentImpulse2);
		}

		sphere1->Collide(fe, sphere2);
		sphere2->Collide(fe, sphere1);

		return true;
	}

	return false;
}
开发者ID:Elephly,项目名称:d00m3d,代码行数:33,代码来源:physics_engine.cpp

示例10: UpdateAI

void CharacterController::UpdateAI(float dt)
{
	_CurrentPathAge += dt;
	//std::cerr << _CurrentPathIndex << " / " << _CurrentPath.size() << "\n";
	if (_CurrentPathIndex + 2 <= _CurrentPath.size())
	{
		Ogre::Vector3 const & a = _CurrentPath[_CurrentPathIndex];
		Ogre::Vector3 const & b = _CurrentPath[_CurrentPathIndex+1];
		Ogre::Vector3 const & m = GetPosition();
		Ogre::Vector3 const ab = b - a;
		Ogre::Vector3 const am = m - a;
		Ogre::Vector3 const mb = b - m;
		Ogre::Vector3 const mb_unit = mb.normalisedCopy();
		
		float remaining = mb.length();
		for(size_t i = _CurrentPathIndex + 1; i + 2 <= _CurrentPath.size(); ++i)
		{
			remaining += _CurrentPath[i].distance(_CurrentPath[i+1]);
		}
		//std::cerr << "Remaining distance: " << remaining << " m\n";
		
		float lambda = am.dotProduct(ab) / ab.squaredLength();
		
		//const float tau = 0.1;
		
		SetVelocity(_CurrentVelocity * mb_unit);
		
		if (lambda > 1) _CurrentPathIndex++;
		/*if (_CurrentPathIndex + 1 == _CurrentPath.size())
			SetVelocity(Ogre::Vector3(0.));*/
	}
}
开发者ID:Meumeu,项目名称:PMD,代码行数:32,代码来源:CharacterController.cpp

示例11: injectMousePress

void OrientationControlet::injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id)
{
	if( _id == MyGUI::MouseButton::Left ){
		string name = Game::getSingleton().pickMovableObject( _absx,_absy );
		if( name == mName ){
			mPick = true;
			mMouseX = _absx;
			mMouseY = _absy;
			InputFilter::getSingleton().setCapture();

			/*判断开始时候,控制球是在球的正面还是背面
			*/
			Game& game = Game::getSingleton();
			int sx = game.getScreenWidth();
			int sy = game.getScreenHeight();
			Ogre::Ray B = game.getCamera()->getCameraToViewportRay(
					(Ogre::Real)_absx/(Ogre::Real)sx,
					(Ogre::Real)_absy/(Ogre::Real)sy
				);
			Ogre::Matrix3 m3 = mNode->getLocalAxes();
			Ogre::Vector3 axis = m3.GetColumn(2);
			if( axis.dotProduct(B.getDirection())>0 )
				mNearFar = false;
			else
				mNearFar = true;
		}
	}
}
开发者ID:JohnCrash,项目名称:iRobot,代码行数:28,代码来源:RigidControlet.cpp

示例12: isCameraInsideLight

bool DeferredLight::isCameraInsideLight(Ogre::Camera* camera) {
    switch (parentLight->getType()) {
        case Ogre::Light::LT_DIRECTIONAL:
            return false;
        case Ogre::Light::LT_POINT: {
            Ogre::Real distanceFromLight =
                camera->getDerivedPosition().distance(parentLight->getDerivedPosition());

            // Small epsilon fix to account for the fact that we aren't a true sphere.
            return distanceFromLight <= radius + camera->getNearClipDistance() + 0.1;
        }
        case Ogre::Light::LT_SPOTLIGHT: {
            Ogre::Vector3 lightPos = parentLight->getDerivedPosition();
            Ogre::Vector3 lightDir = parentLight->getDerivedDirection();
            Ogre::Radian attAngle = parentLight->getSpotlightOuterAngle();

            // Extend the analytic cone's radius by the near clip range by moving its tip accordingly.
            Ogre::Vector3 clipRangeFix = -lightDir * (camera->getNearClipDistance() / Ogre::Math::Tan(attAngle/2));
            lightPos = lightPos + clipRangeFix;

            Ogre::Vector3 lightToCamDir = camera->getDerivedPosition() - lightPos;
            Ogre::Real distanceFromLight = lightToCamDir.normalise();

            Ogre::Real cosAngle = lightToCamDir.dotProduct(lightDir);
            Ogre::Radian angle = Ogre::Math::ACos(cosAngle);

            // Check whether we will see the cone from our current POV.
            return (distanceFromLight <= (parentLight->getAttenuationRange() + clipRangeFix.length()))
                   && (angle <= attAngle);
        }
        default:
            return false;
    }
}
开发者ID:summerbreezeex,项目名称:SolidBlack,代码行数:34,代码来源:DeferredLight.cpp

示例13: _setScale

//--------------------------------------------------------------------------------
bool CMultiSelEditor::_setScale(OgitorsPropertyBase* property, const Ogre::Vector3& val)
{
    if(val.x == 0.0f || val.y == 0.0f || val.z == 0.0f)
        return false;
    
    Ogre::Vector3 scale;
    Ogre::Vector3 diff = val / mNode->getScale(); 

    mNode->setScale(val);

    Ogre::Vector3 groupPos = mNode->getPosition();

    NameObjectPairList::const_iterator it = mModifyList.begin();
    while(it != mModifyList.end())
    {
        if(!it->second->getLocked())
        {
            Ogre::Vector3 newpos = it->second->getDerivedPosition() - groupPos;
            
            Ogre::Vector3 AxisX = mNode->getOrientation() * Ogre::Vector3::UNIT_X;
            Ogre::Vector3 AxisY = mNode->getOrientation() * Ogre::Vector3::UNIT_Y;
            Ogre::Vector3 AxisZ = mNode->getOrientation() * Ogre::Vector3::UNIT_Z;

            Ogre::Vector3 vPos1 = (AxisX.dotProduct(newpos) * AxisX);
            Ogre::Vector3 vPos2 = (AxisY.dotProduct(newpos) * AxisY);
            Ogre::Vector3 vPos3 = (AxisZ.dotProduct(newpos) * AxisZ);
            newpos = (vPos1 * diff.x) + (vPos2 * diff.y) + (vPos3 * diff.z) + groupPos;
           
            it->second->setDerivedPosition(newpos);

            if(it->second->getProperties()->hasProperty("scale"))
            {
                it->second->getProperties()->getValue("scale",scale);
                scale = it->second->getDerivedOrientation().Inverse() * scale;
                scale = mNode->getOrientation() * scale;
                scale *= diff;
                scale = mNode->getOrientation().Inverse() * scale;
                scale = it->second->getDerivedOrientation() * scale;
            
                it->second->getProperties()->setValue("scale", scale);
            }
        }
        it++;
    }
    return true;
}
开发者ID:jacmoe,项目名称:ogitor,代码行数:47,代码来源:MultiSelEditor.cpp

示例14: setDirection

void GameObject::setDirection(const Ogre::Vector3 direction)
{
  Ogre::Radian r = initialForward.angleBetween(direction);
  Ogre::Vector3 initialRight = initialForward.crossProduct(Ogre::Vector3::UNIT_Y);
  if (initialRight.dotProduct(direction) > 0.f)
    r *= -1;
  setYaw(r);
}
开发者ID:flair2005,项目名称:RemoteRenderer,代码行数:8,代码来源:GameObject.cpp

示例15: intersect

 //helper function
 inline Ogre::Real
 intersect(Ogre::Plane* plane,const Ogre::Vector3 &p1, const Ogre::Vector3 &p2)
 {
     Ogre::Vector3 dir = p2 - p1;
     Ogre::Real den = dir.dotProduct(plane->normal);
     if(den == 0)
         return 1e20f;
     return -plane->getDistance(p1) / den;
 }
开发者ID:gitrider,项目名称:wxsj2,代码行数:10,代码来源:Axis3d.cpp


注:本文中的ogre::Vector3::dotProduct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。