Exemplo n.º 1
0
void setupPlayer() {
	Player *player = getGameState()->getPlayer();

	if (!player->isReady()) {
		return;
	}

    // Set viewing position with the Y axis as upright.
    viewMatrix.SetIdentity();
    viewMatrix.LookAt(CIwFVec3(0,-11,0), CIwFVec3(0,0,100), CIwFVec3(0,-1,0));

    // Rotate according to compass heading
	viewMatrix.PostRotateY(rad(player->getHeading()));
    IwGxSetViewMatrix(&viewMatrix);
}
Exemplo n.º 2
0
void CzPlatformRender::SetModelMatrix(CzMatrix4* mat)
{
	CIwFMat m;
	m.SetIdentity();
	m.m[0][0] = mat->m[0][0];
	m.m[1][0] = mat->m[1][0];
	m.m[2][0] = mat->m[2][0];
	m.m[0][1] = mat->m[0][1];
	m.m[1][1] = mat->m[1][1];
	m.m[2][1] = mat->m[2][1];
	m.m[0][2] = mat->m[0][2];
	m.m[1][2] = mat->m[1][2];
	m.m[2][2] = mat->m[2][2];
	m.t.x = mat->m[0][3];
	m.t.y = mat->m[1][3];
	m.t.z = mat->m[2][3];

	IwGxSetModelMatrix(&m);
}
CIwFMat Physics::GetMatrixFromRigidBody( const btRigidBody* b )
{
	CIwFMat modelMatrix;
	
	btMatrix3x3 mRot;
	btTransform btTrans = b->getWorldTransform();
	btVector3 pos = btTrans.getOrigin();
	mRot = btTrans.getBasis();

	modelMatrix.SetIdentity();

	for( int i = 0, j = 0; i < 3; ++i, j = 0 )
	{
		modelMatrix.m[i][j] = ( mRot.getRow( i ).x() );
		modelMatrix.m[i][++j] = ( mRot.getRow( i ).y() );
		modelMatrix.m[i][++j] = ( mRot.getRow( i ).z() );
	}
	
	modelMatrix.SetTrans( CIwFVec3( pos[0], pos[1], pos[2] ) );

	return modelMatrix;
}