www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: nathan on May 01, 2013, 10:41:20 pm

Title: Caching Vertex/UV/Normal data
Post by: nathan on May 01, 2013, 10:41:20 pm
I don't want to open an InputStream to my 3DS model every time I want to instantiate a new one.  I would like to load that data somehow. From what I have read, there is no simple way of doing this.  Why?

I can get the UV coordinates from the Object3D.getPolygonManager().getTextureUV()
I can get the Vertex coordinates from the GenericVertexController.getSourceMesh()
I can get the Normal coordinates from the GenericVertexController.getSourceNormals()

Then I can flatten all the information into a bunch of float arrays. 

Then, I can instantiate new Object3D with the UV and Vertex information
But to get the normal data back in, I have to then make another GenericVertexController to modify the DestinationNormals.

Why is this so complicated? There should be a simple method to cache this information.
When I instantiate the new object, what should I put into the int[] index field?
Title: Re: Caching Vertex/UV/Normal data
Post by: Thomas. on May 02, 2013, 01:00:09 am
You can do it very simple. Look at the javadoc (http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Object3D.html#Object3D(com.threed.jpct.Object3D, boolean)).

Code: [Select]
Object3D secondObject = new Object3D(firstObject, true);
Title: Re: Caching Vertex/UV/Normal data
Post by: nathan on May 02, 2013, 03:16:22 am
Okay, that would work.  I wanted to have a MeshData class that handled all this by itself, but I guess I can just hold an Object3D inside my MeshData, and just use that to copy it.