SetPosition from Cursor, slow!!! (on bottom half of screen)
SetPosition from Cursor, slow!!! (on bottom half of screen)
In my program there is a drag and drop feature which allows you to drag objects from the 2d library on to the 3d world.
It is a simple method that is called during the main loop, it uses getRayFromScreenCoordinates and a triangle selector to determine where, on the floor the mouse is pointing, then calls the setPosition method to put the object in the right place.
My problem is:
When dragging objects into the top half of the screen it is perfect.
But when I drag into the bottom half of the screen it becomes very jerky and unresponsive to the position of the mouse.
I cant think what is causing this problem, nevermind how to fix it. I dont see how the results returned from getCursorPosition (ie the Y value of the cursor) can affect the speed of the calculations for setting the position of a model in 3d space.
Any help would be greatly appreciated...
Thanks in advance,
John
It is a simple method that is called during the main loop, it uses getRayFromScreenCoordinates and a triangle selector to determine where, on the floor the mouse is pointing, then calls the setPosition method to put the object in the right place.
My problem is:
When dragging objects into the top half of the screen it is perfect.
But when I drag into the bottom half of the screen it becomes very jerky and unresponsive to the position of the mouse.
I cant think what is causing this problem, nevermind how to fix it. I dont see how the results returned from getCursorPosition (ie the Y value of the cursor) can affect the speed of the calculations for setting the position of a model in 3d space.
Any help would be greatly appreciated...
Thanks in advance,
John
That is pretty much what I am doing.
My drag and drop methods appear to be working fine.
My problem is with the drag method, which checks to see if a component is selected, and if it does it positions a node, which represents that component at the point on the floor in 3d world where the mouse is pointing.
I am thinking it is a 3d maths issue related with calculating the ray, or where it hits the floor that is the problem.
But I am really stuck for ideas so thanks alot for helping.
John
My drag and drop methods appear to be working fine.
My problem is with the drag method, which checks to see if a component is selected, and if it does it positions a node, which represents that component at the point on the floor in 3d world where the mouse is pointing.
I am thinking it is a 3d maths issue related with calculating the ray, or where it hits the floor that is the problem.
But I am really stuck for ideas so thanks alot for helping.
John
Hi
Sorry I thought I was being perfectly clear on what I am doing.
This code is executed between beginScene and endScene if the user is dragging the model in the 3d world.
I hope that helped
Sorry I thought I was being perfectly clear on what I am doing.
This code is executed between beginScene and endScene if the user is dragging the model in the 3d world.
Code: Select all
void dragModel()
{
//create a ray, from the camera through the cursor into the scene
cpos = cursor->getPosition();
line3d<f32> trace = colManager->getRayFromScreenCoordinates(cpos);
vector3df intersection;
triangle3df tri;
if (colManager->getCollisionPoint(trace, tris, intersection, tri))//if line collides with a triangle
{
if (node)//if node is already drawn
{
node->setPosition(vector3df(intersection.X,0,intersection.Z));
}
else
{
switch(componentNumber)
{
case 0:
{
mesh = smgr->getMesh("mesh1.3ds");
}
break;
case 1:
{
mesh = smgr->getMesh("mesh2.3ds");
}
break;
case 2:
{
mesh = smgr->getMesh("mesh3.3ds");
}
break;
}
node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialTexture( 0, driver->getTexture("../../media/can.bmp") );
}
}
}
I hope that helped
The terrain is displayed on the entire screen not just the bottom half. (apart from a small toolbox window which can be positioned anywhere on the screen)
Dragging the object is perfectly smooth on the top part of the screen, however when the object being dragged is in the bottom half of the screen it is unacceptably jerky.
I cant see any way to do this where collision detection is not done every frame, as I need to know whether the mouse pointer is over the terrain or not.
I dont understand why its perfectly fine when the mouse is in a certain position and then extremely slow when the mouse is in another position.
Dragging the object is perfectly smooth on the top part of the screen, however when the object being dragged is in the bottom half of the screen it is unacceptably jerky.
I cant see any way to do this where collision detection is not done every frame, as I need to know whether the mouse pointer is over the terrain or not.
I dont understand why its perfectly fine when the mouse is in a certain position and then extremely slow when the mouse is in another position.
Thanks for the help Mike,
I am running an AMD Athlon XP 1800 1 gig of ram and Gefore Ti 4400
I have just compared 1024x768 in 32million colours with 800x600 in 16 million colours and they are both equally jerky (in certain places, while smooth in others).
The thing that gets me is that in some places on the screen it is perfectly smooth, in others very laggy. This suggests to me that it is a bug in the code not a performance issue.
However I am an irrlicht newbie that is why I look to this forum for guidance.
I check this post every couple of hours hoping someone has responded, because I do not know what to do about this problem.
Thanks
John
I am running an AMD Athlon XP 1800 1 gig of ram and Gefore Ti 4400
I have just compared 1024x768 in 32million colours with 800x600 in 16 million colours and they are both equally jerky (in certain places, while smooth in others).
The thing that gets me is that in some places on the screen it is perfectly smooth, in others very laggy. This suggests to me that it is a bug in the code not a performance issue.
However I am an irrlicht newbie that is why I look to this forum for guidance.
I check this post every couple of hours hoping someone has responded, because I do not know what to do about this problem.
Thanks
John