But AxisAlignedBox is still remained in Ogre 2.1.
So I got this problem: I want to simple raycast a plane
1st, Create plane (If there is a way to create direct plane in Ogre 2.1 please teach me how, I absolutely need it)
Code: Select all
/*Create plane*/
float nPlaneCx;
float nPlaneCy;
float nPlaneX;
float nPlaneY;
nPlaneCx = nPlaneCy = 300;
nPlaneX = 0;
nPlaneY = 0;
Ogre::v1::MeshManager::getSingleton().createPlane("MyPlane",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::Plane(Ogre::Vector3::UNIT_Y, 1.0f), nPlaneCx, nPlaneCy,
1, 1, true, 1, 8.1f, 8.12f, Ogre::Vector3::UNIT_Z,
Ogre::v1::HardwareBuffer::HBU_STATIC,
Ogre::v1::HardwareBuffer::HBU_STATIC);
Ogre::v1::MeshPtr v1Mesh;
Ogre::MeshPtr v2Mesh;
v1Mesh = Ogre::v1::MeshManager::getSingleton().load(
"MyPlane", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME,
Ogre::v1::HardwareBuffer::HBU_STATIC, Ogre::v1::HardwareBuffer::HBU_STATIC);
//Create a v2 mesh to import to, with a different name (arbitrary).
v2Mesh = Ogre::MeshManager::getSingleton().createManual(
"Plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
v2Mesh->importV1(v1Mesh.get(), true, true, true);
//Free memory
v1Mesh->unload();
Ogre::v1::MeshManager::getSingleton().remove("MyPlane");
m_pItemPlane = m_pScnMgr->createItem(
"Plane", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::SCENE_STATIC);
m_pItemPlane->setDatablock("Rocks");
Ogre::HlmsManager *hlmsManager = mGraphicsSystem->getRoot()->getHlmsManager();
Ogre::Hlms *hlms = hlmsManager->getHlms(Ogre::HLMS_PBS);
Ogre::HlmsPbsDatablock *datablock = static_cast<Ogre::HlmsPbsDatablock*>(
hlms->getDatablock("Rocks"));
for (size_t i = Ogre::PBSM_DIFFUSE; i <= Ogre::PBSM_ROUGHNESS; ++i)
{
Ogre::HlmsSamplerblock samplerblock;
samplerblock.mU = Ogre::TAM_WRAP;
samplerblock.mV = Ogre::TAM_WRAP;
datablock->setSamplerblock(static_cast<Ogre::PbsTextureTypes>(i), samplerblock);
}
m_pNodePlane = m_pScnMgr->getRootSceneNode(Ogre::SCENE_STATIC)->
createChildSceneNode(Ogre::SCENE_STATIC);
m_pNodePlane->setPosition(nPlaneX, -3.6, nPlaneY);
m_pNodePlane->attachObject(m_pItemPlane);
Code: Select all
void EmptyProjectGameState::mousePressed(const SDL_MouseButtonEvent &arg, Ogre::uint8 id)
{
int width = mGraphicsSystem->getRenderWindow()->getWidth();
int height = mGraphicsSystem->getRenderWindow()->getHeight();
Ogre::Real mouseX = (Ogre::Real)arg.x / (Ogre::Real)width;
Ogre::Real mouseY = (Ogre::Real)arg.y / (Ogre::Real)height;
Ogre::Ray ray = m_pCam->getCameraToViewportRay(mouseX, mouseY);
Ogre::Aabb box = m_pItemPlane->getWorldAabb();
Ogre::AxisAlignedBox oldBox = box; //Error, need convert here :(
ray.intersects(oldBox);
Any input is appreciated