Box sides action

Started by itsmeveno, February 05, 2019, 12:13:35 AM

Previous topic - Next topic

itsmeveno

Good day any idea on how to give an action of the sides of a box. By clicking or dragging the sides.
Like for example i drag the top sides. going up. it scale the box vertically.

Thanks :) :) :)

EgonOlsen

#1
You can implement picking like so: http://www.jpct.net/wiki/index.php?title=Picking

In addition (to get the polygon that's affected by picking), you have to add a CollisionListener implementation of your own to the picked object, that returns true on requiresPolygonIDs. You can then ask the collision event for the polygon's id and armed with that, you can "guess" which side has been picked. The mapping between ID and your side has to be done by youself, but it in case of a cube, it shouldn't be too hard to figure it out.

itsmeveno

Thank you for that but when i try the codes it doesn't pick the faces/sides of a box.
What i want to do if to make every action of the sides of my box.

EgonOlsen

Yes, I got that. And picking is the way to do just that. Actually, the wiki page contains everything that you have to know to get at least the picking itself working. What exactly does "it doesn't pick" mean in this context? Have you checked that your picking coordinates correct?

itsmeveno

The codes is for desktop application my project is an android app.

EgonOlsen

That actually doesn't matter. The picking works in exactly the same way (see private void relocate() in the example).

itsmeveno

I do my best to understand the pick but it can't pick the sides base on the documentation. please help any more explanation for me to understand on how it going to detect those sides.

itsmeveno

How can i set the sides of the box. By the way im using Extendedprimitive box. Like how can i identify if that sides of the box is picked.

EgonOlsen

I'm not sure what you expect as a result? You'll get a polygon ID, a number. There's no general rule which number represents which polygon. It depends on the object and it might require a little bit or trial and error to find out.

itsmeveno

I made the picking what i did is i make a box using Primitives plane. but my problem now is the rotation of my box when i rotate every single plane the box was destroyed

EgonOlsen

Just create a dummy Object3D (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#createDummyObj()), place it in the center of your box and assign it as parent object to your planes. Then rotate that object instead of the other individual planes.

itsmeveno

Thanks for that its working another problem if how to get the dimension of my box

EgonOlsen

In which space? Object space or world space (i.e. before or after rotations have been applied)?

itsmeveno