本文整理汇总了C++中ISceneManager::getSceneCollisionManager方法的典型用法代码示例。如果您正苦于以下问题:C++ ISceneManager::getSceneCollisionManager方法的具体用法?C++ ISceneManager::getSceneCollisionManager怎么用?C++ ISceneManager::getSceneCollisionManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISceneManager
的用法示例。
在下文中一共展示了ISceneManager::getSceneCollisionManager方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sceneCollisionManager
/** Test functionality of the sceneCollisionManager */
bool sceneCollisionManager(void)
{
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(160, 120));
assert(device);
if(!device)
return false;
ISceneManager * smgr = device->getSceneManager();
ISceneCollisionManager * collMgr = smgr->getSceneCollisionManager();
bool result = testGetCollisionResultPosition(device, smgr, collMgr);
smgr->clear();
result &= testGetSceneNodeFromScreenCoordinatesBB(device, smgr, collMgr);
result &= getScaledPickedNodeBB(device, smgr, collMgr);
result &= getCollisionPoint_ignoreTriangleVertices(device, smgr, collMgr);
result &= checkBBoxIntersection(device, smgr);
result &= compareGetSceneNodeFromRayBBWithBBIntersectsWithLine(device, smgr, collMgr);
device->closeDevice();
device->run();
device->drop();
return result;
}
示例2: selectObject
// selectObject
// detect list objs at rect
void CDocument::selectObject( int x, int y, int w, int h, bool isControlHold )
{
IView *pView = getIView();
ISceneManager *smgr = pView->getSceneMgr();
ICameraSceneNode *camera = smgr->getActiveCamera();
// if no camera
if ( camera == NULL )
return;
const SViewFrustum* viewFrustum = camera->getViewFrustum();
ISceneCollisionManager *collMan = smgr->getSceneCollisionManager();
int screenX = -1, screenY = -1;
ArrayZoneIter iZone = m_zones.begin(), iEnd = m_zones.end();
while ( iZone != iEnd )
{
ArrayGameObject* listObj = (*iZone)->getChilds();
ArrayGameObjectIter iObj = listObj->begin(), objEnd = listObj->end();
ISceneNode *pNode = NULL;
while ( iObj != objEnd )
{
CGameObject *pGameObj = (CGameObject*)(*iObj);
pNode = pGameObj->getSceneNode();
if ( pNode != NULL && pGameObj->isVisible() )
{
core::vector3df center = pGameObj->getPosition();
// check object is in frustum
if ( viewFrustum->getBoundingBox().isPointInside( center ) )
{
if ( pView->getScreenCoordinatesFrom3DPosition( center, &screenX, &screenY ) )
{
if ( x <= screenX && screenX <= x + w && y <= screenY && screenY <= y + h )
{
if ( isControlHold == false || pGameObj->getObjectState() == CGameObject::Normal )
m_selectObjects.push_back( pGameObj );
} // inselect
} // getScreenCoordinatesFrom3DPosition
} // frustum
}
iObj++;
}
iZone++;
}
}
示例3: 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;
//.........这里部分代码省略.........
示例4: update
void CDR::update(NBEditor* editor, bool drag, rect<s32> offset)
{
if (!editor->state->project) {
return;
}
if (!editor->state->settings->getBool("always_show_position_handle") &&
(editor->state->keys[KEY_LSHIFT] == EKS_UP) ==
(type == CDR_XY || type == CDR_XZ || type == CDR_ZY)) {
return;
}
Node* node = editor->state->project->GetCurrentNode();
if (!node) {
return;
}
NodeBox *box = node->GetCurrentNodeBox();
if (!box) {
return;
}
ISceneManager * smgr = editor->state->device->getSceneManager();
if (drag) {
// get mouse position
position2di target = editor->state->mouse_position;
target -= offset.UpperLeftCorner;
// Get the ray
line3d<irr::f32> ray = smgr->getSceneCollisionManager()
->getRayFromScreenCoordinates(target, smgr->getActiveCamera());
// Contains the output values
vector3df wpos = vector3df(0, 0, 0); // The collision position
// Not used, but required for function
#if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8
const ISceneNode* tmpNode;
#else
ISceneNode* tmpNode;
#endif
triangle3df tmpTri;
// Execute ray
smgr->getSceneCollisionManager()->getCollisionPoint(ray,
editor->state->plane_tri, wpos, tmpTri, tmpNode);
// Snapping
wpos -= vector3df(node->position.X, node->position.Y, node->position.Z);
if (window == VIEW_XZ)
wpos.Z -= 0.1;
if (editor->state->settings->getBool("snapping")) {
wpos.X = floor((wpos.X + 0.5) * 16 + 0.5) / 16 - 0.5;
wpos.Y = floor((wpos.Y + 0.5) * 16 + 0.5) / 16 - 0.5;
wpos.Z = floor((wpos.Z + 0.5) * 16 + 0.5) / 16 - 0.5;
}
// Do node limiting
if (editor->state->settings->getBool("limiting")) {
// X Axis
if (wpos.X < -0.5) {
wpos.X = -0.5;
} else if (wpos.X > 0.5) {
wpos.X = 0.5;
}
// Y Axis
if (wpos.Y < -0.5) {
wpos.Y = -0.5;
} else if (wpos.Y > 0.5) {
wpos.Y = 0.5;
}
// Z Axis
if (wpos.Z < -0.5) {
wpos.Z = -0.5;
} else if (wpos.Z > 0.5) {
wpos.Z = 0.5;
}
}
// Call required function
if (type < CDR_XZ) {
box->resizeNodeBoxFace(editor->state, type, wpos,
editor->state->keys[KEY_LCONTROL] == EKS_DOWN);
} else {
box->moveNodeBox(editor->state, type, wpos);
}
node->remesh();
editor->triggerCDRmoved();
}
vector3df pos = box->GetCenter();
switch (type) {
//.........这里部分代码省略.........
示例5: main
int main(int argc, char** argv) {
CustomEventReceiver receiver;
IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(800, 600), 16, false, false, false, &receiver);
if (!device) {
return EXIT_FAILURE;
}
device->setWindowCaption(L"Solar System Simulator");
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* sceneManager = device->getSceneManager();
scene::ISceneCollisionManager* collisionManager= sceneManager->getSceneCollisionManager();
IGUIEnvironment* guiEnv = device->getGUIEnvironment();
guiEnv->addStaticText(L"Click on a planet to attach the camera to it", rect<s32>(10,10,260,22), false);
sf::SoundBuffer buffer;
if (buffer.loadFromFile(currentPath() + "/sounds/burning.aif")) {
sf::Listener::setPosition(0, 0,0);
sf::Sound sound;
sound.setBuffer(buffer);
sound.setPosition(0, 0, 0);
sound.setLoop(true);
sound.play();
}
const char* spaceTexturePath = ( currentPath() + "/textures/space.jpg" ).c_str();
video::ITexture* space = driver->getTexture(spaceTexturePath);
scene::ISceneNode* skybox = sceneManager->addSkyBoxSceneNode(space, space, space, space, space, space);
sceneManager->addLightSceneNode(0, vector3df(0, 0, -50), video::SColorf(1.0f, 1.0f, 1.0f), 50.0f, 1001);
PlanetFactory planetFactory(sceneManager, driver);
Planet sun = planetFactory.create(PlanetId::Sun);
Planet earth = planetFactory.create(PlanetId::Earth);
Planet pluto = planetFactory.create(PlanetId::Pluto);
Planet jupiter = planetFactory.create(PlanetId::Jupiter);
Planet uranus = planetFactory.create(PlanetId::Uranus);
Planet neptune = planetFactory.create(PlanetId::Neptune);
vector<Planet> planets = { sun, planetFactory.create(PlanetId::Mercury) };
planets.push_back(planetFactory.create(PlanetId::Venus));
planets.push_back(earth);
planets.push_back(planetFactory.create(PlanetId::Mars));
planets.push_back(jupiter);
planets.push_back(planetFactory.create(PlanetId::Saturn));
planets.push_back(uranus);
planets.push_back(neptune);
planets.push_back(pluto);
ICameraSceneNode* camera = sceneManager->addCameraSceneNode(0, vector3df(0,0,40), vector3df(0,0,0));
rect<s32> mainCameraViewPortRect(0, 0, 800, 600);
ICameraSceneNode* topViewCamera = sceneManager->addCameraSceneNode(0, vector3df(0,50,0), vector3df(0,0,0));
sceneManager->setAmbientLight(video::SColorf(255.0,255.0,255.0));
ISceneNode* selectedNode = sun.node;
while(device->run()) {
if(receiver.GetMouseState().LeftButtonDown) {
position2di mousepos = receiver.GetMouseState().Position;
line3df ray = sceneManager->getSceneCollisionManager()->getRayFromScreenCoordinates( mousepos, camera);
vector3df intersection;
triangle3df tri;
for(Planet& planet : planets) {
ITriangleSelector* wselector = sceneManager->createTriangleSelectorFromBoundingBox(planet.node);
if (collisionManager->getCollisionPoint(ray, wselector, intersection, tri, planet.node)) {
selectedNode = planet.node;
}
wselector->drop();
}
}
camera->setTarget(selectedNode->getAbsolutePosition());
skybox->setVisible(true);
driver->setViewPort(mainCameraViewPortRect);
driver->beginScene(true, true, SColor(255,100,101,140));
sceneManager->setActiveCamera(camera);
sceneManager->drawAll();
guiEnv->drawAll();
driver->setViewPort(rect<s32>(0, 380, 200, 600));
driver->draw2DRectangle(SColor(100,0,0,190), mainCameraViewPortRect);
skybox->setVisible(false);
sceneManager->setActiveCamera(topViewCamera);
sceneManager->drawAll();
driver->endScene();
}
device->drop();
return EXIT_SUCCESS;
}