Triangle selector on a plane?
Posted: Thu Feb 27, 2020 7:07 am
I do the following in order to create planes and send only one draw call for every single one of them
You might've noticed I do not create any IAnimateMesh to render the world, therefor I cannot pass that into a scene::ITriangleSelector. How do I go about solving this issue? The goal is to get the planes to highlight when the player looks at them and they are within range (let say 25 length units) of the camera. I want the whole plane to highlight, not just a triangle of the plane, and not the whole sum of the planes either (by that I mean I do not want to slap a single triangle selector on the mesh so all planes highlight when you look at any of them).
Code: Select all
device->getCursorControl()->setVisible(false);
irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNodeFPS();
cam->setPosition(irr::core::vector3df(10, 30, 10));
irr::video::ITexture * myTex = driver->getTexture("ground.png");
const irr::scene::IGeometryCreator *geomentryCreator = smgr->getGeometryCreator();
CBatchingMesh *BatchingMesh = new CBatchingMesh();
for(int x = 0; x < 100; x++) {
for(int z = 0; z < 50; z++) {
irr::scene::IMesh* plane = geomentryCreator->createPlaneMesh(irr::core::dimension2d<irr::f32>(5, 5), irr::core::dimension2d<irr::u32>(1, 1));
plane->getMeshBuffer(0)->getMaterial().setTexture(0, driver->getTexture("ground.png"));
BatchingMesh->addMesh(plane, core::vector3df(5*x, 0, 5*z));
}
}
BatchingMesh->update();
BatchingMesh->setMaterialFlag(EMF_LIGHTING, false);
BatchingMesh->setHardwareMappingHint(EHM_STREAM, EBT_VERTEX_AND_INDEX);
ISceneNode *node = smgr->addMeshSceneNode(BatchingMesh);
node->setScale(core::vector3df(1, 1, 1));
node->setDebugDataVisible(EDS_BBOX_BUFFERS);
BatchingMesh->drop();