Author Topic: cant rotate custom object  (Read 2780 times)

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
cant rotate custom object
« on: February 16, 2011, 01:22:49 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: cant rotate custom object
« Reply #1 on: February 16, 2011, 07:53:42 am »
Most likely because building is null!?

Offline dutch_delight

  • int
  • **
  • Posts: 58
    • View Profile
Re: cant rotate custom object
« Reply #2 on: February 21, 2011, 07:35:16 pm »
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.