cant rotate custom object

Started by dutch_delight, February 16, 2011, 01:22:49 AM

Previous topic - Next topic

dutch_delight

Hi all,

I've got a problem where I'm trying to rotate an object but it just gives me a NullPointerException.

I create a standard cube which I can rotate fine. no problems.
But when I load a serialized model and rotate the new object, the object cant be found and the screen stays black.
Funny thing is, if i comment out the line that rotates it, the new object gets displayed fine in the scene.

cube.rotateX(0.05f);  //works fine
building.rotateX(0.05f);  //doesnt work

Everything gets declared and added to the world.
Any ideas anyone?

EgonOlsen

Most likely because building is null!?

dutch_delight

Yeah, I figured as much  ;)  Still have a lot to learn.

I've got it all sorted out now by creating a class for my object. This is ok for the player object and a few other unique things but it's a bit tedious to do it for everything.

What I've got is a gaming world made up of ground terrain and on that terrain are lots of objects like trees, buildings and the usual props. I've got an xml file containing positions, rotations, textures and what model file to use for each element.
My plan was to create a generic object class and then run through my xml file and create a new object using that data but I'm not sure how to convert that string so I can load it with the deserializer.

r.raw.imported_object will not work because imported_object is not defined.

Although, thinking about it I'ts probably quicker to load and setup my models first and then extracting my xml.