Author Topic: Which function is the fastest way to create Object3D  (Read 615 times)

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Which function is the fastest way to create Object3D
« on: March 17, 2017, 04:23:39 am »
I have all the coordinates, normals, uvs and index values.
which function can create Object3D in shortest time?
Using Object3D(int maxTriangles) and run 8 times addTriangle(SimpleVector vert1, SimpleVector vert2, SimpleVector vert3, TextureInfo tInf)
or
Using Object3D(float[] coordinates, float[] normals, float[] uvs, int[] indices, int textureId)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Which function is the fastest way to create Object3D
« Reply #1 on: March 17, 2017, 08:29:24 am »
The latter one would be faster in that case.

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Which function is the fastest way to create Object3D
« Reply #2 on: March 17, 2017, 05:17:00 pm »
we are creating around 2000 3D objects. in iPhone5 using sceneKit only takes about 1~2 seconds to create, but in Android Nexus5 using jPCT-AE takes about 6 seconds to create after that jPCT-AE also need few seconds to compile the 3D object. is there any faster way to do that in jPCT-AE?
« Last Edit: March 18, 2017, 04:04:22 pm by peter »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Which function is the fastest way to create Object3D
« Reply #3 on: March 20, 2017, 08:30:55 am »
2000 different objects or all the same? Or some different and some the same?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Which function is the fastest way to create Object3D
« Reply #4 on: March 20, 2017, 02:47:05 pm »
all difference, it takes 4 seconds on Android, but that's without build and compile 3D objects

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Which function is the fastest way to create Object3D
« Reply #5 on: March 20, 2017, 02:55:35 pm »
In which way do they differ? Any chance that they share the same geometry (not textures and attributes)?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Which function is the fastest way to create Object3D
« Reply #6 on: March 20, 2017, 03:22:10 pm »
not share same geometry, some of them sharing same texture

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Which function is the fastest way to create Object3D
« Reply #7 on: March 20, 2017, 03:33:03 pm »
Well, in that case...no, there's not much you can do to speed this up. You could try to create them in different threads. For object creation including build(), that should work fine. For compiling them not so much.

Also, have you checked what actually takes the time? Maybe it's not the object creation itself but some garbage collection that occurs while doing so?

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Which function is the fastest way to create Object3D
« Reply #8 on: March 20, 2017, 06:40:32 pm »
Thank you for your help. I did some clean up, now it takes about 2 seconds to create all 2000 objects,  but after that I needs to do Objects.merge for every 250 of them which takes about 1 second for each merge, is there any way to speed up the merge or increase frame rate for drawing 250 objects in one world(I need to merge 250 object into one because the frame rate is too low (about 35fps) for drawing 250 objects in one world)
« Last Edit: March 20, 2017, 10:46:15 pm by peter »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net

Offline peter

  • byte
  • *
  • Posts: 24
    • View Profile
Re: Which function is the fastest way to create Object3D
« Reply #10 on: March 22, 2017, 03:38:11 pm »
yes, I am using that function

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Which function is the fastest way to create Object3D
« Reply #11 on: March 23, 2017, 08:37:06 am »
Well, then there's not much you can do, I'm afraid. If you are creating the objects manually, you might want to consider to create one large object instead of many small ones that get merged afterwards...if that's even an option.
Maybe it helps to know what you are doing...what are you needing 2000 different objects for?