Monday 9 July 2012

Drawing a line in Cocos3D

I'm currently working on a debug drawer for Bullet Physics. 
To get this up and running I need to be able to draw some lines within cocos3d. 

I almost figured it out, but in the end Bill directed me in the right direction.

 float arr_location[] = {0.0,0.0,0.0, 5,5, 5 };
 CC3LineNode* lineNode = [CC3LineNode nodeWithName: @"Line test"];
 [lineNode populateAsLineStripWith: 2
                             vertices: arr_location
                            andRetain: YES];
 lineNode.color = ccGREEN;
    
 [self addChild:lineNode];

Populate arr_location with your way points for the line and add the node to your scene.

The plans I have for my debug drawer will be to record all lines added to the scene so I can remove them on the next debug draw and replace them with the new lines.

No comments:

Post a Comment