Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - LoTan

Pages: [1]
1
Support / Re: TextureManager serializing state problem
« on: February 25, 2014, 12:15:44 am »
Ok cool, I think I'll try going down this path :)  Thanks.

2
Support / Re: TextureManager serializing state problem
« on: February 24, 2014, 08:49:20 pm »
Unfortunately, calling that method did not work, no.

What would ultimately help me (I think) is some way to load just an MTL and get the textures out.  This way, I could cache the serialized Object3Ds and then I will load the MTL files when the game loads to apply the textures.  Does that not sound reasonable?

Right now, the MTL load is tightly coupled with parsing OBJ files and I don't want to parse raw OBJ files at runtime.  I want that parsing done in advance and the texture parsing to be done during game load (at runtime).

3
Support / Re: TextureManager serializing state problem
« on: February 24, 2014, 12:04:34 am »
My primary intention is to support dynamic, user generated content in the game.  I was going to try and keep it as simple as possible - by allowing the Android client to download zip packages of OBJ/MTL files, process them using Loader.loadOBJ, and serialize out everything into a cache so that I don't have to process the OBJ/MTL for future game loads.

That said, I'm currently writing some framework code for pulling the zip files and doing processing of them on the client.  I pull down a zip of OBJ/MTL, and then serializing it to a private cache as an Object3D.  The problem I have now is I cant figure out how to get to the textures that were loaded via Loader.loadOBJ(obj,mtl) so I was dumping the texture manager because I know it has it there.

Is there a way I can just keep the MTL files around and load them dynamically, but avoid calls to the Loader.loadOBJ and just use my serialized/cached Object3D instead?

I've also never created a game before, so I could be doing this all wrong anyway :)  I'm aware of jpct desktop and the possibility of using the DeSerializer class, but I'm still lost on how I should handle the MTL files and applying them to the deserialized Object3Ds.

4
Support / TextureManager serializing state problem
« on: February 23, 2014, 10:36:24 pm »
I am attempting to serialize the texture manager's state to disk and then reload it at another time.

The following code works as expected and my Object3D renders with the appropriate texture:
Code: [Select]
TextureManager textureManager= TextureManager.getInstance();
textureManager.setState(textureManager.getState());



However, as soon as I serialize this out (I tried files at first, then wrote this code to post here), reload the state, and set it on the texture manager, I get blank/black textures when my object is rendered:

Code: [Select]
TextureManager textureManager = TextureManager.getInstance();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
for (Object state : textureManager.getState()) {
    oos.writeObject(state);
}
oos.writeObject(null); // flag for end of stream when reading in state below
oos.flush();
oos.close();

// restore the texture manager
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
List<Object> state = new ArrayList<Object>();
Object o;
while ( (o = ois.readObject()) != null) {
    state.add(o);
}
textureManager.setState(state);
Log.d("TextureLoader", "Texture names in the texture manager: " + textureManager.getNames());
Log.d("TextureLoader", "Texture count: " + textureManager.getTextureCount());
               

The logcat displays the following message:
Quote
D/TextureLoader﹕ Texture names in the texture manager: [__obj-Color:163/163/163, __obj-Color:0/0/0, --dummy--]
D/TextureLoader﹕ Texture count: 3

So it appears that the textures do load, but nothing renders in the world :(  Is there something I am not doing properly when serializing or deserializing the texture manager state to where it is properly set up?

Help would be truly appreciated.

- LoTan

Pages: [1]