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


C++ Point3F::normalize方法代码示例

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


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

示例1: interpolateTick

void Projectile::interpolateTick(F32 delta)
{
   Parent::interpolateTick(delta);

   if( mHasExploded )
      return;

   Point3F interpPos = mCurrDeltaBase + mCurrBackDelta * delta;
   Point3F dir = mCurrVelocity;
   if(dir.isZero())
      dir.set(0,0,1);
   else
      dir.normalize();

   MatrixF xform(true);
	xform = MathUtils::createOrientFromDir(dir);
   xform.setPosition(interpPos);
   setRenderTransform(xform);

   // fade out the projectile image
   S32 time = (S32)(mCurrTick - delta);
   if(time > mDataBlock->fadeDelay)
   {
      F32 fade = F32(time - mDataBlock->fadeDelay);
      mFadeValue = 1.0 - (fade / F32(mDataBlock->lifetime));
   }
   else
      mFadeValue = 1.0;

   updateSound();
}
开发者ID:AlkexGas,项目名称:Torque3D,代码行数:31,代码来源:projectile.cpp

示例2: updateCameraPos

void Etherform::updateCameraPos(F32 delta)
{
	//
	// Update 3rd person camera position.
	//

	F32 min,max;
	Point3F offset;
	MatrixF rot;
	this->getCameraParameters(&min,&max,&offset,&rot);

	Point3F vec = mCameraTargetPos - mCameraPos;
	F32    dist = vec.len();

	if(dist == 0)
	{
		// Catch camera position up to its target position.
		mCameraPos = mCameraTargetPos;
	}
	else if(dist > max)
	{
		// Catch camera up to max allowed dist from target position.
		vec.normalize(); vec.neg();
		mCameraPos = mCameraTargetPos + vec * max;
	}
	else
	{
		// Move camera pos towards its target pos.
#if 0
		F32 speed = mDataBlock->accelerationForce;
		speed *= 1 - (1/vec.lenSquared());

		vec.normalize();
		mCameraPos += vec * speed * delta;
#else
		//F32 speedScale = this->getVelocity().len() / mDataBlock->accelerationForce;
		F32 speedScale = 4; //mDataBlock->accelerationForce / 2;
		F32 distScale = 1 - (1/vec.lenSquared());
		vec *= speedScale * distScale * delta;
		if(vec.len() > dist)
			mCameraPos = mCameraTargetPos;
		else
			mCameraPos += vec;
#endif
	}
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:46,代码来源:etherform.cpp

示例3: calculateLookDirMat

void PathCamera::calculateLookDirMat(Point3F dir)
{
	mLookDirMat.identity();

	if(dir == Point3F(0.f, 0.f, 0.f))
	{
		mUseLookDirMatrix = false;
		return;
	}

	Point3F left = mCross(dir, Point3F(0.f, 0.f, 1.f));
	left.normalize();
	Point3F up = mCross(left, dir);
	up.normalize();

	mLookDirMat.setColumn(0, Point4F(left.x, left.y, left.z, 0.f));			
	mLookDirMat.setColumn(1, Point4F(dir.x, dir.y, dir.z, 0.f));	
	mLookDirMat.setColumn(2, Point4F(up.x, up.y, up.z, 0.f));		

	mUseLookDirMatrix = true;	
}
开发者ID:Bloodknight,项目名称:T3D-MIT-GMK-Port,代码行数:21,代码来源:pathCamera.cpp

示例4: getFrustumClipProj

MatrixF PlaneReflector::getFrustumClipProj( MatrixF &modelview )
{
   static MatrixF rotMat(EulerF( static_cast<F32>(M_PI / 2.f), 0.0, 0.0));
   static MatrixF invRotMat(EulerF( -static_cast<F32>(M_PI / 2.f), 0.0, 0.0));


   MatrixF revModelview = modelview;
   revModelview = rotMat * revModelview;  // add rotation to modelview because it needs to be removed from projection

   // rotate clip plane into modelview space
   Point4F clipPlane;
   Point3F pnt = refplane * -(refplane.d + 0.0 );
   Point3F norm = refplane;

   revModelview.mulP( pnt );
   revModelview.mulV( norm );
   norm.normalize();

   clipPlane.set( norm.x, norm.y, norm.z, -mDot( pnt, norm ) );


   // Manipulate projection matrix
   //------------------------------------------------------------------------
   MatrixF proj = GFX->getProjectionMatrix();
   proj.mul( invRotMat );  // reverse rotation imposed by Torque
   proj.transpose();       // switch to row-major order

   // Calculate the clip-space corner point opposite the clipping plane
   // as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and
   // transform it into camera space by multiplying it
   // by the inverse of the projection matrix
   Vector4F	q;
   q.x = sgn(clipPlane.x) / proj(0,0);
   q.y = sgn(clipPlane.y) / proj(1,1);
   q.z = -1.0F;
   q.w = ( 1.0F - proj(2,2) ) / proj(3,2);

   F32 a = 1.0 / (clipPlane.x * q.x + clipPlane.y * q.y + clipPlane.z * q.z + clipPlane.w * q.w);

   Vector4F c = clipPlane * a;

   // CodeReview [ags 1/23/08] Come up with a better way to deal with this.
   if(GFX->getAdapterType() == OpenGL)
      c.z += 1.0f;

   // Replace the third column of the projection matrix
   proj.setColumn( 2, c );
   proj.transpose(); // convert back to column major order
   proj.mul( rotMat );  // restore Torque rotation

   return proj;
}
开发者ID:AlkexGas,项目名称:Torque3D,代码行数:52,代码来源:reflector.cpp

示例5: setLookDir

//.logicking >>
void PathCamera::setLookDir(Point3F dir)
{
	if(dir == Point3F(0.f, 0.f, 0.f))
	{
		mLookDirVector = dir;	
		setMaskBits(LookDirVectorMask);
	}
	else
	{
		dir.normalize();	
		mLookDirVector = dir;	
		calculateLookDirMat(mLookDirVector);
		setMaskBits(LookDirVectorMask);
	}	
}
开发者ID:Bloodknight,项目名称:T3D-MIT-GMK-Port,代码行数:16,代码来源:pathCamera.cpp

示例6: updateRing

//----------------------------------------------------------------------------
// Update ring
//----------------------------------------------------------------------------
void Splash::updateRing( SplashRing& ring, F32 dt )
{
   for( U32 i=0; i<ring.points.size(); i++ )
   {
      if( mDead )
      {
         Point3F vel = ring.points[i].velocity;
         vel.normalize();
         vel *= mDataBlock->acceleration;
         ring.points[i].velocity += vel * dt;
      }

      ring.points[i].velocity += Point3F( 0.0f, 0.0f, -9.8f ) * dt;
      ring.points[i].position += ring.points[i].velocity * dt;
   }
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:19,代码来源:splash.cpp

示例7: createRing

//----------------------------------------------------------------------------
// Create ring
//----------------------------------------------------------------------------
SplashRing Splash::createRing()
{
   SplashRing ring;
   U32 numPoints = mDataBlock->numSegments + 1;

   Point3F ejectionAxis( 0.0, 0.0, 1.0 );

   Point3F axisx;
   if (mFabs(ejectionAxis.z) < 0.999f)
      mCross(ejectionAxis, Point3F(0, 0, 1), &axisx);
   else
      mCross(ejectionAxis, Point3F(0, 1, 0), &axisx);
   axisx.normalize();

   for( U32 i=0; i<numPoints; i++ )
   {
      F32 t = F32(i) / F32(numPoints);

      AngAxisF thetaRot( axisx, mDataBlock->ejectionAngle * (M_PI / 180.0));
      AngAxisF phiRot(   ejectionAxis, t * (M_PI * 2.0));

      Point3F pointAxis = ejectionAxis;

      MatrixF temp;
      thetaRot.setMatrix(&temp);
      temp.mulP(pointAxis);
      phiRot.setMatrix(&temp);
      temp.mulP(pointAxis);

      Point3F startOffset = axisx;
      temp.mulV( startOffset );
      startOffset *= mDataBlock->startRadius;

      SplashRingPoint point;
      point.position = getPosition() + startOffset;
      point.velocity = pointAxis * mDataBlock->velocity;

      ring.points.push_back( point );
   }

   ring.color = mDataBlock->colors[0];
   ring.lifetime = mDataBlock->ringLifetime;
   ring.elapsedTime = 0.0;
   ring.v = mDataBlock->texFactor * mFmod( mElapsedTime, 1.0 );

   return ring;
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:50,代码来源:splash.cpp

示例8: calculateAim

void PathCamera::calculateAim(Point3F currentPosition)
{
	if(mAimTarget == -1 && mAimOffset == Point3F(0.f, 0.f, 0.f))	
	{
		calculateLookDirMat(mLookDirVector);
		return;
	}

	Point3F dir = mAimOffset;

	if(mAimTarget > 0)
	{	
		SceneObject* obj = NULL;
		Sim::findObject(mAimTarget, obj);
		if(obj)
			dir += obj->getPosition();
	}

	dir = dir - currentPosition;
	dir.normalize();
	calculateLookDirMat(dir);
}
开发者ID:Bloodknight,项目名称:T3D-MIT-GMK-Port,代码行数:22,代码来源:pathCamera.cpp

示例9: computeNormals

void AppMesh::computeNormals()
{
   // Clear normals
   normals.setSize( points.size() );
   for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
      normals[iNorm] = Point3F::Zero;

   // Sum triangle normals for each vertex
   for (S32 iPrim = 0; iPrim < primitives.size(); iPrim++)
   {
      const TSDrawPrimitive& prim = primitives[iPrim];

      for (S32 iInd = 0; iInd < prim.numElements; iInd += 3)
      {
         // Compute the normal for this triangle
         S32 idx0 = indices[prim.start + iInd + 0];
         S32 idx1 = indices[prim.start + iInd + 1];
         S32 idx2 = indices[prim.start + iInd + 2];

         const Point3F& v0 = points[idx0];
         const Point3F& v1 = points[idx1];
         const Point3F& v2 = points[idx2];

         Point3F n;
         mCross(v2 - v0, v1 - v0, &n);
         n.normalize();    // remove this to use 'weighted' normals (large triangles will have more effect)

         normals[idx0] += n;
         normals[idx1] += n;
         normals[idx2] += n;
      }
   }

   // Normalize the vertex normals (this takes care of averaging the triangle normals)
   for (S32 iNorm = 0; iNorm < normals.size(); iNorm++)
      normals[iNorm].normalize();
}
开发者ID:campadrenalin,项目名称:terminal-overload,代码行数:37,代码来源:appMesh.cpp

示例10: _debugRender

void ScatterSky::_debugRender( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
   GFXStateBlockDesc desc;
   desc.fillMode = GFXFillSolid;
   desc.setBlend( false, GFXBlendOne, GFXBlendZero );
   desc.setZReadWrite( false, false );
   GFXStateBlockRef sb = GFX->GFX->createStateBlock( desc );

   GFX->setStateBlock( sb );

   PrimBuild::begin( GFXLineStrip, mSkyPoints.size() );
   PrimBuild::color3i( 255, 0, 255 );

   for ( U32 i = 0; i < mSkyPoints.size(); i++ )
   {
      Point3F pnt = mSkyPoints[i];
      pnt.normalize();
      pnt *= 500;
      pnt += state->getCameraPosition();
      PrimBuild::vertex3fv( pnt );
   }

   PrimBuild::end();
}
开发者ID:AkiraofAstra,项目名称:Torque3D,代码行数:24,代码来源:scatterSky.cpp

示例11: load

void SimPlanet::load()
{
   unload();
   
   if ((textureTag != 0) && (!manager->isServer())) {
      ResourceManager &rm = *SimResource::get(manager);
      const char *filename = SimTagDictionary::getString(manager, textureTag);
   
      // load the texture
      hTexture = rm.load(filename);
      AssertWarn((bool)hTexture, 
         avar("Error reading bitmap file \"%s\"", filename));
      // don't want to assert fatal because we don't want to bring down
      // the mission editor
      if ((bool)hTexture) {
         planet.texture = (GFXBitmap *)hTexture;
         addToSet(SimRenderSetId);
         inRenderSet = true;
      }         
   }   
   else
      planet.texture = NULL;

   // calculate planet position in world coordinates
   // add 90 to azimuth so that zero is at up Y axis
   if (incidence > 89.0f)
      incidence = 89.0f;
   if (incidence < -89.0f)
      incidence = -89.0f;
   const float az = azimuth + 90.0f;
   const float c = planet.distance*m_cos(DEGRAD*incidence);
   planet.position = Point3F(c*m_cos(DEGRAD*az), c*m_sin(DEGRAD*az), planet.distance*m_sin(DEGRAD*incidence));

   // initialize light if any
   Point3F direction = planet.position;
   direction.normalize();
   direction *= -1.0f;

   if (castShadows) {
      // set static data items
      shadowDirection = direction;
      shadows = true;
   }


   light.setAim(direction);
   //light.setType(TS::Light::LightDirectional);
   light.setType(TS::Light::LightDirectionalWrap);
   light.setIntensity(intensity.red, intensity.green, intensity.blue);
   if (intensity.red > 0.0f || intensity.green > 0.0f || intensity.blue > 0.0f 
      || ambient.red > 0.0f || ambient.green > 0.0f || ambient.blue > 0.0f) {
      addToSet(SimLightSetId);
      inLightSet = true;
      lensFlare.setColor(intensity);
   }
   planet.lensFlare = useLensFlare ? &lensFlare : NULL;

   // initialize static texture coordinates
   textCoord[0].x = 0.0f;  textCoord[0].y = 0.0f;
   textCoord[1].x = 1.0f;  textCoord[1].y = 0.0f;
   textCoord[2].x = 1.0f;  textCoord[2].y = 1.0f;
   textCoord[3].x = 0.0f;  textCoord[3].y = 1.0f;

   setMaskBits(Modified);
}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:65,代码来源:simPlanet.cpp

示例12: preRenderShadow

void BaseShadowRenderImage::preRenderShadow(TSRenderContext & rc, float curTime)
{
   if (!castShadow)
      return;
      
	// do visibility check for shadow
   Point3F center;
   m_mul(shape->getShape().fCenter,transform,&center);
	SphereF shadowSphere = SphereF(center,shape->getShape().fRadius);
	int shadowVis = rc.getCamera()->testVisibility(shadowSphere);
	if ( shadowVis==TS::ClipNoneVis )
   {
      shadowSettings.shadowDetail = -1;
      return;
   }

   // shape detail to use for shadows
   if (!shadowOwnDetail)
   {
      projSize = rc.getCamera()->transformProjectRadius( center, shape->getShape().fRadius );
      float adjustedSize = shadowDetailScale * projSize;
                           
      shadowSettings.shadowDetail = shape->getShape().selectDetail( adjustedSize );

      if (shadowSettings.shadowDetail==-1)
         return;
   }

   // first pass at shadow details
   setShadowDetailsA(rc);

   // set shadow details may veto shadow
   if (shadowSettings.shadowDetail==-1)
      return;

   // set light direction, but only if different than before
   Point3F * pLight = &lightDirection;
   Point3F tempDirection;
   if (swingDown != 0.0f)
   {
      tempDirection = (lightDirection * (1.0f - swingDown)) + (Point3F(0, 0, -1) * swingDown);
      tempDirection.normalize();
      pLight = &tempDirection;
   }
   if (m_dot(*pLight,lastLight) < 0.999)
   {
      shadow.setLight( *pLight, shape);
      lastLight = *pLight;
      nextShadowUpdateTime = -1;
   }

   // set position of shadow
   shadow.setPosition(transform.p);

   if (shadowSettings.cacheProjection)
   {
      if (shadowSettings.recacheProjection)
      {
         shadow.calcSourceWindow(shape,transform);
         getPolys();
         shadow.cachePolys();
         shadowSettings.recacheProjection = false;
      }
   }
   else
   {
      shadow.calcSourceWindow(shape,transform);
      getPolys();
      Point3F cc = rc.getCamera()->getTCW().p;
      Point3F camY = transform.p-cc;
      camY.normalize();
      shadow.getPlanes(cc,camY);
   }
   
   setShadowDetails(rc);
   
   // set shadow details may veto shadow
   if (shadowSettings.shadowDetail==-1)
      return;

   if (shadowSettings.shadowDetail < shadowSettings.hiShadowDetail)
      shadowSettings.shadowDetail = shadowSettings.hiShadowDetail;

   // adjust next update time...
   nextShadowUpdateTime += shadowSettings.updateDelta - prevShadowUpdateDelta;
   prevShadowUpdateDelta = shadowSettings.updateDelta;

   // adjust bmp dim...
   int newBmpDim = shadowSettings.bmpDim;
   if (newBmpDim != prevBmpDim)
   {
      prevBmpDim = newBmpDim;
      shadow.setBitmapSize(deviceManager.getGFXDeviceManager(),newBmpDim,rc.getSurface());
      nextShadowUpdateTime = -1;
   }

   shadow.setAlphaLevel(alphaLevel);

   // create the shadow bitmap if needed
   if (curTime > nextShadowUpdateTime)
//.........这里部分代码省略.........
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:101,代码来源:baseShadowRenderImage.cpp

示例13: _initBuffers

void CloudLayer::_initBuffers()
{      
   // Vertex Buffer...

   Point3F vertScale( 16.0f, 16.0f, mHeight );
   F32 zOffset = -( mCos( mSqrt( 1.0f ) ) + 0.01f );
   
   mVB.set( GFX, smVertCount, GFXBufferTypeStatic );   
   GFXCloudVertex *pVert = mVB.lock(); 
   if(!pVert) return;

   for ( U32 y = 0; y < smVertStride; y++ )
   {
      F32 v = ( (F32)y / (F32)smStrideMinusOne - 0.5f ) * 2.0f;

      for ( U32 x = 0; x < smVertStride; x++ )
      {
         F32 u = ( (F32)x / (F32)smStrideMinusOne - 0.5f ) * 2.0f;

         F32 sx = u;
         F32 sy = v;
         F32 sz = mCos( mSqrt( sx*sx + sy*sy ) ) + zOffset;
         //F32 sz = 1.0f;
         pVert->point.set( sx, sy, sz );
         pVert->point *= vertScale;

         // The vert to our right.
         Point3F rpnt;

         F32 ru = ( (F32)( x + 1 ) / (F32)smStrideMinusOne - 0.5f ) * 2.0f;
         F32 rv = v;

         rpnt.x = ru;
         rpnt.y = rv;
         rpnt.z = mCos( mSqrt( rpnt.x*rpnt.x + rpnt.y*rpnt.y ) ) + zOffset;
         rpnt *= vertScale;

         // The vert to our front.
         Point3F fpnt;

         F32 fu = u;
         F32 fv = ( (F32)( y + 1 ) / (F32)smStrideMinusOne - 0.5f ) * 2.0f;

         fpnt.x = fu;
         fpnt.y = fv;
         fpnt.z = mCos( mSqrt( fpnt.x*fpnt.x + fpnt.y*fpnt.y ) ) + zOffset;
         fpnt *= vertScale;

         Point3F fvec = fpnt - pVert->point;
         fvec.normalize();

         Point3F rvec = rpnt - pVert->point;
         rvec.normalize();

         pVert->normal = mCross( fvec, rvec );
         pVert->normal.normalize();
         pVert->binormal = fvec;
         pVert->tangent = rvec;
         pVert->texCoord.set( u, v );   
         pVert++;
      }
   }

   mVB.unlock();


   // Primitive Buffer...   

   mPB.set( GFX, smTriangleCount * 3, smTriangleCount, GFXBufferTypeStatic );

   U16 *pIdx = NULL;   
   mPB.lock(&pIdx);     
   U32 curIdx = 0; 

   for ( U32 y = 0; y < smStrideMinusOne; y++ )
   {
      for ( U32 x = 0; x < smStrideMinusOne; x++ )
      {
         U32 offset = x + y * smVertStride;

         pIdx[curIdx] = offset;
         curIdx++;
         pIdx[curIdx] = offset + 1;
         curIdx++;
         pIdx[curIdx] = offset + smVertStride + 1;
         curIdx++;

         pIdx[curIdx] = offset;
         curIdx++;
         pIdx[curIdx] = offset + smVertStride + 1;
         curIdx++;
         pIdx[curIdx] = offset + smVertStride;
         curIdx++;
      }
   }

   mPB.unlock();   
}
开发者ID:practicing01,项目名称:Torque3D,代码行数:98,代码来源:cloudLayer.cpp

示例14: _calcPlanesCullForShadowCasters

void PSSMLightShadowMap::_calcPlanesCullForShadowCasters(Vector< Vector<PlaneF> > &out, const Frustum &viewFrustum, const Point3F &_ligthDir)
{

#define ENABLE_CULL_ASSERT

   PROFILE_SCOPE(PSSMLightShadowMap_render_getCullFrustrum);

   Point3F ligthDir = _ligthDir;
   PlaneF lightFarPlane, lightNearPlane;
   MatrixF lightFarPlaneMat(true);
   MatrixF invLightFarPlaneMat(true);

   // init data
   {
      ligthDir.normalize();
      Point3F viewDir = viewFrustum.getTransform().getForwardVector();
      viewDir.normalize();
      const Point3F viewPosition = viewFrustum.getPosition();
      const F32 viewDistance = viewFrustum.getBounds().len();
      lightNearPlane = PlaneF(viewPosition + (viewDistance * -ligthDir), ligthDir);

      const Point3F lightFarPlanePos = viewPosition + (viewDistance * ligthDir);
      lightFarPlane = PlaneF(lightFarPlanePos, -ligthDir);

      lightFarPlaneMat = MathUtils::createOrientFromDir(-ligthDir);
      lightFarPlaneMat.setPosition(lightFarPlanePos);
      lightFarPlaneMat.invertTo(&invLightFarPlaneMat);
   }

   Vector<Point2F> projVertices;

   //project all frustum vertices into plane
   // all vertices are 2d and local to far plane
   projVertices.setSize(8);
   for (int i = 0; i < 8; ++i) //
   {
      const Point3F &point = viewFrustum.getPoints()[i];
#ifdef ENABLE_CULL_ASSERT
      AssertFatal( PlaneF::Front == lightNearPlane.whichSide(point), "" );
      AssertFatal( PlaneF::Front == lightFarPlane.whichSide(point), "" );
#endif

      Point3F localPoint(lightFarPlane.project(point));
      invLightFarPlaneMat.mulP(localPoint);
      projVertices[i] = Point2F(localPoint.x, localPoint.z);
   }

   //create hull arround projected proints
   Vector<Point2F> hullVerts;
   MathUtils::mBuildHull2D(projVertices, hullVerts);

   Vector<PlaneF> planes;
   planes.push_back(lightNearPlane);
   planes.push_back(lightFarPlane);

   //build planes
   for (int i = 0; i < (hullVerts.size() - 1); ++i)
   {
      Point2F pos2D = (hullVerts[i] + hullVerts[i + 1]) / 2;
      Point3F pos3D(pos2D.x, 0, pos2D.y);

      Point3F pos3DA(hullVerts[i].x, 0, hullVerts[i].y);
      Point3F pos3DB(hullVerts[i + 1].x, 0, hullVerts[i + 1].y);

      // move hull points to 3d space
      lightFarPlaneMat.mulP(pos3D);
      lightFarPlaneMat.mulP(pos3DA);
      lightFarPlaneMat.mulP(pos3DB);

      PlaneF plane(pos3D, MathUtils::mTriangleNormal(pos3DB, pos3DA, (pos3DA - ligthDir)));
      planes.push_back(plane);
   }

   //recalculate planes for each splits
   for (int split = 0; split < mNumSplits; ++split)
   {
      Frustum subFrustum(viewFrustum);
      subFrustum.cropNearFar(mSplitDist[split], mSplitDist[split + 1]);
      subFrustum.setFarDist(getMin(subFrustum.getFarDist()*2.5f, viewFrustum.getFarDist()));
      subFrustum.update();

      Vector<PlaneF> subPlanes = planes;

      for (int planeIdx = 0; planeIdx < subPlanes.size(); ++planeIdx)
      {
         PlaneF &plane = subPlanes[planeIdx];
         F32 minDist = 0;

         //calculate near vertex distance
         for (int vertexIdx = 0; vertexIdx < 8; ++vertexIdx)
         {
            Point3F point = subFrustum.getPoints()[vertexIdx];
            minDist = getMin(plane.distToPlane(point), minDist);
         }

         // move plane to near vertex
         Point3F newPos = plane.getPosition() + (plane.getNormal() * minDist);
         plane = PlaneF(newPos, plane.getNormal());

#ifdef ENABLE_CULL_ASSERT
//.........这里部分代码省略.........
开发者ID:03050903,项目名称:Torque3D,代码行数:101,代码来源:pssmLightShadowMap.cpp

示例15: getMove

Move HoverPodController::getMove(ShapeBase* obj)
{
	Move retMove = NullMove;

	GameConnection* client = NULL;
	if(!Sim::findObject(mClientId, client)) 
		return retMove;

	ShapeBase* control = client->getControlObject();
	if(control)
	{
		Move cMove = client->lastReceivedMove();

		Point3F v1, v2;
		control->getTransform().getColumn(0, &v1);
		control->getTransform().getColumn(1, &v2);
		Point3F pv = v1*cMove.x + v2*cMove.y;

		//pv = mDirection * mDot(pv, mDirection);

		obj->getTransform().getColumn(0, &v1);
		obj->getTransform().getColumn(1, &v2);
		retMove.x = mDot(v1, pv);
		retMove.y = mDot(v2, pv);
	}
	return retMove;
	
#if 0
   if(this->isServerObject() && this->isMounted())
   {
		Move mMove = NullMove;
		ShapeBase* mount = this->getObjectMount();
		if(mount->getType() & VehicleObjectType)
		{
			Vehicle* vehicle = (Vehicle*)mount;
			if(move && move->x != 0)
			{
				mMove.yaw = move->x;
			}
			else
			{
				Point3F zv; vehicle->getTransform().getColumn(2, &zv);
				zv.normalize();
				Point3F m = vehicle->getRigid().angMomentum;
				//Point3F v = vehicle->getRigid().angVelocity;
				F32 dot = mDot(zv, m);
				//Con::printf("%f / %f %f %f / %f %f %f", dot,
				//	m.x, m.y, m.z, v.x, v.y, v.z);
				mMove.yaw = dot / 50;
			}

			if(move)
				mMove.y = move->y;

		}
		else if(move)
		{
			Point3F v1, v2;
			this->getTransform().getColumn(0, &v1);
			this->getTransform().getColumn(1, &v2);
			Point3F pv = v1*move->x + v2*move->y;

			mount->getTransform().getColumn(0, &v1);
			mount->getTransform().getColumn(1, &v2);

			mMove.x = mDot(v1, pv);
			mMove.y = mDot(v2, pv);
		}
		mount->processTick(&mMove);
   }
#endif
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:71,代码来源:serverSideControl.cpp


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