Page 1 of 1

[2.1] Select triangle in a mesh.

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

Re: [2.1] Select triangle in a mesh.

Posted: Sun Mar 17, 2019 2:25 pm
by paroj

Re: [2.1] Select triangle in a mesh.

Posted: Sun Mar 17, 2019 11:57 pm
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?

Re: [2.1] Select triangle in a mesh.

Posted: Mon Mar 18, 2019 12:11 am
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

Re: [2.1] Select triangle in a mesh.

Posted: Sun Mar 31, 2019 8:08 pm
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?

Re: [2.1] Select triangle in a mesh.

Posted: Sun Mar 31, 2019 9:30 pm
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]

Re: [2.1] Select triangle in a mesh.

Posted: Sun Mar 31, 2019 10:39 pm
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.

Re: [2.1] Select triangle in a mesh.

Posted: Sun Apr 14, 2019 1:18 am
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?