www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: redfalcon on October 12, 2011, 12:03:47 pm

Title: Getting Sub-Objects from *.obj file?
Post by: redfalcon on October 12, 2011, 12:03:47 pm
Hi.

I'm loading a Wavefront obj file, that consists of serveral sub-objects (I noticed that jpct processes each of these objects when compiling). Using the picking tutorial from the wiki, I can now successfully choose between the objects I have in my scene with the touchscreen. It would now be interesting to somehow access (like adding transparency, or removing them temporarily) these sub-objects. I found that I can create a PolygonManager from the object, but it doesn't seem to help me, because I can only manipulate the polygons (duh). Is there any way to get access to the sub-objects in jpct?
Title: Re: Getting Sub-Objects from *.obj file?
Post by: EgonOlsen on October 12, 2011, 12:50:35 pm
The sub-objects in the file are the objects in the array as returned by the loader. What the compiler calls a sub-object is something different and that one can't be accessed, but that's most likely not what you want to do anyway. To get the object of a picking, you can implement a collision listener and add it to the objects to get called when there's a collision/picking.
Title: Re: Getting Sub-Objects from *.obj file?
Post by: redfalcon on October 12, 2011, 01:53:21 pm
I'm not sure I understand you correctly. I already get the object I'm picking with the instructions from the wiki. I gave the objects different names with .setName() and can differentiate between them by checking the name of the currently picked object. The CollisionListener would only return me the whole object that caused the collision, would it?
Title: Re: Getting Sub-Objects from *.obj file?
Post by: EgonOlsen on October 12, 2011, 02:28:28 pm
It would return the victim of the collision, in your case the picked object. But you are right, you already have that...my bad. But then, i don't get what you need in addition!?
Title: Re: Getting Sub-Objects from *.obj file?
Post by: redfalcon on October 12, 2011, 02:30:59 pm
I thought that I could somehow get access the sub-objects that the compiler mentioned (i.e. check if a collision occured with such a sub-object).

Edit: I think they are called groups inside the *.obj file.

Edit2: I obviously completely failed to realize, that all of those sub-objects are loaded independendtly. I just mashed them together with mergeAll() and overlooked that you can shove all sub-objects from the Obj-Loader into an Object3D[]-Array.  :o