本文整理汇总了C++中MeshInstance::initFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshInstance::initFromFile方法的具体用法?C++ MeshInstance::initFromFile怎么用?C++ MeshInstance::initFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshInstance
的用法示例。
在下文中一共展示了MeshInstance::initFromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSpaceShip
void ClientGameObjectManagerAddon::createSpaceShip(int &threadOwnershipMask)
{
//create hierarchy:
//scene root
// scene node // tracks position/orientation
// SpaceShip
//game object manager
// SpaceShipController
// scene node
PE::Handle hMeshInstance("MeshInstance", sizeof(MeshInstance));
MeshInstance *pMeshInstance = new(hMeshInstance) MeshInstance(*m_pContext, m_arena, hMeshInstance);
pMeshInstance->addDefaultComponents();
pMeshInstance->initFromFile("space_frigate_6.mesha", "FregateTest", threadOwnershipMask);
// need to create a scene node for this mesh
PE::Handle hSN("SCENE_NODE", sizeof(SceneNode));
SceneNode *pSN = new(hSN) SceneNode(*m_pContext, m_arena, hSN);
pSN->addDefaultComponents();
Vector3 spawnPos(0, 0, 0.0f);
pSN->m_base.setPos(spawnPos);
pSN->addComponent(hMeshInstance);
RootSceneNode::Instance()->addComponent(hSN);
// now add game objects
PE::Handle hSpaceShip("ClientSpaceShip", sizeof(ClientSpaceShip));
ClientSpaceShip *pSpaceShip = new(hSpaceShip) ClientSpaceShip(*m_pContext, m_arena, hSpaceShip, 0.05f, spawnPos, 0.05f);
pSpaceShip->addDefaultComponents();
addComponent(hSpaceShip);
// add the same scene node to tank controller
static int alllowedEventsToPropagate[] = {0}; // we will pass empty array as allowed events to propagate so that when we add
// scene node to the square controller, the square controller doesnt try to handle scene node's events
// because scene node handles events through scene graph, and is child of space ship just for referencing purposes
pSpaceShip->addComponent(hSN, &alllowedEventsToPropagate[0]);
pSpaceShip->activate();
}
示例2: createTank
void ClientGameObjectManagerAddon::createTank(int index, int &threadOwnershipMask)
{
//create hierarchy:
//scene root
// scene node // tracks position/orientation
// Tank
//game object manager
// TankController
// scene node
PE::Handle hMeshInstance("MeshInstance", sizeof(MeshInstance));
MeshInstance *pMeshInstance = new(hMeshInstance) MeshInstance(*m_pContext, m_arena, hMeshInstance);
pMeshInstance->addDefaultComponents();
pMeshInstance->initFromFile("kingtiger.x_main_mesh.mesha", "Default", threadOwnershipMask);
// need to create a scene node for this mesh
PE::Handle hSN("SCENE_NODE", sizeof(SceneNode));
SceneNode *pSN = new(hSN) SceneNode(*m_pContext, m_arena, hSN);
pSN->addDefaultComponents();
Vector3 spawnPos(-36.0f + 6.0f * index, 0 , 21.0f);
pSN->m_base.setPos(spawnPos);
pSN->addComponent(hMeshInstance);
RootSceneNode::Instance()->addComponent(hSN);
// now add game objects
PE::Handle hTankController("TankController", sizeof(TankController));
TankController *pTankController = new(hTankController) TankController(*m_pContext, m_arena, hTankController, 0.05f, spawnPos, 0.05f);
pTankController->addDefaultComponents();
addComponent(hTankController);
// add the same scene node to tank controller
static int alllowedEventsToPropagate[] = {0}; // we will pass empty array as allowed events to propagate so that when we add
// scene node to the square controller, the square controller doesnt try to handle scene node's events
// because scene node handles events through scene graph, and is child of square controller just for referencing purposes
pTankController->addComponent(hSN, &alllowedEventsToPropagate[0]);
}
示例3: hSN
Flyer::Flyer(PE::GameContext &context, PE::MemoryArena arena, PE::Handle hMyself, int &threadOwnershipMask)
: Component(context, arena, hMyself)
, m_prevCameraType(CameraManager::CameraType_Count)
{
// NUI testing
#ifdef _XBOX
// Could also try for a bit more smoothing ( 0.25f, 0.25f, 0.25f, 0.03f, 0.05f );
m_JointFilter.Init( 0.5f, 0.5f, 0.5f, 0.05f, 0.05f );
// create event which will be signaled when frame processing ends
m_hFrameEndEvent = CreateEvent( NULL,
FALSE, // auto-reset
FALSE, // create unsignaled
"NuiFrameEndEvent" );
if ( !m_hFrameEndEvent )
{
ATG_PrintError( "Failed to create NuiFrameEndEvent\n" );
return;
// return E_FAIL;
}
HRESULT hr = NuiInitialize( NUI_INITIALIZE_FLAG_USES_SKELETON |
NUI_INITIALIZE_FLAG_USES_COLOR |
NUI_INITIALIZE_FLAG_USES_DEPTH_AND_PLAYER_INDEX,
NUI_INITIALIZE_DEFAULT_HARDWARE_THREAD );
if( FAILED( hr ))
{
ATG::NuiPrintError( hr, "NuiInitialize" );
return;
// return E_FAIL;
}
// register frame end event with NUI
hr = NuiSetFrameEndEvent( m_hFrameEndEvent, 0 );
if( FAILED(hr) )
{
ATG::NuiPrintError( hr, "NuiSetFrameEndEvent" );
return;
// return E_FAIL;
}
/*
// Open the color stream
hr = NuiImageStreamOpen( NUI_IMAGE_TYPE_COLOR, NUI_IMAGE_RESOLUTION_640x480, 0, 1, NULL, &m_hImage );
if( FAILED (hr) )
{
ATG::NuiPrintError( hr, "NuiImageStreamOpen" );
return E_FAIL;
}
// Open the depth stream
hr = NuiImageStreamOpen( NUI_IMAGE_TYPE_DEPTH_AND_PLAYER_INDEX, NUI_IMAGE_RESOLUTION_320x240, 0, 1, NULL, &m_hDepth );
if( FAILED (hr) )
{
ATG::NuiPrintError( hr, "NuiImageStreamOpen" );
return E_FAIL;
}
*/
hr = NuiSkeletonTrackingEnable( NULL, 0 );
if( FAILED( hr ))
{
ATG::NuiPrintError( hr, "NuiSkeletonTrackingEnable" );
}
m_pNuiJointConverterConstrained = new ATG::NuiJointConverter();
if( m_pNuiJointConverterConstrained == NULL )
{
// return E_FAIL;
return;
}
m_pNuiJointConverterConstrained->AddDefaultConstraints();
Handle hSN("SceneNode", sizeof(SceneNode));
m_pNuiSN = new(hSN) SceneNode(context, arena, hSN);
m_pNuiSN->addDefaultComponents();
m_pNuiSN->m_base.setPos(Vector3(0.0f, 0, 25.0f));
m_pNuiSN->m_base.turnRight(1.2f * 3.1415f);
RootSceneNode::Instance()->addComponent(hSN);
for (int i = 0; i < XAVATAR_MAX_SKELETON_JOINTS; i++)
{
PE::Handle hMeshInstance("MeshInstance", sizeof(MeshInstance));
MeshInstance *pMeshInstance = new(hMeshInstance) MeshInstance(*m_pContext, m_arena, hMeshInstance);
pMeshInstance->addDefaultComponents();
pMeshInstance->initFromFile("box.x_main_mesh.mesha", "Default", threadOwnershipMask);
Handle hSN("SceneNode", sizeof(SceneNode));
m_sceneNodes[i] = new(hSN) SceneNode(context, arena, hSN);
m_sceneNodes[i]->addDefaultComponents();
m_sceneNodes[i]->addComponent(hMeshInstance);
m_pNuiSN->addComponent(hSN);
if (m_pNuiJointConverterConstrained->MapAvatarJointToNUI_POSITION_INDEX(i) == NUI_SKELETON_POSITION_SHOULDER_RIGHT)
{
PE::Handle hMeshInstance("MeshInstance", sizeof(MeshInstance));
MeshInstance *pMeshInstance = new(hMeshInstance) MeshInstance(*m_pContext, m_arena, hMeshInstance);
pMeshInstance->addDefaultComponents();
//.........这里部分代码省略.........