I'm not sure if it's the raycast or a math problem, but with orthogonal projection off the sphere stays attached to the cursor on a plane when you move the cursor around the spheres stays with it, but as soon as I set the cam to ortho the sphere doesn't follow, it moves in the same direction as the cursor but it doesn't move as far? Here is the code I'm using:
// Create a ray through the mouse cursor.
line3df ray = ezgame.scene()->getSceneCollisionManager()->getRayFromScreenCoordinates(position2d<s32>(ezgame.getCursorPosition()), camera);
plane3df plane(ball->getPosition(), vector3df(0, -1, 0));
vector3df mousePosition;
if(plane.getIntersectionWithLine(ray.start, ray.getVector(), mousePosition))
{
float rect_x = (ball->getPosition().X - mousePosition.X);
float rect_z = (ball->getPosition().Z - mousePosition.Z);
ball->setPosition(core::vector3df(mousePosition.X ,0, mousePosition.Z));
}
I'm just not entirely sure why changing the cam to ortho looses the ray cast? I thought using getRayFromScreenCoordinates was the currect function for ortho cams?
I'm not sure if it's the raycast or a math problem, but with orthogonal projection off the sphere stays attached to the cursor on a plane when you move the cursor around the spheres stays with it, but as soon as I set the cam to ortho the sphere doesn't follow, it moves in the same direction as the cursor but it doesn't move as far? Here is the code I'm using:
aha !
sorry but could you try to pharase that question again into 3 or four coherent sentences please... I got a little confused with all the commas.
edit:
after reading the code I could understand what you are trying to say, but the question is somehow phrased odd, to say the least. And sorry, I can't help you, I never tried that so far...
if i switch to a orthogonal camera, it doesn't find any objects, but works with a normal camera
I think this is a similar problem, I basically don't know how to pass the raycast cursor position to the node when the camera matrix is set to Orthogonal? The screen debug I'm printing says that the cursor x and z is the same as the node's x and z, yet the node only moves a fraction of the distance compared to the cursor?
Okay it's to do with the fact that the coordinates are correct It's just that the camera is drawing everything without perspective, which is a bit of a worry because does that mean we have to fudge the code to get the node into the same screen position as the cursor? Like this:
if(plane.getIntersectionWithLine(ray.start, ray.getVector(), mousePosition))
{
float x = (ball->getPosition().X - mousePosition.X)*4;
float z = (ball->getPosition().Z - mousePosition.Z)*4;
ball->setPosition(core::vector3df(x ,0, z));
}
I've also corrected my code, I made a stupid mistake and didn't use the variables I was creating in the if statement, I tend to make silly mistakes like this now and then I'm also quite new to screen to world coordinate conversions.
No.
And Yes I got a basic idea of your problem after reading the code, but the question itself was completely riddling for me, sorry.
Edit:
And sorry again, I really didn't try to mock you, I just had to laugh about that incomprehensible giant senctece of yours... Basically if the question is phrased like that, most people won't read the code in the first place.
zillion42 wrote:No.
And Yes I got a basic idea of your problem after reading the code, but the question itself was completely riddling for me, sorry.
Edit:
And sorry again, I really didn't try to mock you, I just had to laugh about that incomprehensible giant senctece of yours... Basically if the question is phrased like that, most people won't read the code in the first place.
LOL!!! It is pretty bad isn't it I had to rush it though.
zillion42 wrote:No.
And Yes I got a basic idea of your problem after reading the code, but the question itself was completely riddling for me, sorry.
Edit:
And sorry again, I really didn't try to mock you, I just had to laugh about that incomprehensible giant senctece of yours... Basically if the question is phrased like that, most people won't read the code in the first place.
LOL!!! It is pretty bad isn't it I had to rush it though.