Trouble with corners


01-10-2006 15:33:25

I was reading a tutorial about how to do Object Text Display by xavier. I needed to access all 8 corners of a bounding box.

The trouble is: when iterating thru this, python will automatically iterate thru the x,y,z of the first corner, but not iterate thru the 8 vectors. I guess it makes no difference to python whether it be a pointer to one vector or a pointer to an array of vectors. How would I have access to all the corners? Maybe there shouldn't be an automatic iterator over a vector?

for c in node.worldAABB.corners:
# c should be a vector3, but it is x,y,z of the first corner
print c

Any ideas? I'm using the pyogre 1.2 binaries.


02-10-2006 11:21:29

It's a bug only the first corner (Vector3) is returned, fairly trivial to resolve and return corners as a list of tuples. There are similar problems e.g. camera getWorldSpaceCorners so it probably needs a typemape to handle all cases. You should submit as a bug so it doesn't get overlooked.

As a workaround for the bounding box corners you could use the bounding box minimum/ maximum, e.g.:

def getMyCorners(self, AABB):

# The order of these items is, using right-handed co-ordinates:
# Minimum Z face, starting with Min(all), then anticlockwise
# around face (looking onto the face)
# Maximum Z face, starting with Max(all), then anticlockwise
# around face (looking onto the face)

min = AABB.minimum
max = AABB.maximum

mCorners = [ (min.x,min.y,min.z),
(min.x, max.y, min.z),
(max.x, max.y, min.z),
(max.x, min.y, min.z),
(max.x, max.y, max.z),
(min.x, max.y, max.z),
(min.x, min.y, max.z),
(max.x, min.y, max.z) ]

return mCorners

corners = self.getMyCorners(node.worldAABB)
print "Corners --------------------------",corners


02-10-2006 16:04:43

Thanks dermont! I am going to try this method out. I submitted bug 008975, and referenced this thread.