I am using 2.1 on linux and have a mesh drawn as a manual object and I'd like to select a single triangle in the mesh using the mouse so that I can operate on it. How does one go about doing that? References, examples?
Thanks,
[2.1] Select triangle in a mesh.
-
- OGRE Team Member
- Posts: 2151
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1156
-
- Gnoblar
- Posts: 19
- Joined: Sat Jan 24, 2009 8:27 pm
Re: [2.1] Select triangle in a mesh.
So I take it I would follow the "Manual Object GetMeshInformation()" section since I draw manual objects? And this is good for Ogre 2.1?
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Select triangle in a mesh.
This is the class I have in my engine, its based on paroj's link
its working with 2.1 and 2.2
its working with 2.1 and 2.2
-
- Gnoblar
- Posts: 19
- Joined: Sat Jan 24, 2009 8:27 pm
Re: [2.1] Select triangle in a mesh.
Just one question. The ray that I setup to test, is that from the mouse coordinates and into the view? It looks like there's the point, and the normal when creating the ray. But since there's no normal where the mouse is (or I guess the camera) ... it must be a point on the model and the surface normal I select? can someone explain this part?
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Select triangle in a mesh.
not sure I understand the question.. is this what you're looking for? Ogre::Camera::getCameraToViewportRay(screenx, screeny) you have to convert somehow your cursor coordinates to [0,1]
-
- Gnoblar
- Posts: 19
- Joined: Sat Jan 24, 2009 8:27 pm
Re: [2.1] Select triangle in a mesh.
Yes, I believe that's what I'm looking for.
Now I just need to figure out how to integrate that into those examples. I'm guessing somehow I need to capture a click on the Ogre canvas like a mouse press event, and pass in that x and y.
Now I just need to figure out how to integrate that into those examples. I'm guessing somehow I need to capture a click on the Ogre canvas like a mouse press event, and pass in that x and y.
-
- Gnoblar
- Posts: 19
- Joined: Sat Jan 24, 2009 8:27 pm
Re: [2.1] Select triangle in a mesh.
Still not understanding this. I'll add more detail. I'm trying to create a raycast from a point in to the scene. From the following link ...
http://wiki.ogre3d.org/Raycasting+to+the+polygon+level
... in doing the method for the raycast, where does the point and normal come from that gets passed in?
http://wiki.ogre3d.org/Raycasting+to+the+polygon+level
... in doing the method for the raycast, where does the point and normal come from that gets passed in?
Code: Select all
bool OgreVisionEngine::RaycastFromPoint(const Vector3 &point,
const Vector3 &normal,
Vector3 &result)
{
// create the ray to test
Ogre::Ray ray(Ogre::Vector3(point.x, point.y, point.z),
Ogre::Vector3(normal.x, normal.y, normal.z));
// ...
For what reason do I convert my coordinates to [0,1], and how do I pass that into a vector for the point and the normal?xrgo wrote: Sun Mar 31, 2019 9:30 pm ... Ogre::Camera::getCameraToViewportRay(screenx, screeny) you have to convert somehow your cursor coordinates to [0,1]