Author Topic: Getting Sub-Objects from *.obj file?  (Read 3410 times)

Offline redfalcon

  • byte
  • *
  • Posts: 14
    • View Profile
Getting Sub-Objects from *.obj file?
« 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?
« Last Edit: October 12, 2011, 01:38:24 pm by redfalcon »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Getting Sub-Objects from *.obj file?
« Reply #1 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.

Offline redfalcon

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Getting Sub-Objects from *.obj file?
« Reply #2 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Getting Sub-Objects from *.obj file?
« Reply #3 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!?

Offline redfalcon

  • byte
  • *
  • Posts: 14
    • View Profile
Re: Getting Sub-Objects from *.obj file?
« Reply #4 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
« Last Edit: October 12, 2011, 04:32:29 pm by redfalcon »