www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: itsmeveno on February 05, 2019, 12:13:35 am

Title: Box sides action
Post by: itsmeveno on February 05, 2019, 12:13:35 am
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 :) :) :)
Title: Re: Box sides action
Post by: EgonOlsen on February 05, 2019, 07:59:45 am
You can implement picking like so: http://www.jpct.net/wiki/index.php?title=Picking (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.
Title: Re: Box sides action
Post by: itsmeveno on February 06, 2019, 11:56:24 am
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.
Title: Re: Box sides action
Post by: EgonOlsen on February 07, 2019, 06:04:21 pm
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?
Title: Re: Box sides action
Post by: itsmeveno on February 09, 2019, 08:59:11 am
The codes is for desktop application my project is an android app.
Title: Re: Box sides action
Post by: EgonOlsen on February 12, 2019, 08:54:28 am
That actually doesn't matter. The picking works in exactly the same way (see private void relocate() in the example).
Title: Re: Box sides action
Post by: itsmeveno on February 16, 2019, 09:30:23 am
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.
Title: Re: Box sides action
Post by: itsmeveno on February 16, 2019, 11:44:49 am
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.
Title: Re: Box sides action
Post by: EgonOlsen on February 18, 2019, 08:29:38 am
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.
Title: Re: Box sides action
Post by: itsmeveno on February 22, 2019, 12:00:38 am
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
Title: Re: Box sides action
Post by: EgonOlsen on February 22, 2019, 08:55:27 am
Just create a dummy Object3D (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#createDummyObj() (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.
Title: Re: Box sides action
Post by: itsmeveno on February 24, 2019, 03:56:07 am
Thanks for that its working another problem if how to get the dimension of my box
Title: Re: Box sides action
Post by: EgonOlsen on February 25, 2019, 11:16:51 am
In which space? Object space or world space (i.e. before or after rotations have been applied)?
Title: Re: Box sides action
Post by: itsmeveno on March 03, 2019, 12:27:40 pm
World space
Title: Re: Box sides action
Post by: EgonOlsen on March 04, 2019, 12:44:40 pm
Maybe this helps: http://www.jpct.net/wiki/index.php/Getting_Worldspace_Bounds (http://www.jpct.net/wiki/index.php/Getting_Worldspace_Bounds)?