本文整理汇总了C++中CFactory::alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactory::alloc方法的具体用法?C++ CFactory::alloc怎么用?C++ CFactory::alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactory
的用法示例。
在下文中一共展示了CFactory::alloc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gamerRenderInitAllObjects
void gamerRenderInitAllObjects( tAnimModel const* pAnimModel,
tAnimSequence* pAnimSequence,
tAnimHierarchy const* pAnimHierarchy )
{
const float fStartingPosRadius = 5.0f;
Matrix44Identity( &gIdentityMat );
siNumRenderObjects = 1;
saRenderObjects = sGameRenderObjectFactory.alloc( siNumRenderObjects );
saAnimModelInstances = sAnimModelInstanceFactory.alloc( siNumRenderObjects );
saObjectInfo = sVectorFactory.alloc( siNumRenderObjects * 3 );
saAnimHierarchies = sAnimHierarchyFactory.alloc( siNumRenderObjects );
memset( saObjectInfo, 0, sizeof( tVector4 ) * siNumRenderObjects * 3 );
float fAnglePart = ( 2.0f * 3.14159f ) / (float)siNumRenderObjects;
int iCount = 0;
for( int i = 0; i < siNumRenderObjects; i++ )
{
// animation model instance
tAnimModelInstance* pAnimModelInstance = &saAnimModelInstances[i];
animModelInstanceInit( pAnimModelInstance );
animModelInstanceSet( pAnimModelInstance, pAnimModel );
animModelInstanceSetupGL( pAnimModelInstance );
tGameRenderObject* pRenderObject = &saRenderObjects[i];
pRenderObject->miType = RENDEROBJECT_ANIMMODEL;
pRenderObject->mpAnimModelInstance = &saAnimModelInstances[i];
// position, heading and speed
pRenderObject->mpPosition = &saObjectInfo[iCount++];
pRenderObject->mpSize = &saObjectInfo[iCount++];
pRenderObject->mpHeading = &saObjectInfo[iCount++];
pRenderObject->mfSpeed = 0.0f;
pRenderObject->mpPosition->fW = 1.0f;
pRenderObject->mpSize->fW = 1.0f;
pRenderObject->mpHeading->fW = 1.0f;
// heading
tVector4 xVec = { 1.0f, 0.0f, 0.0f, 1.0f };
tMatrix44 rotMatY;
Matrix44RotateY( &rotMatY, fAnglePart * (float)i );
Matrix44Transform( pRenderObject->mpHeading, &xVec, &rotMatY );
Vector4Normalize( pRenderObject->mpHeading, pRenderObject->mpHeading );
// position
pRenderObject->mpPosition->fX = pRenderObject->mpHeading->fX * fStartingPosRadius - 15.0f;
pRenderObject->mpPosition->fZ = pRenderObject->mpHeading->fZ * fStartingPosRadius;
pRenderObject->mfAnimMult = 0.5f + (float)( rand() % 500 ) * 0.001f;
pRenderObject->mfSpeed = pRenderObject->mfAnimMult;
pRenderObject->mfSpeed *= 0.01f;
pRenderObject->mpSize->fX = 1.5f;
pRenderObject->mpSize->fY = 1.5f;
pRenderObject->mpSize->fZ = 1.5f;
// duplicate of the hierarchy for storing skin matrices
animHierarchyCopy( &saAnimHierarchies[i],
pAnimHierarchy,
&gJointFactory,
&gMatrixFactory );
// use this hierarchy for this model instance
pAnimModelInstance->mpAnimHierarchy = &saAnimHierarchies[i];
pAnimModelInstance->mpAnimModel = pAnimModel;
pAnimModelInstance->maRotations = (tVector4 *)malloc( sizeof( tVector4 ) );
pAnimModelInstance->maPositions = (tVector4 *)malloc( sizeof( tVector4 ) );
pAnimModelInstance->maScalings = (tVector4 *)malloc( sizeof( tVector4 ) );
pAnimModelInstance->maRotatePivot = (tVector4 *)malloc( sizeof( tVector4 ) );
pAnimModelInstance->maScalePivot = (tVector4 *)malloc( sizeof( tVector4 ) );
//memcpy( pAnimModelInstance->maRotatePivot, &pAnimModel->mCenter, sizeof( tVector4 ) );
//memcpy( pAnimModelInstance->maScalePivot, &pAnimModel->mCenter, sizeof( tVector4 ) );
memset( pAnimModelInstance->maRotatePivot, 0, sizeof( tVector4 ) );
memset( pAnimModelInstance->maScalePivot, 0, sizeof( tVector4 ) );
pAnimModelInstance->miNumXForms = 1;
}
spAnimSequence = pAnimSequence;
}