本文整理汇总了C++中ISceneManager::createOctreeTriangleSelector方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::createOctreeTriangleSelector方法的具体用法?C++ ISceneManager::createOctreeTriangleSelector怎么用?C++ ISceneManager::createOctreeTriangleSelector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::createOctreeTriangleSelector方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadScene
void Editor::LoadScene()
{
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
// Calculate Projection Matrix
matrix4 projMat;
irr::f32 orth_w = (float)(driver->getScreenSize().Width - 256) / (float)driver->getScreenSize().Height;
orth_w = 3 * orth_w;
projMat.buildProjectionMatrixOrthoLH(orth_w, 3, 1, 100);
// Create target
target = smgr->addEmptySceneNode(0, 200);
target->setPosition(vector3df(0, 0, 0));
// Add rotational camera
pivot = smgr->addEmptySceneNode(target, 199);
camera[0] = smgr->addCameraSceneNode(NULL, vector3df(0, 0, -2), vector3df(0, 0, 0));
camera[0]->setParent(pivot);
pivot->setRotation(vector3df(25, -45, 0));
// Add Topdown camera
camera[1] = smgr->addCameraSceneNode(target, vector3df(0, 2, -0.01), vector3df(0, 0, 0));
camera[1]->setProjectionMatrix(projMat, true);
// Add front camera
camera[2] = smgr->addCameraSceneNode(target, vector3df(0, 0, -5), vector3df(0, 0, 0));
camera[2]->setProjectionMatrix(projMat, true);
// Add side camera
camera[3] = smgr->addCameraSceneNode(target, vector3df(5, 0, 0), vector3df(0, 0, 0));
camera[3]->setProjectionMatrix(projMat, true);
// Add Light
ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
// Add Plane
IMeshSceneNode* plane = smgr->addCubeSceneNode(1, 0, -1,
vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0),
vector3df(10, 10, 10));
plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10);
// Add sky box
scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50);
skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg"));
skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
skybox->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh());
state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox);
}
示例2: LoadScene
void Editor::LoadScene()
{
IVideoDriver *driver = device->getVideoDriver();
ISceneManager *smgr = device->getSceneManager();
// Create target
target = smgr->addEmptySceneNode(0, 200);
target->setPosition(vector3df(0, 0, 0));
// Create cameras
pivot = smgr->addEmptySceneNode(target, 199);
pivot->setRotation(vector3df(25, -45, 0));
recreateCameras();
// Add Light
ILightSceneNode* light = smgr->addLightSceneNode(target, vector3df(25, 50, 0));
light->setLightType(ELT_POINT);
light->setRadius(2000);
// Add Plane
plane = smgr->addCubeSceneNode(1, 0, -1,
vector3df(0.5, -5.5, 0.5), vector3df(0, 0, 0),
vector3df(10, 10, 10));
plane->setMaterialTexture(0, driver->getTexture("media/texture_terrain.png"));
plane->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
plane->setMaterialFlag(video::EMF_LIGHTING, false);
plane->setMaterialFlag(video::EMF_BACK_FACE_CULLING, true);
plane->getMaterial(0).getTextureMatrix(0).setTextureScale(10, 10);
// Add sky box
scene::IMeshSceneNode* skybox = smgr->addCubeSceneNode(50);
skybox->setMaterialTexture(0, driver->getTexture("media/sky.jpg"));
skybox->setMaterialFlag(video::EMF_BILINEAR_FILTER, false);
skybox->setMaterialFlag(video::EMF_LIGHTING, false);
smgr->getMeshManipulator()->flipSurfaces(skybox->getMesh());
state->plane_tri = smgr->createOctreeTriangleSelector(skybox->getMesh(), skybox);
}
示例3: initComponent
// init
// run when init object
void CObjectCollisionComponent::initComponent()
{
#ifdef GSGAMEPLAY
IMesh *pMesh = NULL;
ISceneNode *node = m_gameObject->getSceneNode();
ISceneManager *smgr = getIView()->getSceneMgr();
if ( node == NULL )
return;
std::vector<SObjectCollisionParam> listMesh;
SObjectCollisionParam temp;
if ( m_gameObject->getComponent( IObjectComponent::StaticMesh ) != NULL )
{
pMesh = ((IMeshSceneNode*) node)->getMesh();
temp.mesh = pMesh;
temp.node = node;
listMesh.push_back( temp );
}
else if ( m_gameObject->getComponent( IObjectComponent::AnimMesh ) != NULL )
{
pMesh = ((IAnimatedMeshSceneNode*) node)->getMesh();
temp.mesh = pMesh;
temp.node = node;
listMesh.push_back( temp );
}
else if ( m_gameObject->getComponent( IObjectComponent::ColladaMesh ) != NULL )
{
CColladaMeshComponent *comp = (CColladaMeshComponent*)m_gameObject->getComponent( IObjectComponent::ColladaMesh );
ISceneNode* colladaNode = comp->getColladaNode();
std::queue<ISceneNode*> listSceneNode;
const core::list<ISceneNode*>* listChild = &colladaNode->getChildren();
core::list<ISceneNode*>::ConstIterator it = listChild->begin(), end = listChild->end();
while ( it != end )
{
listSceneNode.push( (*it) );
it++;
}
while ( listSceneNode.size() )
{
CGameColladaSceneNode* sceneNode = (CGameColladaSceneNode*)listSceneNode.front();
listSceneNode.pop();
if ( sceneNode->getMesh() )
{
temp.mesh = sceneNode->getMesh();
temp.node = sceneNode;
listMesh.push_back( temp );
}
const core::list<ISceneNode*>* listChild = &sceneNode->getChildren();
it = listChild->begin();
end = listChild->end();
while ( it != end )
{
listSceneNode.push( (*it) );
it++;
}
}
}
for ( int i = 0; i < (int)listMesh.size(); i++ )
{
node = listMesh[i].node;
pMesh = listMesh[i].mesh;
switch ( m_collisionType )
{
case CObjectCollisionComponent::BoudingBox:
{
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox(node);
node->setTriangleSelector( selector );
selector->drop();
}
break;
case CObjectCollisionComponent::Triangle:
{
ITriangleSelector* selector = smgr->createTriangleSelector( pMesh, node );
node->setTriangleSelector(selector);
selector->drop();
}
break;
case CObjectCollisionComponent::OctreeTriange:
{
ITriangleSelector* selector = smgr->createOctreeTriangleSelector( pMesh, node );
node->setTriangleSelector(selector);
selector->drop();
}
break;
}
}
//.........这里部分代码省略.........
示例4: main
int main()
{
Input input;
IrrlichtDevice *device = createDevice(video::EDT_DIRECT3D9, dimension2d<u32>(800, 600), 16, false, true, false, &input);
device->setWindowCaption(L"Seas of Gold");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
E_DRIVER_TYPE driverType = driverChoiceConsole();
EffectHandler *effect = new EffectHandler(device, driver->getScreenSize(), false, true);
E_FILTER_TYPE filterType = (E_FILTER_TYPE)core::clamp<u32>((u32)3 - '1', 0, 4);
MapID currentMap;
int skyR = 30, skyG = 30, skyB = 70;
int timer = 0;
SColor sky = SColor(255, skyR, skyG, skyB);
float plPos_x = 0.0f, plPos_y = 0.0f, plPos_z = 0.0f;
bool updateCam = true;
bool menu1 = false;
int state = Main;
int frameCount = 0;
LoadMap loadMap;
Player player;
Interface playerInterface(driver);
ITriangleSelector* selector = 0;
ISceneNodeAnimator* anim = 0;
Vendor southVendor;
Vendor eastVendor;
Vendor northVendor;
//InitializeVendors(northVendor, southVendor, eastVendor, itemD);
//ItemDatabase* itemD = new ItemDatabase;
ItemDatabase itemD;
itemD.Initialize();
//initialize player's inventory
player.AddGold(1000);
player.getInventory()->addItem(itemD.getItem(bronzeOre), 50);
player.getInventory()->addItem(itemD.getItem(ironOre), 50);
player.getInventory()->addItem(itemD.getItem(goldOre), 50);
//initialize south vendor's inventory
southVendor.getInventory()->addItem(itemD.getItem(bronzeOre), 100);
southVendor.getInventory()->addItem(itemD.getItem(coalOre), 100);
southVendor.getInventory()->addItem(itemD.getItem(supplies), 1000);
//initialize north vendor's inventory
northVendor.getInventory()->addItem(itemD.getItem(obsidianOre), 50);
northVendor.getInventory()->addItem(itemD.getItem(supplies), 1000);
//initialize south vendor's inventory
eastVendor.getInventory()->addItem(itemD.getItem(goldOre), 100);
eastVendor.getInventory()->addItem(itemD.getItem(ironOre), 100);
eastVendor.getInventory()->addItem(itemD.getItem(supplies), 1000);
//Item item(0, "bronzeOre", "Sprites/ore_Bronze.png");
//Item item2 = item;
//Item* item2 = itemD.getItem(3);
//inventory.addItem(&item, 2);
//inventory.addItem(&item, 2);
//inventory.addItem(item2, 2);
//int test = 0;
// Load the map scene
//loadMap.Load(smgr, device, Map_Africa);
//loadMap.Load(smgr, device, Map_India);
//loadMap.Load(smgr, device, selector, plyrNode, anim, Map_England);
IAnimatedMeshSceneNode* plyrNode = player.loadPlayerNode(device, smgr);
//plyrNode->setDebugDataVisible((scene::E_DEBUG_SCENE_TYPE)(plyrNode->isDebugDataVisible() ^ scene::EDS_BBOX));
ICameraSceneNode* camera = smgr->addCameraSceneNode(0, plyrNode->getPosition() + vector3df(0, 2, 2), vector3df(0, 0, 100));
loadMap.Load(smgr, device, selector, plyrNode, anim, driver, Map_Africa);
currentMap = Map_Africa;
//loadMap.setCollisions(smgr, selector, plyrNode, anim);
if (loadMap.CollNode)
{
selector = smgr->createOctreeTriangleSelector(loadMap.CollNode->getMesh(), loadMap.CollNode, 32);
for (int i = 0; i < loadMap.CollNode->getMaterialCount(); i++)
{
loadMap.CollNode->getMaterial(i).NormalizeNormals = true;
}
loadMap.CollNode->setTriangleSelector(selector);
}
if (selector)
{
anim = smgr->createCollisionResponseAnimator(selector, plyrNode, vector3df(0.6f, 0.75f, 0.4f), core::vector3df(0.0f, -0.05f, 0.0f),
core::vector3df(0.0f, -0.725f, 0.0f));
plyrNode->addAnimator(anim);
}
ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
////////////// The Sun ////////////
ILightSceneNode *sun_node;
SLight sun_data;
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
//-- collision ------------------------------------------------------------//
/* Put everything we want to do collision checking with inside the meta selector. */
IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
array<ISceneNode *> nodes;
smgr->getSceneNodesFromType(ESNT_ANY, nodes); // Find all nodes
for (u32 i=0; i < nodes.size(); ++i)
{
ISceneNode * node = nodes[i];
ITriangleSelector * selector = 0;
switch(node->getType())
{
case ESNT_CUBE:
case ESNT_ANIMATED_MESH:
// Because the selector won't animate with the mesh,
// and is only being used for camera collision, we'll just use an approximate
// bounding box instead of ((IAnimatedMeshSceneNode*)node)->getMesh(0)
selector = smgr->createTriangleSelectorFromBoundingBox(node);
break;
case ESNT_MESH:
case ESNT_SPHERE: // Derived from IMeshSceneNode
selector = smgr->createTriangleSelector(((IMeshSceneNode*)node)->getMesh(), node);
break;
case ESNT_TERRAIN:
selector = smgr->createTerrainTriangleSelector((ITerrainSceneNode*)node);
break;
case ESNT_OCTREE:
selector = smgr->createOctreeTriangleSelector(((IMeshSceneNode*)node)->getMesh(), node);
break;
default:
// Don't create a selector for this node type
break;
}
if(selector)
{
// Add it to the meta selector, which will take a reference to it
meta->addTriangleSelector(selector);
// And drop my reference to it, so that the meta selector owns it.
selector->drop();
}
}
//-- robots ------------------------------------------------------------//
//create robots
Fly2D::Brain* brains[nRobots];
//all to a default type
//for ( int i=0; i<nRobots; i++ )
//{
//brains[i] = new Fly2D::BrainForward;
////brains[i] = new Fly2D::BrainCircle();
//}
brains[0] = new Fly2D::BrainForward;
brains[1] = new Fly2D::BrainForward;