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


C++ Point3F类代码示例

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


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

示例1: start

bool PhysShape::castRayLocal(const Point3F &startLocal, const Point3F &endLocal, RayInfo* info)
{
    if (m_physInfo.owner)
    {
        const VectorF& scale = m_physInfo.owner->getScale();
        const MatrixF& objToWorld = m_physInfo.owner->getTransform();
        Point3F start(startLocal);
        Point3F end (endLocal);

        start.convolve(scale);
        end.convolve(scale);
        objToWorld.mulP(start);
        objToWorld.mulP(end);

        bool res = castRay(start,end,info);
        if (res && info)
        {
            info->normal = startLocal - endLocal;
            info->normal.normalize();

        }
        return res;
    }
    return false;
}
开发者ID:Bloodknight,项目名称:GMK,代码行数:25,代码来源:physShape.cpp

示例2: sizeof

void GFXDrawUtil::_drawSolidCapsule( const GFXStateBlockDesc &desc, const Point3F &center, F32 radius, F32 height, const ColorI &color, const MatrixF *xfm )
{	
   MatrixF mat;
   if ( xfm )
      mat = *xfm;      
   else
      mat = MatrixF::Identity;

   S32 numPoints = sizeof(circlePoints)/sizeof(Point2F);
   GFXVertexBufferHandle<GFXVertexPC> verts(mDevice, numPoints * 2 + 2, GFXBufferTypeVolatile);
   verts.lock();

   for (S32 i=0; i<numPoints + 1; i++)
   {
      S32 imod = i % numPoints;      
      verts[2 * i].point = Point3F( circlePoints[imod].x * radius, circlePoints[imod].y * radius, height );
      verts[2 * i].color = color;
      verts[2 * i + 1].point = Point3F( circlePoints[imod].x * radius, circlePoints[imod].y * radius, -height );
      verts[2 * i + 1].color = color;
   }

   S32 totalNumPnts = numPoints * 2 + 2;

   // Apply xfm if we were passed one.
   for ( U32 i = 0; i < totalNumPnts; i++ )
      mat.mulP( verts[i].point );

   // Apply position offset
   for ( U32 i = 0; i < totalNumPnts; i++ )
      verts[i].point += center;

   verts.unlock();

   mDevice->setStateBlockByDesc( desc );

   mDevice->setVertexBuffer( verts );
   mDevice->setupGenericShaders();

   mDevice->drawPrimitive( GFXTriangleStrip, 0, 2 * numPoints );

   Point3F sphereCenter;
   MatrixF sphereMat;

   if ( xfm )
      sphereMat = *xfm;
   else
      sphereMat = MatrixF::Identity;   

   sphereCenter.set( 0, 0, 0.5f * height );
   mat.mulV( sphereCenter );
   sphereCenter += center;

   drawSphere( desc, radius, sphereCenter, color, true, false, &sphereMat );

   sphereCenter.set( 0, 0, -0.5f * height );
   mat.mulV( sphereCenter );
   sphereCenter += center;

   drawSphere( desc, radius, sphereCenter, color, false, true, &sphereMat );
}
开发者ID:mray,项目名称:terminal-overload,代码行数:60,代码来源:gfxDrawUtil.cpp

示例3: castRay

bool AtlasGeomChunkTracer::castRay(const Point3F &start, const Point3F &end, RayInfo *info)
{
   // Don't collide if nothing's there...
   if(!mChunk->mColTree)
      return false;

   // Do our tracing math in 0..1 space, but still need filespace coordinates
   // as that's how our geometry is currently stored. So let's store off the
   // values pass, then convert them to chunkspace (0..1) so we can process
   // them normally.

   // Cache the delta of the ray, to save us some per-tri vector math later on...
   mRayDelta = end - start;
   mRayStart = start;
   mRayEnd   = end;

   // Figure scale and offset to get to chunkspace from filespace.
   mScale.set(1.0 / mChunk->mBounds.len_x(), 1.0 / mChunk->mBounds.len_y(), 1.0);
   mOffset = -mChunk->mBounds.minExtents;
   mOffset.z = 0;

   // Now, scale down to chunkspace, and cast the ray!
   Point3F adjStart = (start + mOffset);
   adjStart.convolve(mScale);

   Point3F adjEnd = (end + mOffset);
   adjEnd.convolve(mScale);

   return QuadTreeTracer::castRay(adjStart, adjEnd, info);
}
开发者ID:dodong471520,项目名称:pap,代码行数:30,代码来源:atlasGeomCollision.cpp

示例4: getScale

void TurretShape::getRenderWeaponMountTransform( F32 delta, S32 mountPoint, const MatrixF &xfm, MatrixF *outMat )
{
   // Returns mount point to world space transform
   if ( mountPoint >= 0 && mountPoint < SceneObject::NumMountPoints) {
      S32 ni = mDataBlock->weaponMountNode[mountPoint];
      if (ni != -1) {
         MatrixF mountTransform = mShapeInstance->mNodeTransforms[ni];
         mountTransform.mul( xfm );
         const Point3F& scale = getScale();

         // The position of the mount point needs to be scaled.
         Point3F position = mountTransform.getPosition();
         position.convolve( scale );
         mountTransform.setPosition( position );

         // Also we would like the object to be scaled to the model.
         mountTransform.scale( scale );
         outMat->mul(getRenderTransform(), mountTransform);
         return;
      }
   }

   // Then let SceneObject handle it.
   GrandParent::getRenderMountTransform( delta, mountPoint, xfm, outMat );   
}
开发者ID:mray,项目名称:terminal-overload,代码行数:25,代码来源:turretShape.cpp

示例5: getOriginVector

/** Resolve collision with an immovable object
   Computes & applies the collision impulse needed to keep the body
   from penetrating the given surface.
*/
bool Rigid::resolveCollision(const Point3F& p, const Point3F &normal)
{
   atRest = false;
   Point3F v,r;
   getOriginVector(p,&r);
   getVelocity(r,&v);
   F32 n = -mDot(v,normal);
   if (n >= 0.0f) {

      // Collision impulse, straight forward force stuff.
      F32 d = getZeroImpulse(r,normal);
      F32 j = n * (1.0f + restitution) * d;
      Point3F impulse = normal * j;

      // Friction impulse, calculated as a function of the
      // amount of force it would take to stop the motion
      // perpendicular to the normal.
      Point3F uv = v + (normal * n);
      F32 ul = uv.len();
      if (ul) {
         uv /= -ul;
         F32 u = ul * getZeroImpulse(r,uv);
         j *= friction;
         if (u > j)
            u = j;
         impulse += uv * u;
      }

      //
      applyImpulse(r,impulse);
   }
   return true;
}
开发者ID:Adhdcrazzy,项目名称:Torque3D,代码行数:37,代码来源:rigid.cpp

示例6: setWorldPosition

void VPathNode::updateWorldData( void )
{
    if ( !mPath )
    {
        setWorldPosition( getLocalPosition() );
        setWorldRotation( getLocalRotation() );
        return;
    }

    // Fetch Path Details.
    const MatrixF &pathTransform = mPath->getTransform();
    const QuatF   &pathRotation( pathTransform );

    // Calculate the World Position.
    Point3F newPosition = getLocalPosition();
    newPosition.convolve( mPath->getScale() );
    pathTransform.mulP( newPosition );

    // Calculate the new Rotation.
    QuatF newRotation;
    newRotation.mul( getLocalRotation(), pathRotation );

    // Apply.
    setWorldPosition( newPosition );
    setWorldRotation( newRotation );
}
开发者ID:AnteSim,项目名称:Verve,代码行数:26,代码来源:VPathNode.cpp

示例7: prepRenderImage

bool PxSingleActor::prepRenderImage(   SceneState *state,
                                          const U32 stateKey,
                                          const U32 startZone, 
                                          const bool modifyBaseState )
{
   if ( !mShapeInstance || !state->isObjectRendered(this) )
      return false;

   Point3F cameraOffset;
   getTransform().getColumn(3,&cameraOffset);
   cameraOffset -= state->getDiffuseCameraPosition();
   F32 dist = cameraOffset.len();
   if ( dist < 0.01f )
      dist = 0.01f;

   F32 invScale = (1.0f/getMax(getMax(getScale().x,getScale().y),getScale().z));
   dist *= invScale;
   S32 dl = mShapeInstance->setDetailFromDistance( state, dist );
   if (dl<0)
      return false;

   renderObject( state );

   return false;
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:25,代码来源:pxSingleActor.cpp

示例8: 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

示例9: xfm

void CloudLayer::renderObject( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mi )
{
   GFXTransformSaver saver;

   const Point3F &camPos = state->getCameraPosition();
   MatrixF xfm(true);
   xfm.setPosition(camPos);
   GFX->multWorld(xfm);   

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

   GFX->setShader( mShader );
   GFX->setShaderConstBuffer( mShaderConsts );
   GFX->setStateBlock( mStateblock );

   // Set all the shader consts...

   MatrixF xform(GFX->getProjectionMatrix());
   xform *= GFX->getViewMatrix();
   xform *= GFX->getWorldMatrix();

   mShaderConsts->setSafe( mModelViewProjSC, xform );

   mShaderConsts->setSafe( mEyePosWorldSC, camPos );

   LightInfo *lightinfo = LIGHTMGR->getSpecialLight(LightManager::slSunLightType);
   const ColorF &sunlight = state->getAmbientLightColor();

   Point3F ambientColor( sunlight.red, sunlight.green, sunlight.blue );
   mShaderConsts->setSafe( mAmbientColorSC, ambientColor );   

   const ColorF &sunColor = lightinfo->getColor();
   Point3F data( sunColor.red, sunColor.green, sunColor.blue );
   mShaderConsts->setSafe( mSunColorSC, data );

   mShaderConsts->setSafe( mSunVecSC, lightinfo->getDirection() );

   for ( U32 i = 0; i < TEX_COUNT; i++ )         
      mShaderConsts->setSafe( mTexOffsetSC[i], mTexOffset[i] );

   Point3F scale( mTexScale[0], mTexScale[1], mTexScale[2] );
   mShaderConsts->setSafe( mTexScaleSC, scale );

   Point3F color;
   color.set( mBaseColor.red, mBaseColor.green, mBaseColor.blue );
   mShaderConsts->setSafe( mBaseColorSC, color );

   mShaderConsts->setSafe( mCoverageSC, mCoverage );

   mShaderConsts->setSafe( mExposureSC, mExposure );

   GFX->setTexture( mNormalHeightMapSC->getSamplerRegister(), mTexture );                            
   GFX->setVertexBuffer( mVB );            
   GFX->setPrimitiveBuffer( mPB );

   GFX->drawIndexedPrimitive( GFXTriangleList, 0, 0, smVertCount, 0, smTriangleCount );
}
开发者ID:practicing01,项目名称:Torque3D,代码行数:58,代码来源:cloudLayer.cpp

示例10: getScale

//----------------------------------------------------------------------------
void Item::updateWorkingCollisionSet(const U32 mask, const F32 dt)
{
   // It is assumed that we will never accelerate more than 10 m/s for gravity...
   //
   Point3F scaledVelocity = mVelocity * dt;
   F32 len    = scaledVelocity.len();
   F32 newLen = len + (10 * dt);

   // Check to see if it is actually necessary to construct the new working list,
   //  or if we can use the cached version from the last query.  We use the x
   //  component of the min member of the mWorkingQueryBox, which is lame, but
   //  it works ok.
   bool updateSet = false;

   Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale());
   F32 l = (newLen * 1.1) + 0.1;  // from Convex::updateWorkingList
   convexBox.minExtents -= Point3F(l, l, l);
   convexBox.maxExtents += Point3F(l, l, l);

   // Check containment
   {
      if (mWorkingQueryBox.minExtents.x != -1e9)
      {
         if (mWorkingQueryBox.isContained(convexBox) == false)
         {
            // Needed region is outside the cached region.  Update it.
            updateSet = true;
         }
         else
         {
            // We can leave it alone, we're still inside the cached region
         }
      }
      else
      {
         // Must update
         updateSet = true;
      }
   }

   // Actually perform the query, if necessary
   if (updateSet == true)
   {
      mWorkingQueryBox = convexBox;
      mWorkingQueryBox.minExtents -= Point3F(2 * l, 2 * l, 2 * l);
      mWorkingQueryBox.maxExtents += Point3F(2 * l, 2 * l, 2 * l);

      disableCollision();
      if (mCollisionObject)
         mCollisionObject->disableCollision();

      mConvex.updateWorkingList(mWorkingQueryBox, mask);

      if (mCollisionObject)
         mCollisionObject->enableCollision();
      enableCollision();
   }
}
开发者ID:Bloodknight,项目名称:GMK,代码行数:59,代码来源:item.cpp

示例11: mountTransform

void SceneObject::getRenderMountTransform( F32 delta, S32 index, const MatrixF &xfm, MatrixF *outMat )
{
   MatrixF mountTransform( xfm );
   const Point3F &scale = getScale();
   Point3F position = mountTransform.getPosition();
   position.convolve( scale );
   mountTransform.setPosition( position );

   outMat->mul( mRenderObjToWorld, mountTransform );
}
开发者ID:mray,项目名称:terminal-overload,代码行数:10,代码来源:sceneObject.cpp

示例12: consoleError

void Point3NormalizeValidator::validateType(SimObject *object, void *typePtr)
{
    Point3F *v = (Point3F *) typePtr;
    const F32 len = v->len();
    if(!mIsEqual(len, 1.0f))
    {
        consoleError(object, "Vector length must be %g", length);
        *v *= length / len;
    }
}
开发者ID:caomw,项目名称:Torque3D,代码行数:10,代码来源:typeValidators.cpp

示例13: Point3F

void GFXCubemap::initNormalize( U32 size )
{
   Point3F axis[6] =
         {Point3F(1.0, 0.0, 0.0), Point3F(-1.0,  0.0,  0.0),
         Point3F(0.0, 1.0, 0.0), Point3F( 0.0, -1.0,  0.0),
         Point3F(0.0, 0.0, 1.0), Point3F( 0.0,  0.0, -1.0),};
   Point3F s[6] =
         {Point3F(0.0, 0.0, -1.0), Point3F( 0.0, 0.0, 1.0),
         Point3F(1.0, 0.0,  0.0), Point3F( 1.0, 0.0, 0.0),
         Point3F(1.0, 0.0,  0.0), Point3F(-1.0, 0.0, 0.0),};
   Point3F t[6] =
         {Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0,  0.0),
         Point3F(0.0,  0.0, 1.0), Point3F(0.0,  0.0, -1.0),
         Point3F(0.0, -1.0, 0.0), Point3F(0.0, -1.0,  0.0),};

   F32 span = 2.0;
   F32 start = -1.0;

   F32 stride = span / F32(size - 1);
   GFXTexHandle faces[6];

   for(U32 i=0; i<6; i++)
   {
      GFXTexHandle &tex = faces[i];
      GBitmap *bitmap = new GBitmap(size, size);

      // fill in...
      for(U32 v=0; v<size; v++)
      {
         for(U32 u=0; u<size; u++)
         {
            Point3F vector;
            vector = axis[i] +
               ((F32(u) * stride) + start) * s[i] +
               ((F32(v) * stride) + start) * t[i];
            vector.normalizeSafe();
            vector = ((vector * 0.5) + Point3F(0.5, 0.5, 0.5)) * 255.0;
            vector.x = mClampF(vector.x, 0.0f, 255.0f);
            vector.y = mClampF(vector.y, 0.0f, 255.0f);
            vector.z = mClampF(vector.z, 0.0f, 255.0f);
            // easy way to avoid knowledge of the format (RGB, RGBA, RGBX, ...)...
            U8 *bits = bitmap->getAddress(u, v);
            bits[0] = U8(vector.x);
            bits[1] = U8(vector.y);
            bits[2] = U8(vector.z);
         }
      }

      tex.set(bitmap, &GFXDefaultStaticDiffuseProfile, true, "Cubemap");
   }

   initStatic(faces);
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:53,代码来源:gfxCubemap.cpp

示例14: getLinearPosition

float Player::coverage (Point3F eye)
{
	float total = 0;
	Point3F foot = getLinearPosition () + collisionImage.sphere.center / 2;
	Point3F head = foot + collisionImage.sphere.center;
	Point3F temp;
	Point3F lshoulder;
	Point3F rshoulder;
	temp = getRot ();
	RMat3F rot (EulerF(temp.x, temp.y, temp.z));
	
	temp.set (collisionImage.bbox.fMin.x / 2, 0, 0);
	m_mul (temp, rot, &lshoulder);
	lshoulder += getLinearPosition ();
	lshoulder.z += collisionImage.sphere.center.z;
	lshoulder.z += collisionImage.sphere.center.z / 4;
	
	temp.set (collisionImage.bbox.fMax.x / 2, 0, 0);
	m_mul (temp, rot, &rshoulder);
	rshoulder += getLinearPosition ();
	rshoulder.z += collisionImage.sphere.center.z;
	rshoulder.z += collisionImage.sphere.center.z / 4;
	
	SimContainerQuery cq;
	cq.id = getId();
	cq.type = -1;
	cq.mask = SimTerrainObjectType | SimInteriorObjectType | SimPlayerObjectType | StaticObjectType;

	cq.box.fMin = eye;
	cq.box.fMax = foot;
	SimCollisionInfo info;
	SimContainer* root = findObject(manager,SimRootContainerId,(SimContainer*)0);
	bool obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = head;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = lshoulder;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	cq.box.fMax = rshoulder;
	obstructed = root->findLOS (cq, &info);
	if (!obstructed)
		total += 0.25;

	return total;
}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:53,代码来源:player.cpp

示例15: Point2F

void Scene::loop() {
	//Basic movement
	glm::mat4x4 delta = glm::mat4x4(1);

	if (movement[4]) pitch -= keyCameraSpeed;
	if (movement[5]) pitch += keyCameraSpeed;
	if (movement[6]) yaw -= keyCameraSpeed;
	if (movement[7]) yaw += keyCameraSpeed;

	delta = glm::rotate(delta, -yaw, glm::vec3(0, 0, 1));

	float speed = movementSpeed;
	if (mouseButtons[1])
		speed *= 2.f;

	Point2F move = Point2F();
	if (movement[0]) move.x -= speed;
	if (movement[1]) move.x += speed;
	if (movement[2]) move.y -= speed;
	if (movement[3]) move.y += speed;

#ifdef BUILD_PHYSICS
	glm::vec3 torque = glm::vec3(glm::translate(delta, glm::vec3(move.x, move.y, 0))[3]);
	delta = glm::rotate(delta, -pitch, glm::vec3(1, 0, 0));

	sphere->applyTorque(Point3F(torque.x, torque.y, torque.z) * 20);

	if (sphere->getColliding()) {
		Point3F normal = sphere->getCollisionNormal();
		if (movement[8] && normal.dot(Point3F(0, 0, 1)) > 0.1)
			sphere->applyImpulse((normal + Point3F(0, 0, 1)) / 2.f, Point3F(0, 0, -1));
	} else {
		sphere->applyImpulse(Point3F(torque.y, -torque.x, torque.z) / 4.f, Point3F(0, 0, 0));
	}

	Point3F pos = sphere->getPosition();
	cameraPosition = glm::vec3(pos.x, pos.y, pos.z);
	cameraPosition += glm::vec3(glm::translate(delta, glm::vec3(0, -2.5, 0))[3]);

	if (sphere->getPosition().z < difs[0]->interior[0]->boundingBox.getMin().x) {
		sphere->setPosition(Point3F(0, 30, 60));
	}
#else /* BUILD_PHYSICS */
	move *= 3;
	if (movement[8])
		move *= 2;

	delta = glm::rotate(delta, -pitch, glm::vec3(1, 0, 0));
	delta = glm::translate(delta, glm::vec3(move.y, -move.x, 0));

	cameraPosition += glm::vec3(delta[3]);
#endif /* BUILD_PHYSICS */
}
开发者ID:AbhinavJain13,项目名称:DifViewer,代码行数:53,代码来源:scene.cpp


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