Author Topic: Obj name change  (Read 1950 times)

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Obj name change
« on: May 27, 2012, 11:02:35 am »
Previously I was loading each model as it's own obj file, attaching that model to a parent Object3D, then access each needed object3D through though a series of class calls. The sub-object was in it's own class, and the parent had an array of the child classes....it was taking up too much space and the subclass was easily able to be knocked out since the parent always contains the same number of children.

So, I made a new object with the children already attached. Each object has it's own name and is numbered incrementally. To access the 4th block element, I would use hub[10].getName() and it would be "Block_4".

...here is where my problem comes in, rather than returning the name "Block_4", it would return "_jPCT17". Only the first loaded object in the Obj has a correctish name, it return the object's name plus "_jPCT-2", so it reads "HubSides_jPCT-2".

Is there a way to load the obj file and keep each object's name? The objects are labeled: "HubSides", "Front_" + (1 - 12), "Sides_" + (1 - 12), and "Back_" + (1 - 12).

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Obj name change
« Reply #1 on: May 28, 2012, 01:02:30 am »
You can use something like this...

Code: [Select]
String name = hub[10].getName();
int end = name.lastIndexOf("_") - 1;
name = name.substring(0, end);

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Obj name change
« Reply #2 on: May 28, 2012, 01:37:43 am »
That would return a string containing nothing.
Quote
rather than returning the name "Block_4", it would return "_jPCT17". Only the first loaded object in the Obj has a correctish name, it return the object's name plus "_jPCT-2", so it reads "HubSides_jPCT-2".

Edit: Log from loading the object
Quote
05-27 15:25:14.329: I/jPCT-AE(22470): Loading file from InputStream
05-27 15:25:14.339: I/jPCT-AE(22470): Text file from InputStream loaded...34718 bytes
05-27 15:25:14.369: I/jPCT-AE(22470): Processing object from OBJ-file: HubSides
05-27 15:25:14.389: I/jPCT-AE(22470): Object 'HubSides_jPCT-2' created using 24 polygons and 26 vertices.
05-27 15:25:14.389: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.399: I/jPCT-AE(22470): Object '_jPCT-1' created using 2 polygons and 4 vertices.
05-27 15:25:14.399: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.409: I/jPCT-AE(22470): Object '_jPCT0' created using 12 polygons and 16 vertices.
05-27 15:25:14.409: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.409: I/jPCT-AE(22470): Object '_jPCT1' created using 2 polygons and 4 vertices.
05-27 15:25:14.409: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.429: I/jPCT-AE(22470): Object '_jPCT2' created using 2 polygons and 4 vertices.
05-27 15:25:14.429: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.439: I/jPCT-AE(22470): Object '_jPCT3' created using 12 polygons and 14 vertices.
05-27 15:25:14.439: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.439: I/jPCT-AE(22470): Object '_jPCT4' created using 2 polygons and 4 vertices.
05-27 15:25:14.439: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.449: I/jPCT-AE(22470): Object '_jPCT5' created using 2 polygons and 4 vertices.
05-27 15:25:14.449: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.459: I/jPCT-AE(22470): Object '_jPCT6' created using 12 polygons and 11 vertices.
05-27 15:25:14.459: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.459: I/jPCT-AE(22470): Object '_jPCT7' created using 2 polygons and 4 vertices.
05-27 15:25:14.459: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.469: I/jPCT-AE(22470): Object '_jPCT8' created using 2 polygons and 4 vertices.
05-27 15:25:14.469: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.479: I/jPCT-AE(22470): Object '_jPCT9' created using 12 polygons and 16 vertices.
05-27 15:25:14.479: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.479: I/jPCT-AE(22470): Object '_jPCT10' created using 2 polygons and 4 vertices.
05-27 15:25:14.479: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.489: I/jPCT-AE(22470): Object '_jPCT11' created using 2 polygons and 4 vertices.
05-27 15:25:14.489: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.499: I/jPCT-AE(22470): Object '_jPCT12' created using 12 polygons and 14 vertices.
05-27 15:25:14.499: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.499: I/jPCT-AE(22470): Object '_jPCT13' created using 2 polygons and 4 vertices.
05-27 15:25:14.499: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.509: I/jPCT-AE(22470): Object '_jPCT14' created using 2 polygons and 4 vertices.
05-27 15:25:14.509: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.509: I/jPCT-AE(22470): Object '_jPCT15' created using 12 polygons and 13 vertices.
05-27 15:25:14.509: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.519: I/jPCT-AE(22470): Object '_jPCT16' created using 2 polygons and 4 vertices.
05-27 15:25:14.519: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.519: I/jPCT-AE(22470): Object '_jPCT17' created using 2 polygons and 4 vertices.
05-27 15:25:14.519: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.519: I/jPCT-AE(22470): Object '_jPCT18' created using 12 polygons and 12 vertices.
05-27 15:25:14.519: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.529: I/jPCT-AE(22470): Object '_jPCT19' created using 2 polygons and 4 vertices.
05-27 15:25:14.529: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.529: I/jPCT-AE(22470): Object '_jPCT20' created using 2 polygons and 4 vertices.
05-27 15:25:14.529: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.539: I/jPCT-AE(22470): Object '_jPCT21' created using 12 polygons and 14 vertices.
05-27 15:25:14.539: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.539: I/jPCT-AE(22470): Object '_jPCT22' created using 12 polygons and 14 vertices.
05-27 15:25:14.539: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.539: I/jPCT-AE(22470): Object '_jPCT23' created using 2 polygons and 4 vertices.
05-27 15:25:14.539: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.549: I/jPCT-AE(22470): Object '_jPCT24' created using 12 polygons and 13 vertices.
05-27 15:25:14.549: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.549: I/jPCT-AE(22470): Object '_jPCT25' created using 2 polygons and 4 vertices.
05-27 15:25:14.549: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.549: I/jPCT-AE(22470): Object '_jPCT26' created using 2 polygons and 4 vertices.
05-27 15:25:14.549: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.549: I/jPCT-AE(22470): Object '_jPCT27' created using 12 polygons and 12 vertices.
05-27 15:25:14.549: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.549: I/jPCT-AE(22470): Object '_jPCT28' created using 2 polygons and 4 vertices.
05-27 15:25:14.559: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.559: I/jPCT-AE(22470): Object '_jPCT29' created using 2 polygons and 4 vertices.
05-27 15:25:14.559: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.559: I/jPCT-AE(22470): Object '_jPCT30' created using 12 polygons and 14 vertices.
05-27 15:25:14.559: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.559: I/jPCT-AE(22470): Object '_jPCT31' created using 2 polygons and 4 vertices.
05-27 15:25:14.559: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.569: I/jPCT-AE(22470): Object '_jPCT32' created using 2 polygons and 4 vertices.
05-27 15:25:14.569: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.569: I/jPCT-AE(22470): Object '_jPCT33' created using 12 polygons and 11 vertices.
05-27 15:25:14.569: I/jPCT-AE(22470): Processing object from OBJ-file:
05-27 15:25:14.569: I/jPCT-AE(22470): Object '_jPCT34' created using 2 polygons and 4 vertices.
« Last Edit: May 28, 2012, 01:56:43 am by Zyphuris55 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Obj name change
« Reply #3 on: May 28, 2012, 08:56:57 pm »
The OBJ-format is a bunch of sh*!'*&t when it comes to consistency. There are more variants of this formats than birds in the sky. Your variant seems to be one, where the parser can't find proper names for the sub-objects (either they have none or they are (more likely) stored in a crazy way). You can send me the OBJ-file you are using and i'll have a look.

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: Obj name change
« Reply #4 on: May 28, 2012, 09:33:55 pm »
if you have 3Ds max, you can save your model in many variants of OBJ (variant "none" is fully compatible with jPCT)

Offline Zyphuris55

  • byte
  • *
  • Posts: 30
    • View Profile
Re: Obj name change
« Reply #5 on: May 28, 2012, 11:09:38 pm »
The file was saved in 3DS max 2012 with the "None" preset, and it still caused problems. I'm going to try the 3ds format instead and see if that makes anything better. Here is the obj file which I'm using.


Edit: the 3ds file works better, in that the names are preserved, but it still tacks on the "_jPCT-#" thing at the end :-/.
Also, in the obj file (and it seems in the 3ds file too), that normals are saved along with the object. Is there a way to not calculate the normals for each object while it's being built? It seems like a waste of time.

[attachment deleted by admin]
« Last Edit: May 28, 2012, 11:22:38 pm by Zyphuris55 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Obj name change
« Reply #6 on: May 29, 2012, 08:01:09 pm »
The postfix _jPCT-# is always added to keep the names unique. As Thomas. mentioned, you can simply set a new name for each object where this is removed.

Regarding normals: jPCT (as well as -AE) fully relies on its own normal calculations. If you want to get rid of the calculation on the mobile device, use serialized objects instead of loading the models directly (http://www.jpct.net/wiki/index.php/Differences_between_jPCT_and_jPCT-AE#Performance_and_memory_issues.2C_serialized_objects).

I'll now take a look at this obj-file...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Obj name change
« Reply #7 on: May 29, 2012, 08:05:44 pm »
Tried the file...it seems to load fine:

Code: [Select]
Processing object from OBJ-file: HubSides
Object 'HubSides_jPCT-2' created using 24 polygons and 26 vertices.
Processing object from OBJ-file: Back_1
Object 'Back_1_jPCT-1' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_1
Object 'Sides_1_jPCT0' created using 12 polygons and 16 vertices.
Processing object from OBJ-file: Front_1
Object 'Front_1_jPCT1' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_2
Object 'Back_2_jPCT2' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_2
Object 'Sides_2_jPCT3' created using 12 polygons and 14 vertices.
Processing object from OBJ-file: Front_2
Object 'Front_2_jPCT4' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_3
Object 'Back_3_jPCT5' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_3
Object 'Sides_3_jPCT6' created using 12 polygons and 11 vertices.
Processing object from OBJ-file: Front_3
Object 'Front_3_jPCT7' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_4
Object 'Back_4_jPCT8' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_4
Object 'Sides_4_jPCT9' created using 12 polygons and 16 vertices.
Processing object from OBJ-file: Front_4
Object 'Front_4_jPCT10' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_5
Object 'Back_5_jPCT11' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_5
Object 'Sides_5_jPCT12' created using 12 polygons and 14 vertices.
Processing object from OBJ-file: Front_5
Object 'Front_5_jPCT13' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_6
Object 'Back_6_jPCT14' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_6
Object 'Sides_6_jPCT15' created using 12 polygons and 13 vertices.
Processing object from OBJ-file: Front_6
Object 'Front_6_jPCT16' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_7
Object 'Back_7_jPCT17' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_7
Object 'Sides_7_jPCT18' created using 12 polygons and 12 vertices.
Processing object from OBJ-file: Front_7
Object 'Front_7_jPCT19' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_8
Object 'Back_8_jPCT20' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_8
Object 'Sides_8_jPCT21' created using 12 polygons and 14 vertices.
Processing object from OBJ-file: Front_8
Object 'Front_8_jPCT22' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_9
Object 'Back_9_jPCT23' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_9
Object 'Sides_9_jPCT24' created using 12 polygons and 13 vertices.
Processing object from OBJ-file: Front_9
Object 'Front_9_jPCT25' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_10
Object 'Back_10_jPCT26' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_10
Object 'Sides_10_jPCT27' created using 12 polygons and 12 vertices.
Processing object from OBJ-file: Front_10
Object 'Front_10_jPCT28' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_11
Object 'Back_11_jPCT29' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_11
Object 'Sides_11_jPCT30' created using 12 polygons and 14 vertices.
Processing object from OBJ-file: Front_11
Object 'Front_11_jPCT31' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Back_12
Object 'Back_12_jPCT32' created using 2 polygons and 4 vertices.
Processing object from OBJ-file: Sides_12
Object 'Sides_12_jPCT33' created using 12 polygons and 11 vertices.
Processing object from OBJ-file: Front_12
Object 'Front_12_jPCT34' created using 2 polygons and 4 vertices.

The numbers start at -2, which seems a bit strange (i bet i had a reason for this that i can't remember anymore), but apart from that, all names are as expected.