__bf_ddc__
15-10-2007 14:54:31
Hello again.
I'm trying to port old code to new on mouse-picking in a 3D space. It was originally working rather similarly to what I've seen on the new samples. But for some reason it never hits.
Does anything need to be initialised along with when the bodies are being constructed to be able to be picked? Or am I just doing something silly?
The old code was rather similar, in creating a Ray with the x&y coords of the current mouse [0-1floating point] then calling getCameraToViewportRay on the camera. And the old function createRayCaster pretty much takes the same params as the new, an origin, direction and length of raycast -- getClosestRaycastHit then usually netted a perfectly fine result.
Though now everything works fine, just after castShape() call it doesn't net any results and the mReport.count() is usually zero.
Thanks in advance. This will be the last part of converting to new code on my project.
I'm trying to port old code to new on mouse-picking in a 3D space. It was originally working rather similarly to what I've seen on the new samples. But for some reason it never hits.
Real x = (CEGUI::MouseCursor::getSingleton().getPosition().d_x / m_pWindow->getWidth());
Real y = (CEGUI::MouseCursor::getSingleton().getPosition().d_y / m_pWindow->getHeight());
Ray mouseRay = m_pCamera->getCameraToViewportRay(x, y);
m_pMouseRaycast = new RayCaster(mouseRay.getOrigin(), mouseRay.getDirection().normalisedCopy(), MAX_RAYCAST, RayCaster::RCT_CLOSEST, m_pScene);
m_pMouseRaycast->castShape(RayCaster::AF_NONE);
Actor *actor = m_pMouseRaycast->getClosestActor();
.
.
.
Does anything need to be initialised along with when the bodies are being constructed to be able to be picked? Or am I just doing something silly?
The old code was rather similar, in creating a Ray with the x&y coords of the current mouse [0-1floating point] then calling getCameraToViewportRay on the camera. And the old function createRayCaster pretty much takes the same params as the new, an origin, direction and length of raycast -- getClosestRaycastHit then usually netted a perfectly fine result.
Though now everything works fine, just after castShape() call it doesn't net any results and the mReport.count() is usually zero.
Thanks in advance. This will be the last part of converting to new code on my project.