Howto transform worldcoordinates into screencoordinates
Howto transform worldcoordinates into screencoordinates
Hi everyone.
First I want to ask if anyone can become a member in this forum. I tried to register but it keeps telling me that my "Confirm password" is wrong. I have even copy and paste the same word from an external text document and it still complains. Is it me who is doing something wrong?
Secound I want to ask if there is any way to transform the world coordinates into screen coordinates.
So if i have an object in the top left corner of the window I want to get the coordinates (0,0) and not the coordinates in the world ex (10,0,200)
Third and last question. Is it possible to transform the mouse coordinats into the 3d world. If the mouse is in the top left corner of the screen, its coordinats is (0,0). Can you get the that coordinat into what polygons it is touching like (10,100,25) depending on the camera
First I want to ask if anyone can become a member in this forum. I tried to register but it keeps telling me that my "Confirm password" is wrong. I have even copy and paste the same word from an external text document and it still complains. Is it me who is doing something wrong?
Secound I want to ask if there is any way to transform the world coordinates into screen coordinates.
So if i have an object in the top left corner of the window I want to get the coordinates (0,0) and not the coordinates in the world ex (10,0,200)
Third and last question. Is it possible to transform the mouse coordinats into the 3d world. If the mouse is in the top left corner of the screen, its coordinats is (0,0). Can you get the that coordinat into what polygons it is touching like (10,100,25) depending on the camera
First... What on earth is stopping you from using a search tool [Start | Search | All files and folders on windows or grep on *nix] to look for a method by that name in the include directory? That would only take you like 3 seconds to do and you'd have the answer immediately.
Second... What about the documentation? Given the method name, you can find out information about it there... You can find the docshere. Click Class members and then 'g'.
Third... You most definitely would not get a nasty runtime error from the posted code. It would never compile. You would get a nasty compile error.
Travis
Second... What about the documentation? Given the method name, you can find out information about it there... You can find the docshere. Click Class members and then 'g'.
Third... You most definitely would not get a nasty runtime error from the posted code. It would never compile. You would get a nasty compile error.
Travis
-
- Posts: 322
- Joined: Tue Aug 30, 2005 10:34 am
- Location: slovakia
multiply the world vector with world-view-projection matrix, get the matrix like this:
core::matrix4 matWorldViewProjection;
matWorldViewProjection = driver->getTransform(video::ETS_PROJECTION);
matWorldViewProjection *= driver->getTransform(video::ETS_VIEW);
matWorldViewProjection *= driver->getTransform(video::ETS_WORLD);
and then by doing matWorldViewProjection *= worldvector; you will get a 2 dimension vector beleived to be the screen(projectioin) coordinates ;
core::matrix4 matWorldViewProjection;
matWorldViewProjection = driver->getTransform(video::ETS_PROJECTION);
matWorldViewProjection *= driver->getTransform(video::ETS_VIEW);
matWorldViewProjection *= driver->getTransform(video::ETS_WORLD);
and then by doing matWorldViewProjection *= worldvector; you will get a 2 dimension vector beleived to be the screen(projectioin) coordinates ;
what is this thing...
To vitec...
If the windows search function lets me search for a frase inside of all text documents then perhaps you can tell me how I do that.
Secound, I DID look in the documentations first but I could not find it there because again, I can't search for a frase in all documenation files.
But I am sorry about the runtime error when I meant compile error...
If the windows search function lets me search for a frase inside of all text documents then perhaps you can tell me how I do that.
Secound, I DID look in the documentations first but I could not find it there because again, I can't search for a frase in all documenation files.
But I am sorry about the runtime error when I meant compile error...
If the windows search function lets me search for a frase inside of all text documents then perhaps you can tell me how I do that.
- click Start | Search | All files and folders
- Set All or part of the file name to *.h
- Set A word or phrase in the file to getScreenCoordinatesFrom3DPosition
- Set Look in to the path to the Irrlicht include directory
- click Search button
Why would you need to search. You know the name of the function you are looking for.Secound, I DID look in the documentations first but I could not find it there because again, I can't search for a frase in all documenation files.
- click http://irrlicht.sourceforge.net/docu/index.html
- click class members near the top of the page
- click functions
- click g
- use the search feature of your web browser [ctrl+f for internet explorer]
- search for getScreenCoordinatesFrom3DPosition
- click link to irr::scene::ISceneCollisionManager::getScreenCoordinatesFrom3DPosition(...)
I cant get this code to work. This time i get the runtime error, thanks vitek for clearing that up...
IAnimatedMesh* mesh = smgr->getMesh(*model*);
node = smgr->addAnimatedMeshSceneNode( mesh );
ICameraSceneNode* camera = smgr->addCameraSceneNode(*numbers*);
ISceneCollisionManager* scmgr = 0;
position2d<s32> pos = scmgr->getScreenCoordinatesFrom3DPosition(node->getPosition(),camera);
PS. Im to lazy to use the debuger...
Please help me anyway...
IAnimatedMesh* mesh = smgr->getMesh(*model*);
node = smgr->addAnimatedMeshSceneNode( mesh );
ICameraSceneNode* camera = smgr->addCameraSceneNode(*numbers*);
ISceneCollisionManager* scmgr = 0;
position2d<s32> pos = scmgr->getScreenCoordinatesFrom3DPosition(node->getPosition(),camera);
PS. Im to lazy to use the debuger...
Please help me anyway...
The use your brain.Big-Laser-Gun wrote:ISceneCollisionManager* scmgr = 0;
position2d<s32> pos = scmgr->getScreenCoordinatesFrom3DPosition(node->getPosition(),camera);
You create a new pointer and initialize it with NULL:
ISceneCollisionManager* scmgr = 0;
In the next line, you want to access a member of the SceneCollisionManager with a nullpointer: CRASH.
Regards - Xaron
Just do:
...edited, because of my fault.
Regards - Xaron
Code: Select all
position2d<s32> pos = smgr->getSceneCollisionManager()->getScreenCoordinatesFrom3DPosition(node->getPosition(),camera);
Regards - Xaron
Last edited by Xaron on Fri Feb 24, 2006 10:15 am, edited 1 time in total.
Code: Select all
scene::ISceneManager* smgr = device->getSceneManager();
ISceneCollisionManager* scmgr = smgr->getSceneCollisionManager();