bool FlyingCamera::onSimCameraQuery(SimCameraQuery *query)
{
   SimObjectTransformQuery tquery;

   query->cameraInfo.fov       = g_rDefaultFOV;
   query->cameraInfo.nearPlane = DEFAULT_NEAR_PLANE;
   query->cameraInfo.farPlane  = getFarPlane();

   if (objFollow && objFollow->processQuery(&tquery))
   {
      Point3F  objPos = tquery.tmat.p;
      Vector3F x, y, z;
      RMat3F   rmat(EulerF(rotation.x - M_PI / 2, rotation.y, -rotation.z));

      tquery.tmat.p   += m_mul(Vector3F(0.0f, rDistance, 0.0f), rmat, &y);
      tquery.tmat.p.z += 2.0f;

      y.neg();
      y.normalize();
      m_cross(y, Vector3F(0.0f, 0.0f, 1.0f), &x);
      x.normalize();
      m_cross(x, y, &z);

      tquery.tmat.setRow(0, x);
      tquery.tmat.setRow(1, y);
      tquery.tmat.setRow(2, z);

      // Set our position
      findLOSPosition(tquery.tmat, objPos);
   }

   query->cameraInfo.tmat = getTransform();
   return (true);
}
Example #2
0
	void LightCategory::bind( castor::PxBufferBase & p_texture, uint32_t index )const
	{
		uint32_t offset = 0u;
		doCopyComponent( getColour(), index, offset, p_texture );
		doCopyComponent( getIntensity(), getFarPlane(), index, offset, p_texture );
		doBind( p_texture, index, offset );
	}
Example #3
0
SceneRenderState::SceneRenderState( SceneManager* sceneManager,
                                    ScenePassType passType,
                                    const SceneCameraState& view,
                                    RenderPassManager* renderPass /* = NULL */,
                                    bool usePostEffects /* = true */ )
   :  mSceneManager( sceneManager ),
      mCullingState( sceneManager, view ),
      mRenderPass( renderPass ? renderPass : sceneManager->getDefaultRenderPass() ),
      mScenePassType( passType ),
      mRenderNonLightmappedMeshes( true ),
      mRenderLightmappedMeshes( true ),
      mUsePostEffects( usePostEffects ),
      mDisableAdvancedLightingBins( false ),
      mRenderArea( view.getFrustum().getBounds() ),
      mAmbientLightColor( sceneManager->getAmbientLightColor() ),
      mSceneRenderStyle( SRS_Standard ),
      mRenderField( 0 )
{
   // Setup the default parameters for the screen metrics methods.
   mDiffuseCameraTransform = view.getViewWorldMatrix();

   // The vector eye is the camera vector with its 
   // length normalized to 1 / zFar.
   getCameraTransform().getColumn( 1, &mVectorEye );
   mVectorEye.normalize( 1.0f / getFarPlane() );

   // TODO: What about ortho modes?  Is near plane ok
   // or do i need to remove it... maybe ortho has a near
   // plane of 1 and it just works out?

   const Frustum& frustum = view.getFrustum();
   const RectI& viewport = view.getViewport();

   mWorldToScreenScale.set(   ( frustum.getNearDist() * viewport.extent.x ) / ( frustum.getNearRight() - frustum.getNearLeft() ),
                              ( frustum.getNearDist() * viewport.extent.y ) / ( frustum.getNearTop() - frustum.getNearBottom() ) );

   // Assign shared matrix data to the render pass.

   mRenderPass->assignSharedXform( RenderPassManager::View, view.getWorldViewMatrix() );
   mRenderPass->assignSharedXform( RenderPassManager::Projection, view.getProjectionMatrix() );
}
void ShapeView::onWake()
{
   float width, height;

   if (camera)
   {
      // Set up the viewport
      width  = DEFAULT_NEAR_PLANE * tan(DEFAULT_FOV);
      height = (float)extent.y / (float)extent.x * width;

      camera->setWorldViewport(
         RectF(-width, height, width, -height));
      camera->setNearDist(DEFAULT_NEAR_PLANE);
      camera->setFarDist (getFarPlane());
      camera->setScreenViewport(
         RectI(position.x, position.y, 
               position.x + extent.x, position.y + extent.y));

      // Load the shape
      loadShape(gDefaultShapeFile);

      timer.reset();
   }
}
Example #5
0
void CameraNode::updateFrustum() {
	frustum.setFrustumFromAngles(fovLeft,fovRight,fovBottom,fovTop,getNearPlane(),getFarPlane());
	frustum.setPosition( 	getWorldOrigin(), // pos
							Transformations::localDirToWorldDir(*this,Geometry::Vec3(0,0,-1)),  	// dir
							Transformations::localDirToWorldDir(*this,Geometry::Vec3(0,1,0)));	// up
}