First off, I have to say thank you, this is fantastic. Ive been on the forum just using the search features and never saying anything, but this was so perfect for what I needed it actually compelled me to post.
secondly @Mcadieux
From what I gathered out of it, ODE when you specify you want a box that is 1,1,1 you get a box that is 1 long, 1 deep, and 1 high
for these functions it is specifying you want a box that spans from -1,-1,-1 to 1,1,1
I just modified the function to divide whats passed in by 2 for boxes, since i preferred to be able to use the same dimensions to draw that I am passing to ODE to create the geometry
I also found it useful to modify the generate function to take in RGB values rather than making everything green, made it much easier to see things (or just generate a random RGB value if none was passed in)
This is the modified version I am using now
def generate (self, type, radius=1.0, length=1.0, extents=Point3(1, 1, 1), R=-1, G=-1, B=-1):
if R==-1:
R=random.uniform(0,1)
if G==-1:
G=random.uniform(0,1)
if B==-1:
B=random.uniform(0,1)
if type == 'sphere':
# generate a simple sphere
self.circle (radius, "x", 0)
self.circle (radius, "y", 0)
self.circle (radius, "z", 0)
if type == 'capsule':
# generate a simple capsule
self.capsule (radius, length, "x")
self.capsule (radius, length, "y")
self.circle (radius, "z", -length / 2)
self.circle (radius, "z", length / 2)
if type == 'box':
# generate a simple box
self.rect (extents[1]/2, extents[2]/2, "x")
self.rect (extents[0]/2, extents[2]/2, "y")
self.rect (extents[0]/2, extents[1]/2, "z")
if type == 'cylinder':
# generate a simple cylinder
self.line ((0, -radius, -length / 2), (0, -radius, length/2))
self.line ((0, radius, -length / 2), (0, radius, length/2))
self.line ((-radius, 0, -length / 2), (-radius, 0, length/2))
self.line ((radius, 0, -length / 2), (radius, 0, length/2))
self.circle (radius, "z", -length / 2)
self.circle (radius, "z", length / 2)
if type == 'ray':
# generate a ray
self.circle (length / 10, "x", 0)
self.circle (length / 10, "z", 0)
self.line ((0, 0, 0), (0, 0, length))
self.line ((0, 0, length), (0, -length/10, length*0.9))
self.line ((0, 0, length), (0, length/10, length*0.9))
if type == 'plane':
# generate a plane
length = 3.0
self.rect (1.0, 1.0, "z")
self.line ((0, 0, 0), (0, 0, length))
self.line ((0, 0, length), (0, -length/10, length*0.9))
self.line ((0, 0, length), (0, length/10, length*0.9))
# rename ourselves to wirePrimBox, etc.
name = self.gnode.getName()
self.gnode.setName(name + type.capitalize())
NP = NodePath (self.gnode) # Finally, make a nodepath to our geom
NP.setColor(R, G, B) # Set default color
return NP