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


C++ Ray::setOrigin方法代码示例

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


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

示例1: updateCameraHeight

void TerrainManager::updateCameraHeight(const Ogre::FrameEvent& evt)
{
  // clamp to terrain
  Ogre::Vector3 camPos = mCamera->getPosition();
  Ogre::Ray ray;
  ray.setOrigin(Ogre::Vector3(camPos.x, mTerrainPos.y + 10000, camPos.z));
  ray.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);

  Ogre::TerrainGroup::RayResult rayResult = mTerrainGroup->rayIntersects(ray);
  Ogre::Real distanceAboveTerrain = 50;
  Ogre::Real fallSpeed = 300;
  Ogre::Real newy = camPos.y;
  if (rayResult.hit)
    {
      if (camPos.y > rayResult.position.y + distanceAboveTerrain)
	{
	  mFallVelocity += evt.timeSinceLastFrame * 20;
	  mFallVelocity = std::min(mFallVelocity, fallSpeed);
	  newy = camPos.y - mFallVelocity * evt.timeSinceLastFrame;

	}
      newy = std::max(rayResult.position.y + distanceAboveTerrain, newy);
      mCamera->setPosition(camPos.x, newy, camPos.z);
				
    }
}
开发者ID:lkarydas,项目名称:ogre_object_placement_utility,代码行数:26,代码来源:TerrainManager.cpp

示例2: ViewportRay

void CombatCamera::ViewportRay(double screen_x, double screen_y, Ogre::Ray& ray) const
{
    double out_origin[3];
    double ray_direction[3];
    ViewportRay(screen_x,  screen_y, out_origin, ray_direction);
    ray.setOrigin(Ogre::Vector3(out_origin[0], out_origin[1], out_origin[2]));
    ray.setDirection(Ogre::Vector3(ray_direction[0], ray_direction[1], ray_direction[2]));
}
开发者ID:Ablu,项目名称:freeorion,代码行数:8,代码来源:CombatCamera.cpp

示例3: raycastFromPoint

// raycast from a point in to the scene.
// returns success or failure.
// on success the point is returned in the result.
bool CollisionTools::raycastFromPoint(const Vector3 &point,
                                        const Vector3 &normal,
										Vector3 &result,unsigned long &target,float &closest_distance,
										const uint32 queryMask)
{
    // create the ray to test
    static Ogre::Ray ray;
	ray.setOrigin(point);
	ray.setDirection(normal);

	return raycast(ray, result, target, closest_distance, queryMask);
}
开发者ID:nikki93,项目名称:ngf,代码行数:15,代码来源:CollisionTools.cpp

示例4: raycastFromPoint

bool CollisionTools::raycastFromPoint(const Ogre::Vector3 &point,
                                        const Ogre::Vector3 &normal,
										Ogre::Vector3 &result,int &FaceIndex,Ogre::MovableObject* &target,
										float &closest_distance,
										const Ogre::uint32 queryMask)
{
    // create the ray to test
    static Ogre::Ray ray;
	ray.setOrigin(point);
	ray.setDirection(normal);

	return raycast(ray, result,FaceIndex, target, closest_distance, queryMask);
}
开发者ID:kelingjie1,项目名称:TheRoadofHegemony,代码行数:13,代码来源:CollisionTools.cpp

示例5: intersectGroundPlane

bool XYOrbitViewController::intersectGroundPlane( Ogre::Ray mouse_ray, Ogre::Vector3 &intersection_3d )
{
  //convert rays into reference frame
  mouse_ray.setOrigin( target_scene_node_->convertWorldToLocalPosition( mouse_ray.getOrigin() ) );
  mouse_ray.setDirection( target_scene_node_->convertWorldToLocalOrientation( Ogre::Quaternion::IDENTITY ) * mouse_ray.getDirection() );

  Ogre::Plane ground_plane( Ogre::Vector3::UNIT_Z, 0 );

  std::pair<bool, Ogre::Real> intersection = mouse_ray.intersects(ground_plane);
  if (!intersection.first)
  {
    return false;
  }

  intersection_3d = mouse_ray.getPoint(intersection.second);
  return true;
}
开发者ID:jkammerl,项目名称:rviz,代码行数:17,代码来源:xy_orbit_view_controller.cpp

示例6: getTSMHeightAt

float CollisionTools::getTSMHeightAt(const float x, const float z) {
	float y=0.0f;

    static Ogre::Ray updateRay;

    updateRay.setOrigin(Ogre::Vector3(x,9999,z));
    updateRay.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);

    mTSMRaySceneQuery->setRay(updateRay);
    Ogre::RaySceneQueryResult& qryResult = mTSMRaySceneQuery->execute();

    Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
    if (i != qryResult.end() && i->worldFragment)
    {
        y=i->worldFragment->singleIntersection.y;
    }
	return y;
}
开发者ID:aerique,项目名称:okra,代码行数:18,代码来源:CollisionTools.cpp

示例7: UpdateCameraControl

BOOL CCameraController::UpdateCameraControl()
{
	if (m_bLocked)
	{
		return TRUE;
	}

	Vector3 vtNewPos = m_pBindObject->GetPosition();
	if((m_vtBindObjPos == vtNewPos)&&(!m_bPositionUpate)&&!m_bMoveCameraFar&&!m_bMoveCameraNear)
	{
		return TRUE;
	}

	if(m_bMoveCameraNear)
	{
		m_fDistance -= 0.05;
	}

	if(m_bMoveCameraFar)
	{
		m_fDistance += 0.05;
	}

	m_vtBindObjPos = vtNewPos;

	m_vecDstPos = m_vecUnitDir * m_fDistance + m_vtBindObjPos;

	

	Ogre::Vector3 RayDir = m_vecDstPos-vtNewPos;
	RayDir.normalise();

	Ogre::Ray SearchRay;
	SearchRay.setOrigin(vtNewPos);
	SearchRay.setDirection(RayDir);

	g_Debuginfo.PrintfInfo("m_vecDstPos x:%.2f-y:%.2f-z:%.2f!||", m_vecDstPos.x,m_vecDstPos.y,m_vecDstPos.z);

	
	Ogre::TerrainGroup::RayResult rayResult = CGameApp::GetGameApp()->m_World.m_pTerrainGroup->rayIntersects(SearchRay);
	if(rayResult.hit)
	{
		if((rayResult.position-vtNewPos).length()<m_fDistance)
		{
			m_vecDstPos = rayResult.position;
			m_vecDstPos .y += 1;
			g_Debuginfo.PrintfInfo("hit -- rayResult x:%.2f--y:%.2f--z:%.2f!\n", rayResult.position.x,rayResult.position.y,rayResult.position.z);
		}
		else
		{
			g_Debuginfo.PrintfInfo("hit --rayResult x:1--y:1--z:1!\n");
		}
		
	}
	else
	{
		g_Debuginfo.PrintfInfo("unhit --rayResult x:0--y:0--z:0!\n");
	}

	m_pCamera->lookAt(vtNewPos+Vector3(0,1.5,0));

	m_pCamera->setPosition(m_vecDstPos);

	m_bPositionUpate = FALSE;

	return TRUE;
}
开发者ID:whztt07,项目名称:OgreClient,代码行数:67,代码来源:CameraController.cpp

示例8: frameRenderingQueued

//-------------------------------------------------------------------------------------
bool SampleApp::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
    bool ret = BaseApplication::frameRenderingQueued(evt);

    if (!mFly)
    {
        // clamp to terrain
        Ogre::Vector3 camPos = mActiveCamera->getPosition();
        Ogre::Ray ray;
        ray.setOrigin(Ogre::Vector3(camPos.x, 10000, camPos.z));
        ray.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);

        Ogre::TerrainGroup::RayResult rayResult = mLoader->getTerrainGroup()->rayIntersects(ray);
        Ogre::Real distanceAboveTerrain = 1.4f;
        Ogre::Real fallSpeed = 200;
        Ogre::Real newy = camPos.y;
        if (rayResult.hit)
        {
            if (camPos.y > rayResult.position.y + distanceAboveTerrain)
            {
                mFallVelocity += evt.timeSinceLastFrame * 10;
                mFallVelocity = std::min(mFallVelocity, fallSpeed);
                newy = camPos.y - mFallVelocity * evt.timeSinceLastFrame;

            }
            newy = std::max(rayResult.position.y + distanceAboveTerrain, newy);
            mActiveCamera->setPosition(camPos.x, newy, camPos.z);
        }
    }

    if (!mLoader->getTerrainGroup()->isDerivedDataUpdateInProgress())
    {
        if (mTerrainImported)
        {
            mLoader->getTerrainGroup()->saveAllTerrains(true);
            mTerrainImported = false;
        }
    }

	mImpulse = btVector3(0,0,0);

	if(mKeyboard->isKeyDown(OIS::KC_I))
		mImpulse += btVector3(0,0,1);
	if(mKeyboard->isKeyDown(OIS::KC_K))
		mImpulse += btVector3(0,0,-1);
	if(mKeyboard->isKeyDown(OIS::KC_J))
		mImpulse += btVector3(-1,0,0);
	if(mKeyboard->isKeyDown(OIS::KC_L))
		mImpulse += btVector3(1,0,0);

	mCharacterBody->applyCentralImpulse(mImpulse);
	//Update Bullet world.
	Globals::phyWorld->stepSimulation(evt.timeSinceLastFrame, 10);
	Globals::dbgdraw->setDebugMode(mKeyboard->isKeyDown(OIS::KC_F3));	
	Globals::dbgdraw->step();
    //for(unsigned int ij = 0;ij < mLoader->mPGHandles.size();ij++)
    //{
    //    mLoader->mPGHandles[ij]->update();
    //}

    return ret;
}
开发者ID:aspiringprogrammer,项目名称:Capstone,代码行数:63,代码来源:SampleApp.cpp

示例9: if

std::pair<bool, Real>
rayCollide(const Ogre::Ray& ray,
           Ogre::MovableObject* movable,
           bool accurate,
           CullingMode cullingMode,
           bool allowAnimable)
{
    // Get local space axis aligned bounding box
    const Ogre::AxisAlignedBox& aabb = movable->getBoundingBox();

    // Matrix4 to transform local space to world space
    const Ogre::Matrix4& localToWorld = movable->_getParentNodeFullTransform();

    // Matrix4 to transform world space to local space
    Ogre::Matrix4 worldToLocal = localToWorld.inverse();

    // Matrix3 to transform world space normal to local space
    Ogre::Matrix3 worldToLocalN;
    worldToLocal.extract3x3Matrix(worldToLocalN);

    // Convert world space ray to local space ray
    // Note:
    //      By preserving the scale between world space and local space of the
    //      direction, we don't need to recalculate the distance later.
    Ogre::Ray localRay;
    localRay.setOrigin(worldToLocal * ray.getOrigin());
    localRay.setDirection(worldToLocalN * ray.getDirection());

    // Intersect with axis aligned bounding box, but because we transformed
    // ray to local space of the bounding box, so this test just like test
    // with oriented bounding box.
    std::pair<bool, Real> ret = localRay.intersects(aabb);

    // Do accurate test if hitted bounding box and user required.
    if (ret.first && accurate)
    {
        if (movable->getMovableType() == Ogre::EntityFactory::FACTORY_TYPE_NAME ||
            allowAnimable && movable->getMovableType() == Ogre::AutoAnimationEntityFactory::FACTORY_TYPE_NAME)
        {
            Ogre::Entity* entity = static_cast<Ogre::Entity*>(movable);
            if (!entity->_isAnimated())
            {
                // Static entity

                // Get the entity mesh
                const Ogre::MeshPtr& mesh = entity->getMesh();

                // Get the collision mode
                CollisionModelPtr collisionModel = CollisionModelManager::getSingleton().getCollisionModel(mesh);

                ret = doPicking(localRay, *collisionModel, cullingMode);
            }
            else if (allowAnimable)
            {
                // Animation entity

                bool addedSoftwareAnimation = false;
                if (entity->getSoftwareAnimationRequests() <= 0)
                {
                    entity->addSoftwareAnimationRequest(false);
                    entity->_updateAnimation();
                    addedSoftwareAnimation = true;
                }

                CollisionModel collisionModel;
                collisionModel.addEntity(entity);
                collisionModel.build(true);

                ret = doPicking(localRay, collisionModel, cullingMode);

                if (addedSoftwareAnimation)
                {
                    entity->removeSoftwareAnimationRequest(false);
                }
            }
        }
    }

    return ret;
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:80,代码来源:WXRayCollide.cpp


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