ObjectDuplicate problems

View previous topic View next topic Go down

ObjectDuplicate problems

Post  mordenkaim on Thu May 21, 2009 5:16 pm

I'm trying to get sio2ObjectDuplicate working. Basically I want to instantiate an object because I will be using them through the flow of the game. They will basically be the game pieces which will be generated as the game goes on. I'm trying to duplicate a cube at runtime, and this is the code I'm using. I borrowed the code from tutorial02 and modified it to apply to a cube object that I exported. I may be calling it incorrectly, but I'm having a hard time finding a good reference for a command/syntax guide, so if you have a good link to a function listing that I've been missing that would be very helpful. I'm using sio2ResourceGet to populate my SIO2object (and I'm able to rotate the cube if I comment the duplicate out, so I know I'm getting the intended object) and then attempting to duplicate it like in tutorial06. Whenever I add the duplicate code I get an exception, EXC_BAD_ACCESS, and it points to a line within the sio2ObjectDuplicate function. Thanks in advance for the help, and I apologize if this is a repost. I searched for the exception online and it generally points to a problem with XCode.

Code:
SIO2object *_SIO2object = ( SIO2object * )sio2ResourceGet( sio2->_SIO2resource,
                                                  SIO2_OBJECT,
                                                  "object/Cube" );
      if(_SIO2object)
      {
         if(dupe)
         {
            dupe=!dupe;
            _SIO2object=sio2ObjectDuplicate(_SIO2object, _SIO2object->_SIO2transform, "oName", 1);
         }
      }


Last edited by mordenkaim on Thu May 21, 2009 5:24 pm; edited 1 time in total (Reason for editing : typos)

mordenkaim

Posts : 21
Join date : 2009-05-19

View user profile

Back to top Go down

Re: ObjectDuplicate problems

Post  sio2interactive on Thu May 21, 2009 5:44 pm

Check tutorial06_1 for more info...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 37
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: ObjectDuplicate problems

Post  mordenkaim on Fri May 22, 2009 9:52 am

OK, I've done a little more with this, and I've been able to get it working.

First of all, thank you for all of your help so far, and I apologize if any of these are newbie questions. I am attempting to do as much research as I can before resorting to asking on here. Now I really want to share my experiences so hopefully someone will find this and not have to ask the same questions.

It seems to me that in order for ObjectDuplicate to work you have to be using physics. Maybe this was said during the tutorial and I just missed it.

Until I initialized physics using... (taken directly from tutorial06_1)

sio2->_SIO2physic = sio2PhysicInit( "earth" ); //in the createFramebuffer function in EAGLView.mm

and

sio2PhysicRender...; //in the drawView function of EAGLView.mm

I was trying to use ObjectDuplicate in the tutorial02 template.mm file and since physics wasn't initialized in EAGLView.mm for tutorial02 it was throwing an exception. I kept getting EXC_BAD_ACCESS whenever it tried to access the physics function in sio2ObjectDuplicate. It makes sense since the physics engine wasn't initialized.

Am I right to think that physics is required for duplicate since the duplicate code calls functions that require physics to work properly?

mordenkaim

Posts : 21
Join date : 2009-05-19

View user profile

Back to top Go down

Re: ObjectDuplicate problems

Post  sio2interactive on Fri May 22, 2009 6:13 pm

Take a look at the function definition:

SIO2object *sio2ObjectDuplicate( SIO2object *_SIO2object,
SIO2transform *_SIO2transform,
char *_name,
unsigned char _physic )

Passing 0 to _physic OBVIOUSLY don't copy the physic properties...

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 37
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: ObjectDuplicate problems

Post  mordenkaim on Tue May 26, 2009 8:33 am

sio2interactive wrote:Take a look at the function definition:

SIO2object *sio2ObjectDuplicate( SIO2object *_SIO2object,
SIO2transform *_SIO2transform,
char *_name,
unsigned char _physic )

Passing 0 to _physic OBVIOUSLY don't copy the physic properties...

Yeah I saw this after I played around a little more with it. Embarassed Felt pretty stupid since I "wasted" (not really wasted since I learned more about the engine) a lot of time tracing the error messages and such. Oh well, noob mistake. I'm on to cameras and loving every bit of this engine so far. Great work!

mordenkaim

Posts : 21
Join date : 2009-05-19

View user profile

Back to top Go down

Re: ObjectDuplicate problems

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum