[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 » Sun Mar 17, 2019 2:00 am

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,
0 x


rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly » Sun Mar 17, 2019 11:57 pm

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?
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1034
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 68

Re: [2.1] Select triangle in a mesh.

Post by xrgo » Mon Mar 18, 2019 12:11 am

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

its working with 2.1 and 2.2
0 x

rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly » Sun Mar 31, 2019 8:08 pm

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?
0 x

xrgo
OGRE Expert User
OGRE Expert User
Posts: 1034
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 68

Re: [2.1] Select triangle in a mesh.

Post by xrgo » Sun Mar 31, 2019 9:30 pm

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]
0 x

rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly » Sun Mar 31, 2019 10:39 pm

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.
0 x

rrlangly
Gnoblar
Posts: 19
Joined: Sat Jan 24, 2009 8:27 pm

Re: [2.1] Select triangle in a mesh.

Post by rrlangly » Sun Apr 14, 2019 1:18 am

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?
0 x

Post Reply