本文整理汇总了C++中MatrixF::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixF::scale方法的具体用法?C++ MatrixF::scale怎么用?C++ MatrixF::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixF
的用法示例。
在下文中一共展示了MatrixF::scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepBatchRender
void Projectile::prepBatchRender( SceneRenderState *state )
{
if ( !mProjectileShape )
return;
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
// We might have some forward lit materials
// so pass down a query to gather lights.
LightQuery query;
query.init( getWorldSphere() );
rdata.setLightQuery( &query );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
mat.scale( mDataBlock->scale );
GFX->setWorldMatrix( mat );
mProjectileShape->setDetailFromPosAndScale( state, mat.getPosition(), mObjScale );
mProjectileShape->animate();
mProjectileShape->render( rdata );
}
示例2: 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);
}
示例3: getNodeTransform
/// Get the world transform of the node at the specified time
MatrixF ColladaAppNode::getNodeTransform(F32 time)
{
// Avoid re-computing the default transform if possible
if (defaultTransformValid && time == TSShapeLoader::DefaultTime)
{
return defaultNodeTransform;
}
else
{
MatrixF nodeTransform = getTransform(time);
// Check for inverted node coordinate spaces => can happen when modelers
// use the 'mirror' tool in their 3d app. Shows up as negative <scale>
// transforms in the collada model.
if (m_matF_determinant(nodeTransform) < 0.0f)
{
// Mark this node as inverted so we can mirror mesh geometry, then
// de-invert the transform matrix
invertMeshes = true;
nodeTransform.scale(Point3F(1, 1, -1));
}
// Cache the default transform
if (time == TSShapeLoader::DefaultTime)
{
defaultTransformValid = true;
defaultNodeTransform = nodeTransform;
}
return nodeTransform;
}
}
示例4: _renderObject
void SceneSpace::_renderObject( ObjectRenderInst* ri, SceneRenderState* state, BaseMatInstance* overrideMat )
{
if( overrideMat )
return;
if( !mEditorRenderMaterial )
{
// We have no material for rendering so just render
// a plain box.
GFXTransformSaver saver;
MatrixF mat = getRenderTransform();
mat.scale( getScale() );
GFX->multWorld( mat );
GFXStateBlockDesc desc;
desc.setZReadWrite( true, false );
desc.setBlend( true );
desc.setCullMode( GFXCullNone );
GFXDrawUtil *drawer = GFX->getDrawUtil();
drawer->drawCube( desc, mObjBox, _getDefaultEditorSolidColor() );
// Render black wireframe.
desc.setFillModeWireframe();
drawer->drawCube( desc, mObjBox, _getDefaultEditorWireframeColor() );
}
else
{
//RDTODO
}
}
示例5: getRenderWeaponMountTransform
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 );
}
示例6: renderObject
void Trigger::renderObject( ObjectRenderInst *ri,
SceneRenderState *state,
BaseMatInstance *overrideMat )
{
if(overrideMat)
return;
GFXStateBlockDesc desc;
desc.setZReadWrite( true, false );
desc.setBlend( true );
// Trigger polyhedrons are set up with outward facing normals and CCW ordering
// so can't enable backface culling.
desc.setCullMode( GFXCullNone );
GFXTransformSaver saver;
MatrixF mat = getRenderTransform();
mat.scale( getScale() );
GFX->multWorld( mat );
GFXDrawUtil *drawer = GFX->getDrawUtil();
drawer->drawPolyhedron( desc, mTriggerPolyhedron, ColorI( 255, 192, 0, 45 ) );
// Render wireframe.
desc.setFillModeWireframe();
drawer->drawPolyhedron( desc, mTriggerPolyhedron, ColorI::BLACK );
}
示例7: zapScale
void TSShapeLoader::zapScale(MatrixF& mat)
{
Point3F invScale = mat.getScale();
invScale.x = invScale.x ? (1.0f / invScale.x) : 0;
invScale.y = invScale.y ? (1.0f / invScale.y) : 0;
invScale.z = invScale.z ? (1.0f / invScale.z) : 0;
mat.scale(invScale);
}
示例8: findClosestState
CollisionState* Convex::findClosestState(const MatrixF& mat, const Point3F& scale, const F32 dontCareDist)
{
PROFILE_SCOPE( Convex_FindClosestState );
updateStateList(mat, scale);
F32 dist = +1E30f;
CollisionState *st = 0;
// Prepare scaled version of transform
MatrixF axform = mat;
axform.scale(scale);
MatrixF axforminv(true);
MatrixF temp(mat);
axforminv.scale(Point3F(1.0f/scale.x, 1.0f/scale.y, 1.0f/scale.z));
temp.affineInverse();
axforminv.mul(temp);
for (CollisionStateList* itr = mList.mNext; itr != &mList; itr = itr->mNext)
{
CollisionState* state = itr->mState;
if (state->mLista != itr)
state->swap();
// Prepare scaled version of transform
MatrixF bxform = state->b->getTransform();
temp = bxform;
Point3F bscale = state->b->getScale();
bxform.scale(bscale);
MatrixF bxforminv(true);
bxforminv.scale(Point3F(1.0f/bscale.x, 1.0f/bscale.y, 1.0f/bscale.z));
temp.affineInverse();
bxforminv.mul(temp);
//
F32 dd = state->distance(axform, bxform, dontCareDist, &axforminv, &bxforminv);
if (dd < dist)
{
dist = dd;
st = state;
}
}
if (dist < dontCareDist)
return st;
else
return NULL;
}
示例9: drawSphere
void GFXDrawUtil::drawSphere( const GFXStateBlockDesc &desc, F32 radius, const Point3F &pos, const ColorI &color, bool drawTop, bool drawBottom, const MatrixF *xfm )
{
MatrixF mat;
if ( xfm )
mat = *xfm;
else
mat = MatrixF::Identity;
mat.scale(Point3F(radius,radius,radius));
mat.setPosition(pos);
GFX->pushWorldMatrix();
GFX->multWorld(mat);
const SphereMesh::TriangleMesh * sphereMesh = gSphere.getMesh(2);
S32 numPoly = sphereMesh->numPoly;
S32 totalPoly = 0;
GFXVertexBufferHandle<GFXVertexPC> verts(mDevice, numPoly*3, GFXBufferTypeVolatile);
verts.lock();
S32 vertexIndex = 0;
for (S32 i=0; i<numPoly; i++)
{
if (!drawBottom)
{
if (sphereMesh->poly[i].pnt[0].z < -0.01f || sphereMesh->poly[i].pnt[1].z < -0.01f || sphereMesh->poly[i].pnt[2].z < -0.01f)
continue;
}
if (!drawTop)
{
if (sphereMesh->poly[i].pnt[0].z > 0.01f || sphereMesh->poly[i].pnt[1].z > 0.01f || sphereMesh->poly[i].pnt[2].z > 0.01f)
continue;
}
totalPoly++;
verts[vertexIndex].point = sphereMesh->poly[i].pnt[0];
verts[vertexIndex].color = color;
vertexIndex++;
verts[vertexIndex].point = sphereMesh->poly[i].pnt[1];
verts[vertexIndex].color = color;
vertexIndex++;
verts[vertexIndex].point = sphereMesh->poly[i].pnt[2];
verts[vertexIndex].color = color;
vertexIndex++;
}
verts.unlock();
mDevice->setStateBlockByDesc( desc );
mDevice->setVertexBuffer( verts );
mDevice->setupGenericShaders();
mDevice->drawPrimitive( GFXTriangleList, 0, totalPoly );
GFX->popWorldMatrix();
}
示例10: _renderNormals
void TSStatic::_renderNormals( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
PROFILE_SCOPE( TSStatic_RenderNormals );
GFXTransformSaver saver;
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
GFX->multWorld( mat );
S32 dl = mShapeInstance->getCurrentDetail();
mShapeInstance->renderDebugNormals( mRenderNormalScalar, dl );
}
示例11: prepBatchRender
void Projectile::prepBatchRender( SceneState *state )
{
GFXTransformSaver saver;
// Set up our TS render state.
TSRenderState rdata;
rdata.setSceneState( state );
MatrixF mat = getRenderTransform();
mat.scale( mObjScale );
mat.scale( mDataBlock->scale );
GFX->setWorldMatrix( mat );
if(mProjectileShape)
{
AssertFatal(mProjectileShape != NULL,
"Projectile::renderObject: Error, projectile shape should always be present in renderObject");
mProjectileShape->setDetailFromPosAndScale( state, mat.getPosition(), mObjScale );
mProjectileShape->animate();
mProjectileShape->render( rdata );
}
}
示例12: render
void MetaShapeRenderer::render( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat )
{
if ( overrideMat )
return;
PROFILE_SCOPE(MetaShapeRenderer_Render);
mPolyList.render();
if ( mVertexBuffer.isNull() )
return;
// Set up a GFX debug event (this helps with debugging rendering events in external tools)
GFXDEBUGEVENT_SCOPE( MetaShapeRenderer_Render, ColorI::RED );
// GFXTransformSaver is a handy helper class that restores
// the current GFX matrices to their original values when
// it goes out of scope at the end of the function
GFXTransformSaver saver;
// Calculate our object to world transform matrix
MatrixF objectToWorld = getRenderTransform();
objectToWorld.scale( getScale() );
// Apply our object transform
GFX->multWorld( objectToWorld );
// Deal with reflect pass otherwise
// set the normal StateBlock
if ( state->isReflectPass() )
GFX->setStateBlock( mReflectSB );
else
GFX->setStateBlock( mNormalSB );
// Set up the "generic" shaders
// These handle rendering on GFX layers that don't support
// fixed function. Otherwise they disable shaders.
GFX->setupGenericShaders( GFXDevice::GSModColorTexture );
// Set the vertex buffer
GFX->setVertexBuffer( mVertexBuffer );
// Draw our triangles
GFX->drawPrimitive( GFXTriangleList, 0, 12 );
}
示例13: _drawWireCapsule
void GFXDrawUtil::_drawWireCapsule( const GFXStateBlockDesc &desc, const Point3F ¢er, F32 radius, F32 height, const ColorI &color, const MatrixF *xfm )
{
MatrixF mat;
if ( xfm )
mat = *xfm;
else
mat = MatrixF::Identity;
mat.scale( Point3F(radius,radius,height*0.5f) );
mat.setPosition(center);
mDevice->pushWorldMatrix();
mDevice->multWorld(mat);
S32 numPoints = sizeof(circlePoints)/sizeof(Point2F);
GFXVertexBufferHandle<GFXVertexPC> verts(mDevice, numPoints, GFXBufferTypeVolatile);
verts.lock();
for (S32 i=0; i< numPoints; i++)
{
S32 idx = i & (~1); // just draw the even ones
F32 z = i & 1 ? 1.0f : -1.0f;
verts[i].point = Point3F(circlePoints[idx].x,circlePoints[idx].y, z);
verts[i].color = color;
}
verts.unlock();
mDevice->setStateBlockByDesc( desc );
mDevice->setVertexBuffer( verts );
mDevice->setupGenericShaders();
for (S32 i=0; i<numPoints; i += 2)
mDevice->drawPrimitive(GFXLineStrip, i, 1);
mDevice->popWorldMatrix();
Point3F sphereCenter;
sphereCenter.z = center.z + 0.5f * height;
drawSphere( desc, radius,sphereCenter,color,true,false);
sphereCenter.z = center.z - 0.5f * height;
drawSphere( desc, radius,sphereCenter,color,false,true);
}
示例14: 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;
}
示例15: renderObject
void PxSingleActor::renderObject(SceneState* state)
{
GFXTransformSaver saver;
// Set up our TS render state here.
TSRenderState rdata;
rdata.setSceneState( state );
//rdata.setObjScale( &getScale() );
LightManager *lm = gClientSceneGraph->getLightManager();
if ( !state->isShadowPass() )
lm->setupLights( this, getWorldSphere() );
MatrixF mat = getTransform();
mat.scale( getScale() );
GFX->setWorldMatrix( mat );
mShapeInstance->animate();
mShapeInstance->render( rdata );
lm->resetLights();
}