本文整理汇总了C++中ITriangleSelector类的典型用法代码示例。如果您正苦于以下问题:C++ ITriangleSelector类的具体用法?C++ ITriangleSelector怎么用?C++ ITriangleSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ITriangleSelector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIView
CWayPoint::CWayPoint()
{
m_objectType = CGameObject::WaypointObject;
m_next = NULL;
m_back = NULL;
m_timeWait = 0;
ISceneManager *smgr = getIView()->getSceneMgr();
// init waypoint mesh
//CColladaMeshComponent *comp = new CColladaMeshComponent( this );
//comp->loadFromFile( getIView()->getPath("data/editor/waypoint.dae") );
//addComponent( comp );
//setLighting( false );
m_node = new CGameBoxSceneNode(this, 5, smgr->getRootSceneNode(), smgr, (s32)m_objectID);
m_node->getMaterial(0).Lighting = true;
#ifdef GSEDITOR
setVisible ( true );
// add collision
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_node );
m_node->setTriangleSelector(selector);
selector->drop();
#else
setVisible ( false );
#endif
}
示例2: IrrGetCollisionGroupFromBox
/* ----------------------------------------------------------------------------
creates a collision selector from triangles in a nodes bounding box
*/
void * DLL_EXPORT IrrGetCollisionGroupFromBox( ISceneNode * node )
{
ITriangleSelector* selector = smgr->createTriangleSelectorFromBoundingBox( node );
node->setTriangleSelector(selector);
selector->drop();
return (void *)selector;
}
示例3: GameEntity
Player::Player(IrrlichtDevice *device, IAnimatedMeshSceneNode *m) : GameEntity(device)
{
health = 100;
armor = 0;
model = 0;
fpsCamera = 0;
weaponManager = 0;
headsUpGUI = 0;
collisionAnimator = 0;
/*** Set up Camera Stuff ***/
fpsCamera = new FPSCamera(device);
/*** Set up Player Mesh ***/
if(m)
{
model = m;
//Set up the triangle selector for the player mesh model
ITriangleSelector *selector = smgr->createOctTreeTriangleSelector(model->getMesh(), model);
if(selector)
{
model->setTriangleSelector(selector);
selector->drop();
}
}
///*** Set up Player Weapons ***/
// weaponManager = new WeaponManager(device);
/*** Set up Player HUD ***/
headsUpGUI = new HeadsUpGUI(device);
}
示例4: recalculate
void TerrainTile::recalculate(bool simple)
{
if (custom)
return;
if (needrecalc)
{
//This part only refresh the visual model, will not change the collision shape
smgr->getMeshManipulator()->recalculateNormals(((IMeshSceneNode*)node)->getMesh(),true);
core::aabbox3df box=node->getBoundingBox();
((IMeshSceneNode*)node)->getMesh()->setBoundingBox(core::aabbox3df(-box.getExtent().X/2,-256.0f,-box.getExtent().Z/2,box.getExtent().X/2,1024,box.getExtent().Z/2));
((IMeshSceneNode*)node)->getMesh()->setDirty();
}
// Simple is used by the brush when carving, once the carve is done, if needrecalc is activated will redo the collision shape
// also used by terrainManager::recalculate()
if (!simple && needrecalc)
{
// Attempt to update the triangle selector with the new mesh, will get the modified mesh and recreate the collision mesh
ITriangleSelector * selector = smgr->createTriangleSelector(((IMeshSceneNode*)node)->getMesh(),node);
//----ITriangleSelector * selector = smgr->createOctTreeTriangleSelector(((IMeshSceneNode*)node)->getMesh(),node);
node->setTriangleSelector(selector);
selector->drop();
needrecalc = false;
#ifdef DEBUG
printf("RECALCULATING SEGMENT: %s\n",getName().c_str());
#endif
}
}
示例5: applyCollision
/*********************************************************************
* Applies collision to the model created
* Param: metaTriSelector pointer to the IMetaFriangleSelector
* that handles collision
*********************************************************************/
void Soldier::applyCollision(
irr::scene::IMetaTriangleSelector *metaTriSelector){
// add its triangles to the global collision meta selector
ITriangleSelector *selector =
smgr->createTriangleSelectorFromBoundingBox(sceneNode);
sceneNode->setTriangleSelector(selector);
selector->drop();
metaTriSelector->addTriangleSelector(sceneNode->getTriangleSelector());
}
示例6: IrrGetCollisionGroupFromComplexMesh
/* ----------------------------------------------------------------------------
creates a collision selector from a complex node like a map
*/
void * DLL_EXPORT IrrGetCollisionGroupFromComplexMesh( IAnimatedMesh* mesh, ISceneNode* node, int iframe )
{
ITriangleSelector* selector = smgr->createOctreeTriangleSelector(
mesh->getMesh(iframe), node, 128);
node->setTriangleSelector(selector);
selector->drop();
return (void *)selector;
}
示例7: getIView
CGameCamera::CGameCamera()
{
m_targetObject = NULL;
m_objectType = CGameObject::CameraObject;
#ifdef GSEDITOR
m_cameraMesh = NULL;
#endif
ISceneManager *smgr = getIView()->getSceneMgr();
// save old camera
ICameraSceneNode *oldCam = smgr->getActiveCamera();
// create new camera
m_camera = smgr->addCameraSceneNode();
m_camera->setFOV( core::degToRad(60.0f) );
m_camera->setFarValue( 8000.0f );
m_camera->grab();
core::vector3df pos(0,0,0);
setPosition( pos );
core::vector3df target(1,0,0);
setTarget( target );
#ifdef GSEDITOR
CColladaMeshComponent *comp = new CColladaMeshComponent( this );
comp->loadFromFile( getIView()->getPath("data/editor/camera.dae") );
addComponent( comp );
setLighting( false );
m_cameraMesh = m_node;
m_cameraMesh->setVisible( true );
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox( m_cameraMesh );
m_cameraMesh->setTriangleSelector(selector);
selector->drop();
#endif
// set camera node
m_node = m_camera;
// restore camera
smgr->setActiveCamera( oldCam );
m_animator = NULL;
#ifndef GSGAMEPLAY
setEditorCamera();
#else
setFreeCamera();
#endif
}
示例8: getCollisionPoint_ignoreTriangleVertices
// Test that getCollisionPoint() actually uses the closest point, not the closest triangle.
static bool getCollisionPoint_ignoreTriangleVertices(IrrlichtDevice * device,
ISceneManager * smgr,
ISceneCollisionManager * collMgr)
{
// Create a cube with a Z face at 5, but corners close to 0
ISceneNode * farSmallCube = smgr->addCubeSceneNode(10, 0, -1, vector3df(0, 0, 10));
// Create a cube with a Z face at 0, but corners far from 0
ISceneNode * nearBigCube = smgr->addCubeSceneNode(100, 0, -1, vector3df(0, 0, 50));
IMetaTriangleSelector * meta = smgr->createMetaTriangleSelector();
ITriangleSelector * selector = smgr->createTriangleSelectorFromBoundingBox(farSmallCube);
meta->addTriangleSelector(selector);
selector->drop();
// We should expect a hit on this cube
selector = smgr->createTriangleSelectorFromBoundingBox(nearBigCube);
meta->addTriangleSelector(selector);
selector->drop();
line3df ray(0, 0, -5, 0, 0, 100);
vector3df hitPosition;
triangle3df hitTriangle;
ISceneNode* hitNode;
bool collision = collMgr->getCollisionPoint(ray, meta, hitPosition, hitTriangle, hitNode);
meta->drop();
if(hitNode != nearBigCube)
{
logTestString("getCollisionPoint_ignoreTriangleVertices: hit the wrong node.\n");
return false;
}
if(!collision)
{
logTestString("getCollisionPoint_ignoreTriangleVertices: didn't get a hit.\n");
return false;
}
if(hitPosition != vector3df(0, 0, 0))
{
logTestString("getCollisionPoint_ignoreTriangleVertices: unexpected hit position %f %f %f.\n",
hitPosition.X, hitPosition.Y, hitPosition.Z );
return false;
}
smgr->clear();
return true;
}
示例9:
ISceneNode *Plane::createSceneNode(ISceneManager *smgr)
{
if (sceneNode) sceneNode->drop();
sceneNode = smgr->addMeshSceneNode(mesh, 0, GUIManager::ID_COMPONENT);
sceneNode->grab();
ITriangleSelector *selector = smgr->createTriangleSelector(mesh, sceneNode);
sceneNode->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
sceneNode->setMaterialTexture(0, smgr->getVideoDriver()->getTexture(texturePath));
sceneNode->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
sceneNode->setTriangleSelector(selector);
selector->drop();
return sceneNode;
}
示例10: addCollision
void Entity::addCollision(Entity coll, f32 tx, f32 ty, f32 tz, f32 sx, f32 sy, f32 sz, f32 gx, f32 gy, f32 gz)
{
ITriangleSelector* selector = 0;
if(coll.type == MESH_TYPE)
{
selector = Scene->createTriangleSelector(coll.tmesh, coll.sceneNode);
coll.sceneNode->setTriangleSelector(selector);
}
if(coll.type == ANIM_TYPE)
{
selector = Scene->createTriangleSelector(coll.animNode->getMesh(), coll.animNode);
coll.animNode->setTriangleSelector(selector);
}
if(coll.type == MAP_TYPE)
{
selector = Scene->createOctreeTriangleSelector(coll.bmesh->getMesh(0), coll.sceneNode);
coll.sceneNode->setTriangleSelector(selector);
}
ISceneNodeAnimator* anim;
if(type == MESH_TYPE)
{
anim = Scene->createCollisionResponseAnimator(selector, sceneNode, vector3df(sx,sy,sz), \
vector3df(gx,gy,gz), vector3df(tx,ty,tz));
sceneNode->addAnimator(anim);
}
if(type == ANIM_TYPE)
{
anim = Scene->createCollisionResponseAnimator(selector, animNode, vector3df(sx,sy,sz), \
vector3df(gx,gy,gz), vector3df(tx,ty,tz));
animNode->addAnimator(anim);
}
if(type == MAP_TYPE)
{
anim = Scene->createCollisionResponseAnimator(selector, sceneNode, vector3df(sx,sy,sz), \
vector3df(gx,gy,gz), vector3df(tx,ty,tz));
sceneNode->addAnimator(anim);
}
else
return;
selector->drop();
anim->drop();
}
示例11: ZombieInstance
ZombieInstance :: ZombieInstance(vector3df position)
{
this->position = position;
sceneNode = IRR->sceneMgr->addMeshSceneNode(IRR->sceneMgr->getMesh("mdl/Zombie.irrmesh"), 0, BITMASK_CHARACTER);
sceneNode->setMaterialFlag(EMF_LIGHTING, false);
sceneNode->setPosition(position);
// Collision Triangle Selector for collision:
ITriangleSelector* collisionSelector = IRR->sceneMgr->createTriangleSelector(sceneNode->getMesh(), sceneNode);
sceneNode->setTriangleSelector(collisionSelector);
collisionSelector->drop();
timer = ZOMBIE_IDLE_TIME;
currentHealth = ZOMBIE_MAX_HEALTH;
removeMe = false;
attackDelay = 0;
}
示例12: getIView
// init
// run when init object
void CPlayerComponent::initComponent()
{
m_collada = (CColladaMeshComponent*)m_gameObject->getComponent( IObjectComponent::ColladaMesh );
// load model by character id
CGameConfig::SCharacterInfo *charInfo = CGameConfig::getInstance()->getCharacterInfo(m_charID);
// load model
m_collada->loadScene(charInfo->model.c_str() );
// load animation
CColladaAnimationFactory* animFactory = CColladaAnimationFactory::getInstance();
m_animationPackage = animFactory->getAnimation( charInfo->name.c_str() );
if ( m_animationPackage == NULL )
m_animationPackage = animFactory->loadAnimation( charInfo->name.c_str(), getIView()->getPath(charInfo->anim));
m_collada->setAnimationPackage( m_animationPackage );
// apply lod
for (int i = 0, n = (int)charInfo->lods.size(); i < n; i++)
m_collada->addLodData( charInfo->lods[i].distance, charInfo->lods[i].node.c_str() );
init(m_gameObject);
// register event
getIView()->registerEvent("CPlayerComponent", this);
// init lua player component
char luaObjName[64];
sprintf(luaObjName, "CPlayerComp_%ld", m_gameObject->getID());
m_luaObjName = luaObjName;
// init collision
ISceneManager *smgr = getIView()->getSceneMgr();
ITriangleSelector *selector = smgr->createTriangleSelectorFromBoundingBox(m_gameObject->getSceneNode());
m_gameObject->getSceneNode()->setTriangleSelector(selector);
selector->drop();
CGameObject *zone = (CGameObject*)m_gameObject->getParent();
if ( zone && zone->getObjectType() == CGameObject::ZoneObject )
((CZone*)zone)->registerCollideObj( m_gameObject);
}
示例13: AnimatedNode
Character::Character(ISceneNode * parent,
ISceneManager * manager,
s32 id,
ISoundEngine * soundEngine,
vector3df offset,
const std::string name,
const char * modelPath,
int level)
: AnimatedNode(),
ISceneNode(parent, manager, id, offset),
SoundEmmitter(soundEngine) {
cout<<"To entrando em char"<<endl;
//vector3df center = getAnimatedNode()->getBoundingBox().getCenter();
//size_ = dimension2df(getPosition().X + center.X, getPosition().Z + center.Z);
name_ = name;
level_ = level;
maxHP_ = 1;
moveSpeed_ = DEFAULT_CHARACTER_MOVESPEED;
healthBar_ = new Bar(this, manager);
fillHP();
IAnimatedMesh * mesh = getSceneManager()->getMesh(modelPath);
cout<<"Loaded char model"<<endl;
setNode(getSceneManager()->addAnimatedMeshSceneNode(mesh, this, getID()));
cout<<"Setted char node"<<endl;
vector3df center = getAnimatedNode()->getBoundingBox().getCenter();
ITriangleSelector* selector = getSceneManager()->createOctreeTriangleSelector(mesh, getAnimatedNode());
getAnimatedNode()->setTriangleSelector(selector);
selector->drop();
cout<<"accessed animatedNode"<<endl;
f32 x = max_(center.X, center.Z);
setSize(dimension2df(2 * x, 2 * center.Y));
cout<<"settedsize"<<endl;
}
示例14: getIView
// 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;
}
}
//.........这里部分代码省略.........
示例15: testGetCollisionResultPosition
static bool testGetCollisionResultPosition(IrrlichtDevice * device,
ISceneManager * smgr,
ISceneCollisionManager * collMgr)
{
IMeshSceneNode * cubeNode = smgr->addCubeSceneNode(10.f);
ITriangleSelector * cubeSelector = smgr->createTriangleSelectorFromBoundingBox(cubeNode);
triangle3df triOut;
vector3df hitPosition;
bool falling;
ISceneNode* hitNode;
vector3df resultPosition =
collMgr->getCollisionResultPosition(cubeSelector,
vector3df(0, 50, 0),
vector3df(10, 20, 10),
vector3df(0, -100, 0),
triOut,
hitPosition,
falling,
hitNode);
bool result = true;
if(hitNode != cubeNode)
{
logTestString("Unexpected collision node\n");
result = false;
}
if(!equals(resultPosition.Y, 25.f, 0.01f))
{
logTestString("Unexpected collision response position\n");
result = false;
}
if(!equals(hitPosition.Y, 5.f, 0.01f))
{
logTestString("Unexpected collision position\n");
result = false;
}
resultPosition =
collMgr->getCollisionResultPosition(cubeSelector,
vector3df(-20, 0, 0),
vector3df(10, 20, 10),
vector3df(100, 0, 0),
triOut,
hitPosition,
falling,
hitNode);
if(hitNode != cubeNode)
{
logTestString("Unexpected collision node\n");
result = false;
}
if(!equals(resultPosition.X, -15.f, 0.01f))
{
logTestString("Unexpected collision response position\n");
result = false;
}
if(!equals(hitPosition.X, -5.f, 0.01f))
{
logTestString("Unexpected collision position\n");
result = false;
}
assert(result);
cubeSelector->drop();
smgr->clear();
return result;
}