Geometry Selection

Hey guys, this is my first post here, but I figured I needed a little bit of help with this code. So basically, I have a Shape, a StripBox. I am working on being able to “Select” the faces of the quad for some game related purposes. So basically, the thought occured me to create a red quad that sits on top of the face that I select. So I got that all working, basically I can select a face of the stripbox by clicking on it, and a red quad is placed on that face to show that it is infact selected.

Here is the problem, my technique only works when the shape is not rotated in any way. So basically I accomplish this by determining where the click landed on the surface and comparing it to the center and extent of the shape.

Is there any known way to select a specific face and also display the selection quad I want over that face easier than I am doing? Thank you!

Might be an awful solution depending on your needs, but maybe make 6 quads and add them to a node. You’d be able to easily change the color of the selected quad, and since they are in a node, you could rotate all of them as if they were just one cube by rotating the node instead.

Look at raycasting, there is a mousepick example in the examples,
it returns you the geomtry taht is clicked, regardless of rotations ect.

If you want to combine those quads,
one simple solution might be the use of a batchnode, as it retains the original geometrys for raycasting, but uses a combined one for rendering.

Empire Pheonix, that Batchnode solutions sounds decent enough, but loopies and empire I need the inside to be visible too (hence the stripbox), is there any solutions for the StripBox method, elsewise I might have to just go with the 6 quads.

either set the amterial to be faceculled on no side, or simply use 12 quads ^^ and batch them in batchnode.

Depends on how many you need of course.

Alternative, use the hitlocation of the raycast, to determine on wich side it can be (transform it into cube local space, then its a bunch of ifs)

I would rather use Box shape, because the whole point of the selection is actually to be able to edit the face of the mesh by bringing it out or in (extrusion), kinda like a 3D Model editor program. So I mean right now I am able to display my red quad over the face that is selected, the problem is that my math to determine the location/size/rotation of the selection quad does not work if the Box mesh is rotated in any way. So I guess my real question is , what is the math or guide to determine the translation and rotation of the red quad I want to display over the face of the box the raycast hit? If you know of course I would appreciate it, or any hints at all :).

->

get the face you are interested, eg via hittriangle
-> get inverse world transform ( this will need some trial and error, see quaternion opposite and quaternion invert, i usually mix those two up)

-> calculate the world positions of each vertex of the selected face.

-> create a own mesh that has those vertexes, make sure it renders after (transparent queue) and overwrites (ignores z tests) previous render stuff.

Then you should be able to get the selected triangles/face like eg blender does.

-> Downside, only triangles are used in game engines, support for other surfaces is not really possible.

http://hub.jmonkeyengine.org/javadoc/com/jme3/collision/CollisionResults.html - There is no triangle related function, should I be looking here instead? http://www.jmonkeyengine.org/doc/com/jme/scene/shape/Box.html ? Also, why inverse world transform, what exactly is that?

Sure theres a triangle related method but obviously not in the result SET…
http://hub.jmonkeyengine.org/javadoc/com/jme3/collision/CollisionResult.html

Ahh oh, awesome, so that will result in the triangle that was hit o.0! So will simply have to calculate the 4th vertice (for the face), based upon the 3 vertices given right?