[2.1] Select triangle in a mesh.

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

[2.1] Select triangle in a mesh.

Post by rrlangly »

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,
rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly »

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?
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: [2.1] Select triangle in a mesh.

Post by xrgo »

This is the class I have in my engine, its based on paroj's link

its working with 2.1 and 2.2
rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly »

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?
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: [2.1] Select triangle in a mesh.

Post by xrgo »

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]
rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly »

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.
rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly »

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?

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));
	// ...
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]
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?
Post Reply