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


C++ MatrixF::inverse方法代码示例

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


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

示例1: getCollisionInfo

bool Convex::getCollisionInfo(const MatrixF& mat, const Point3F& scale, CollisionList* cList,F32 tol)
{
   PROFILE_SCOPE( Convex_GetCollisionInfo );

   // Making these static prevents needless Vector resizing that occurs
   // in the ConvexFeature constructor.
   static ConvexFeature fa;
   static ConvexFeature fb;

   for ( CollisionStateList* itr = mList.mNext; 
         itr != &mList; 
         itr = itr->mNext) 
   {

      CollisionState* state = itr->mState;

      if (state->mLista != itr)
         state->swap();

      if (state->dist <= tol) 
      {
         fa.reset();
         fb.reset();
         VectorF v;

         // The idea is that we need to scale the matrix, so we need to
         // make a copy of it, before we can pass it in to getFeatures.
         // This is used to scale us for comparison against the other
         // convex, which is correctly scaled.
         MatrixF omat = mat;
         omat.scale(scale);

         MatrixF imat = omat;
         imat.inverse();
         imat.mulV(-state->v,&v);

         getFeatures(omat,v,&fa);

         imat = state->b->getTransform();
         imat.scale(state->b->getScale());

         MatrixF bxform = imat;
         imat.inverse();
         imat.mulV(state->v,&v);

         state->b->getFeatures(bxform,v,&fb);

         fa.collide(fb,cList,tol);
      }
   }

   return (cList->getCount() != 0);
}
开发者ID:jamesu,项目名称:libDTShape,代码行数:53,代码来源:convex.cpp

示例2: applyImpulse

void BtBody::applyImpulse( const Point3F &origin, const Point3F &force )
{
   AssertFatal( mActor, "BtBody::applyImpulse - The actor is null!" );
   AssertFatal( isDynamic(), "BtBody::applyImpulse - This call is only for dynamics!" );

   // Convert the world position to local
   MatrixF trans = btCast<MatrixF>( mActor->getCenterOfMassTransform() );
   trans.inverse();
   Point3F localOrigin( origin );
   trans.mulP( localOrigin );

   if ( mCenterOfMass )
   {
      Point3F relOrigin( localOrigin );
      mCenterOfMass->mulP( relOrigin );
      Point3F relForce( force );
      mCenterOfMass->mulV( relForce );
      mActor->applyImpulse( btCast<btVector3>( relForce ), btCast<btVector3>( relOrigin ) );
   }
   else
      mActor->applyImpulse( btCast<btVector3>( force ), btCast<btVector3>( localOrigin ) );

   if ( !mActor->isActive() )
      mActor->activate();
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:25,代码来源:btBody.cpp

示例3: getLocalNodeMatrix

MatrixF TSShapeLoader::getLocalNodeMatrix(AppNode* node, F32 t)
{
   MatrixF m1 = node->getNodeTransform(t);

   // multiply by inverse scale at t=0
   MatrixF m10 = node->getNodeTransform(DefaultTime);
   m1.scale(Point3F(1.0f/m10.getScale().x, 1.0f/m10.getScale().y, 1.0f/m10.getScale().z));

   if (node->mParentIndex >= 0)
   {
      AppNode *parent = appNodes[node->mParentIndex];

      MatrixF m2 = parent->getNodeTransform(t);

      // multiply by inverse scale at t=0
      MatrixF m20 = parent->getNodeTransform(DefaultTime);
      m2.scale(Point3F(1.0f/m20.getScale().x, 1.0f/m20.getScale().y, 1.0f/m20.getScale().z));

      // get local transform by pre-multiplying by inverted parent transform
      m1 = m2.inverse() * m1;
   }
   else if (boundsNode && node != boundsNode)
   {
      // make transform relative to bounds node transform at time=t
      MatrixF mb = boundsNode->getNodeTransform(t);
      zapScale(mb);
      m1 = mb.inverse() * m1;
   }

   return m1;
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:31,代码来源:tsShapeLoader.cpp

示例4: generateGroundAnimation

void TSShapeLoader::generateGroundAnimation(TSShape::Sequence& seq, const AppSequence* appSeq)
{
   seq.firstGroundFrame = shape->groundTranslations.size();
   seq.numGroundFrames = 0;

   if (!boundsNode)
      return;

   // Check if the bounds node is animated by this sequence
   seq.numGroundFrames = (S32)((seq.duration + 0.25f/AppGroundFrameRate) * AppGroundFrameRate);

   seq.flags |= TSShape::MakePath;

   // Get ground transform at the start of the sequence
   MatrixF invStartMat = boundsNode->getNodeTransform(appSeq->getStart());
   zapScale(invStartMat);
   invStartMat.inverse();

   for (int iFrame = 0; iFrame < seq.numGroundFrames; iFrame++)
   {
      F32 time = appSeq->getStart() + seq.duration * iFrame / getMax(1, seq.numGroundFrames - 1);

      // Determine delta bounds node transform at 't'
      MatrixF mat = boundsNode->getNodeTransform(time);
      zapScale(mat);
      mat = invStartMat * mat;

      // Add ground transform
      Quat16 rotation;
      rotation.set(QuatF(mat));
      shape->groundTranslations.push_back(mat.getPosition());
      shape->groundRotations.push_back(rotation);
   }
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:34,代码来源:tsShapeLoader.cpp

示例5: _renderCorona

void Sun::_renderCorona( ObjectRenderInst *ri, SceneState *state, BaseMatInstance *overrideMat )
{   
   Point3F sunlightPosition = state->getCameraPosition() - mLight->getDirection() * state->getFarPlane() * 0.9f;

   // Calculate Billboard Radius (in world units) to be constant, independent of distance.
   // Takes into account distance, viewport size, and specified size in editor
   F32 BBRadius = (((sunlightPosition - state->getCameraPosition()).len()) / (GFX->getViewport().extent.x / 640.0)) / 2;  
   BBRadius *= mCoronaScale;

   GFXTransformSaver saver;

   if ( state->isReflectPass() )
      GFX->setProjectionMatrix( gClientSceneGraph->getNonClipProjection() );

   GFX->setStateBlock(mCoronaSB);

   // Initialize points with basic info
   Point3F points[4];
   points[0] = Point3F(-BBRadius, 0.0, -BBRadius);
   points[1] = Point3F( BBRadius, 0.0, -BBRadius);
   points[2] = Point3F( BBRadius, 0.0,  BBRadius);
   points[3] = Point3F(-BBRadius, 0.0,  BBRadius);

   // Get info we need to adjust points
   MatrixF camView = GFX->getWorldMatrix();
   camView.inverse();

   // Finalize points
   for(int i = 0; i < 4; i++)
   {
      // align with camera
      camView.mulV(points[i]);
      // offset
      points[i] += sunlightPosition;
   }

   // Draw it
   
   if ( mCoronaUseLightColor )
      PrimBuild::color(mLightColor);
   else
      PrimBuild::color(mCoronaTint);
   
   GFX->setTexture(0, mCoronaTexture);

   PrimBuild::begin( GFXTriangleFan, 4 );
   PrimBuild::texCoord2f(0, 0);
   PrimBuild::vertex3fv(points[0]);
   PrimBuild::texCoord2f(1, 0);
   PrimBuild::vertex3fv(points[1]);
   PrimBuild::texCoord2f(1, 1);
   PrimBuild::vertex3fv(points[2]);
   PrimBuild::texCoord2f(0, 1);
   PrimBuild::vertex3fv(points[3]);
   PrimBuild::end();
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:56,代码来源:sun.cpp

示例6: setGFXMatrices

void PlaneReflector::setGFXMatrices( const MatrixF &camTrans )
{
   if ( objectSpace )
   {
      // set up camera transform relative to object
      MatrixF invObjTrans = mObject->getRenderTransform();
      invObjTrans.inverse();
      MatrixF relCamTrans = invObjTrans * camTrans;

      MatrixF camReflectTrans = getCameraReflection( relCamTrans );
      MatrixF camTrans = mObject->getRenderTransform() * camReflectTrans;
      camTrans.inverse();

      GFX->setWorldMatrix( camTrans );

      // use relative reflect transform for modelview since clip plane is in object space
      camTrans = camReflectTrans;
      camTrans.inverse();

      // set new projection matrix
      gClientSceneGraph->setNonClipProjection( (MatrixF&) GFX->getProjectionMatrix() );
      MatrixF clipProj = getFrustumClipProj( camTrans );
      GFX->setProjectionMatrix( clipProj );
   }    
   else
   {
      // set world mat from new camera view
      MatrixF camReflectTrans = getCameraReflection( camTrans );
      camReflectTrans.inverse();
      GFX->setWorldMatrix( camReflectTrans );

      // set new projection matrix
      gClientSceneGraph->setNonClipProjection( (MatrixF&) GFX->getProjectionMatrix() );
      MatrixF clipProj = getFrustumClipProj( camReflectTrans );
      GFX->setProjectionMatrix( clipProj );
   }   
}
开发者ID:AlkexGas,项目名称:Torque3D,代码行数:37,代码来源:reflector.cpp

示例7: fromGFXWithViewport

SceneCameraState SceneCameraState::fromGFXWithViewport( const RectI& viewport )
{
   const MatrixF& world = GFX->getWorldMatrix();
   
   MatrixF camera = world;
   camera.inverse();

   Frustum frustum = GFX->getFrustum();
   frustum.setTransform( camera );

   return SceneCameraState(
      viewport,
      frustum,
      world,
      GFX->getProjectionMatrix()
   );
}
开发者ID:03050903,项目名称:Torque3D,代码行数:17,代码来源:sceneCameraState.cpp

示例8: gluUnProject

GLint gluUnProject( GLdouble winx, GLdouble winy, GLdouble winz, const F64 *model, const F64 * proj, const GLint * vp, F64 * x, F64 * y, F64 * z )
{
    Vector4F v = Vector4F( 2.0f*(winx-vp[0])/vp[2] - 1.0f, 2.0f*(winy-vp[1])/vp[2] - 1.0f, 2.0f*vp[2] - 1.0f, 1.0f );
    MatrixF pmat = MatrixF( false );
    for (int i=0; i<16; i++) { ((F32*)pmat)[i] = (float)proj[i]; }
    MatrixF mmat = MatrixF( false );
    for (int i=0; i<16; i++) { ((F32*)mmat)[i] = (float)model[i]; }
    mmat = pmat.mul(mmat);

    mmat = mmat.inverse();
    mmat.mul( v );
    *x = v.x;
    *y = v.y;
    *z = v.z;
    int glError;
    glError = TEST_FOR_OPENGL_ERRORS
    return GL_TRUE;
}
开发者ID:120pulsations,项目名称:Torque2D,代码行数:18,代码来源:EmscriptenGL.cpp

示例9: addPath

void TSShapeInstance::addPath(TSThread *gt, F32 start, F32 end, MatrixF *mat)
{
   // never get here while in transition...
   AssertFatal(!gt->transitionData.inTransition,"TSShapeInstance::addPath");

   if (!mat)
      mat = &mGroundTransform;

   MatrixF startInvM;
   gt->getGround(start,&startInvM);
   startInvM.inverse();

   MatrixF endM;
   gt->getGround(end,&endM);

   MatrixF addM;
   addM.mul(startInvM,endM);
   endM.mul(*mat,addM);
   *mat = endM;
}
开发者ID:jamesu,项目名称:libDTShape,代码行数:20,代码来源:tsAnimate.cpp

示例10: pnt

//----------------------------------------------------------------------------
AwTextureTarget *AwShape::processAwesomiumHit (const Point3F &start, const Point3F &end)
{
	if (!mTextureTarget)
	{
		return NULL;
	}

	Point3F localStart, localEnd;
	MatrixF mat = getTransform();
	mat.scale (Point3F (getScale ()));
	mat.inverse ();

	mat.mulP (start, &localStart);
	mat.mulP (end, &localEnd);

	RayInfo info;
	info.generateTexCoord = true;
	if (!mShapeInstance || !mShapeInstance->castRayOpcode (0, localStart, localEnd, &info))
	{
		return NULL;
	}

	if (info.texCoord.x != -1 && info.texCoord.y != -1 && info.material == mMatInstance)
	{
		Point2I pnt (info.texCoord.x * mTextureTarget->getResolution ().x, info.texCoord.y * mTextureTarget->getResolution ().y);
		
		AwManager::sCursor->setPosition (pnt);

		if (mIsMouseDown)
		{
			mTextureTarget->injectMouseDown ();
		}
		else
		{
			mTextureTarget->injectMouseUp ();
		}

		return mTextureTarget;
	}
	return NULL;
}
开发者ID:Azaezel,项目名称:Torque3D_Awesomium,代码行数:42,代码来源:AwShape.cpp

示例11: _setSecondaryLightInfo

void ProcessedFFMaterial::_setSecondaryLightInfo(const MatrixF &_objTrans, LightInfo* light)
{
   // set object transform
   MatrixF objTrans = _objTrans;
   objTrans.inverse();

   // fill in secondary light
   //-------------------------
   GFXLightInfo xlatedLight;
   light->setGFXLight(&xlatedLight);

   Point3F lightPos = light->getPosition();
   Point3F lightDir = light->getDirection();
   objTrans.mulP(lightPos);
   objTrans.mulV(lightDir);

   xlatedLight.mPos = lightPos;
   xlatedLight.mDirection = lightDir;

   GFX->setLight(1, &xlatedLight);
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:21,代码来源:processedFFMaterial.cpp

示例12: _setPrimaryLightInfo

void ProcessedFFMaterial::_setPrimaryLightInfo(const MatrixF &_objTrans, LightInfo* light, U32 pass)
{
   // Just in case
   GFX->setGlobalAmbientColor(ColorF(0.0f, 0.0f, 0.0f, 1.0f));
   if ( light->getType() == LightInfo::Ambient )
   {
      // Ambient light
      GFX->setGlobalAmbientColor( light->getAmbient() );
      return;
   }

   GFX->setLight(0, NULL);
   GFX->setLight(1, NULL);
   // This is a quick hack that lets us use FF lights
   GFXLightMaterial lightMat;
   lightMat.ambient = ColorF(1.0f, 1.0f, 1.0f, 1.0f);
   lightMat.diffuse = ColorF(1.0f, 1.0f, 1.0f, 1.0f);
   lightMat.emissive = ColorF(0.0f, 0.0f, 0.0f, 0.0f);
   lightMat.specular = ColorF(0.0f, 0.0f, 0.0f, 0.0f);
   lightMat.shininess = 128.0f;
   GFX->setLightMaterial(lightMat);   

   // set object transform
   MatrixF objTrans = _objTrans;
   objTrans.inverse();

   // fill in primary light
   //-------------------------
   GFXLightInfo xlatedLight;
   light->setGFXLight(&xlatedLight);
   Point3F lightPos = light->getPosition();
   Point3F lightDir = light->getDirection();
   objTrans.mulP(lightPos);
   objTrans.mulV(lightDir);

   xlatedLight.mPos = lightPos;
   xlatedLight.mDirection = lightDir;

   GFX->setLight(0, &xlatedLight);
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:40,代码来源:processedFFMaterial.cpp

示例13: castRay

bool ForestItem::castRay( const Point3F &start, const Point3F &end, RayInfo *outInfo, bool rendered ) const
{
   if ( !mWorldBox.collideLine( start, end ) )
      return false;

   Point3F s, e;
   MatrixF mat = getTransform();
   mat.scale( Point3F(mScale) );
   mat.inverse();

   mat.mulP( start, &s );
   mat.mulP( end, &e );

   TSForestItemData *data = (TSForestItemData*)mDataBlock;
   TSShapeInstance *si = data->getShapeInstance();

   if ( !si ) 
      return false;
   
   if ( rendered )
   {
      // Always raycast against detail level zero
      // because it makes lots of things easier.
      if ( !si->castRayRendered( s, e, outInfo, 0 ) )
         return false;

      if ( outInfo->userData != NULL )
         *(ForestItem*)(outInfo->userData) = *this;

      return true;
   }

   RayInfo shortest;  
   shortest.t = 1e8;
   bool gotMatch = false;
   S32 detail;

   const Vector<S32> &details = data->getLOSDetails();
   for (U32 i = 0; i < details.size(); i++) 
   {
      detail = details[i];
      if (detail != -1) 
      {
         //si->animate(data->mLOSDetails[i]);

         if ( si->castRayOpcode( detail, s, e, outInfo ) )         
         {
            if (outInfo->t < shortest.t)
            {
               gotMatch = true;
               shortest = *outInfo;      
            }
         }
      }
   }

   if ( !gotMatch )
      return false;

   // Copy out the shortest time...
   *outInfo = shortest;

   if ( outInfo->userData != NULL )
      *(ForestItem*)(outInfo->userData) = *this;

   return true;   
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:67,代码来源:forestCollision.cpp

示例14: renderCameraAxis

void EditTSCtrl::renderCameraAxis()
{
   GFXDEBUGEVENT_SCOPE( Editor_renderCameraAxis, ColorI::WHITE );

   static MatrixF sRotMat(EulerF( (M_PI_F / -2.0f), 0.0f, 0.0f));

   MatrixF camMat = mLastCameraQuery.cameraMatrix;
   camMat.mul(sRotMat);
   camMat.inverse();

   MatrixF axis;
   axis.setColumn(0, Point3F(1, 0, 0));
   axis.setColumn(1, Point3F(0, 0, 1));
   axis.setColumn(2, Point3F(0, -1, 0));
   axis.mul(camMat);

   Point3F forwardVec, upVec, rightVec;
	axis.getColumn( 2, &forwardVec );
	axis.getColumn( 1, &upVec );
	axis.getColumn( 0, &rightVec );

   Point2I pos = getPosition();
	F32 offsetx = pos.x + 20.0;
	F32 offsety = pos.y + getExtent().y - 42.0; // Take the status bar into account
	F32 scale = 15.0;

   // Generate correct drawing order
   ColorI c1(255,0,0);
   ColorI c2(0,255,0);
   ColorI c3(0,0,255);
	ColorI tc;
	Point3F *p1, *p2, *p3, *tp;
	p1 = &rightVec;
	p2 = &upVec;
	p3 = &forwardVec;
	if(p3->y > p2->y)
	{
		tp = p2; tc = c2;
		p2 = p3; c2 = c3;
		p3 = tp; c3 = tc;
	}
	if(p2->y > p1->y)
	{
		tp = p1; tc = c1;
		p1 = p2; c1 = c2;
		p2 = tp; c2 = tc;
	}

   PrimBuild::begin( GFXLineList, 6 );
		//*** Axis 1
		PrimBuild::color(c1);
		PrimBuild::vertex3f(offsetx, offsety, 0);
		PrimBuild::vertex3f(offsetx+p1->x*scale, offsety-p1->z*scale, 0);

		//*** Axis 2
		PrimBuild::color(c2);
		PrimBuild::vertex3f(offsetx, offsety, 0);
		PrimBuild::vertex3f(offsetx+p2->x*scale, offsety-p2->z*scale, 0);

		//*** Axis 3
		PrimBuild::color(c3);
		PrimBuild::vertex3f(offsetx, offsety, 0);
		PrimBuild::vertex3f(offsetx+p3->x*scale, offsety-p3->z*scale, 0);
   PrimBuild::end();
}
开发者ID:souxiaosou,项目名称:OmniEngine.Net,代码行数:65,代码来源:editTSCtrl.cpp

示例15: _render

void SingleLightShadowMap::_render( RenderPassManager* renderPass,
                                    const SceneRenderState *diffuseState )
{
   PROFILE_SCOPE(SingleLightShadowMap_render);

   const LightMapParams *lmParams = mLight->getExtended<LightMapParams>();
   const bool bUseLightmappedGeometry = lmParams ? !lmParams->representedInLightmap || lmParams->includeLightmappedGeometryInShadow : true;

   const U32 texSize = getBestTexSize();

   if (  mShadowMapTex.isNull() ||
         mTexSize != texSize )
   {
      mTexSize = texSize;

      mShadowMapTex.set(   mTexSize, mTexSize, 
                           ShadowMapFormat, &ShadowMapProfile, 
                           "SingleLightShadowMap" );
   }

   GFXFrustumSaver frustSaver;
   GFXTransformSaver saver;

   MatrixF lightMatrix;
   calcLightMatrices( lightMatrix, diffuseState->getCameraFrustum() );
   lightMatrix.inverse();
   GFX->setWorldMatrix(lightMatrix);

   const MatrixF& lightProj = GFX->getProjectionMatrix();
   mWorldToLightProj = lightProj * lightMatrix;

   // Render the shadowmap!
   GFX->pushActiveRenderTarget();
   mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
   mTarget->attachTexture( GFXTextureTarget::DepthStencil, 
      _getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() ) );
   GFX->setActiveRenderTarget(mTarget);
   GFX->clear(GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0);

   SceneManager* sceneManager = diffuseState->getSceneManager();
   
   SceneRenderState shadowRenderState
   (
      sceneManager,
      SPT_Shadow,
      SceneCameraState::fromGFXWithViewport( diffuseState->getViewport() ),
      renderPass
   );

   shadowRenderState.getMaterialDelegate().bind( this, &LightShadowMap::getShadowMaterial );
   shadowRenderState.renderNonLightmappedMeshes( true );
   shadowRenderState.renderLightmappedMeshes( bUseLightmappedGeometry );
   shadowRenderState.setDiffuseCameraTransform( diffuseState->getCameraTransform() );
   shadowRenderState.setWorldToScreenScale( diffuseState->getWorldToScreenScale() );

   sceneManager->renderSceneNoLights( &shadowRenderState, SHADOW_TYPEMASK );

   _debugRender( &shadowRenderState );

   mTarget->resolve();
   GFX->popActiveRenderTarget();
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:62,代码来源:singleLightShadowMap.cpp


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