nargil
22-08-2008 00:45:17
I found a solution, but still this needs to be fixed
First of all i know the raycasting was giving reverse order actors. I fixed it as stated in the forums
It seemed to work for a really simple scene. Now i created my editors movement arrows and can't get accurate raycasting on them.
This is how my scene does look like:
here is my raycasting code
Now the problem is that some actors are still reversed. For example when i move the cursor over the square connecting red and green arrow in a point where it can be the only actor hit by the ray - everything is ok
Now i lower the cursor and the background square is being selected, although it shouldn't - it's behing the previously highlighted square.
Someone could say: "ok you got an reversed raycast order", but its not the point - this doesn't happen for the square connecting green and blue arrow
Now someone could say: "ok - there is something wrong with the square that connects the red and green arrow, but there is also a bug with the green-blue connecting square. Lets rotate the camera:
The squares in the background aren't being selected - its fine:
but the red arrow is... just look:
However changing the raycaster from NxOgre::RayCaster::RCT_ALL to NxOgre::RayCaster::RCT_CLOSEST fixes the problem - so i can go ahead with my work.
Good luck fixing it :>
First of all i know the raycasting was giving reverse order actors. I fixed it as stated in the forums
Actor* RayCaster::getClosestActor() {
if (mReport.count() == 0)
return 0;
RayCastReport::Iterator mIterator = mReport.mItems.end();
mIterator--;
return (*mIterator).second.t.mActor;
}
It seemed to work for a really simple scene. Now i created my editors movement arrows and can't get accurate raycasting on them.
This is how my scene does look like:
here is my raycasting code
Ogre::Ray mray = cam->getCameraToViewportRay(x, y);
NxOgre::RayCaster* mRay = new NxOgre::RayCaster(mray.getOrigin(), mray.getDirection(), 10000, NxOgre::RayCaster::RCT_ALL, mEngine->mScene);
if (mRay->castShape(NxOgre::RayCaster::AF_NONE))
{
Vector3 hitpos = mRay->getClosestRaycastHit().mWorldImpact;
NxOgre::Body* actor = (NxOgre::Body*)((mRay->getClosestRaycastHit().mActor));
mStrzalki->raycast(actor->getName());
}
delete mRay;
Now the problem is that some actors are still reversed. For example when i move the cursor over the square connecting red and green arrow in a point where it can be the only actor hit by the ray - everything is ok
Now i lower the cursor and the background square is being selected, although it shouldn't - it's behing the previously highlighted square.
Someone could say: "ok you got an reversed raycast order", but its not the point - this doesn't happen for the square connecting green and blue arrow
Now someone could say: "ok - there is something wrong with the square that connects the red and green arrow, but there is also a bug with the green-blue connecting square. Lets rotate the camera:
The squares in the background aren't being selected - its fine:
but the red arrow is... just look:
However changing the raycaster from NxOgre::RayCaster::RCT_ALL to NxOgre::RayCaster::RCT_CLOSEST fixes the problem - so i can go ahead with my work.
Good luck fixing it :>