[Bf-python] radius of collision sphere

Willian Padovani Germano wgermano at ig.com.br
Tue Apr 27 14:01:37 CEST 2004


Hi Jacek,

----- Original Message -----
From: "Jacek Popławski" <jpopl at interia.pl>
To: <bf-python at blender.org>
Sent: Tuesday, April 27, 2004 6:55 AM
Subject: Re: [Bf-python] radius of collision sphere


> On Mon, Apr 26, 2004 at 03:03:08PM -0400, Gilbert, Joseph wrote:
> > The object and mesh datastructs have a bounding box member that contains
> > the 8 points that make up the bounding box for the object. This is not
> > currently accessable through the api.
>
> Are you sure? At least function exists.

Yes it exists: obj.getBoundBox() method in Blender.Object.

This is the best way to get what you want "automatically", since you don't
have to model the bounding sphere, only calculate it using the bounding box.

> Calculating sphere radius in algorithm is not so hard. But I need to define
> sphere by hand. That's why it would be very helpfull to add new type of
object
> (real sphere), move and scale it, then get center and radius.

This is something that would have to be in Blender itself.  It'd be useful
there, too, since renderers like "primitives" and specially spheres.

Since you want to add by hand ... just thinking aloud, sorry for obvious
solutions:

To simply define which obj must have a bounding sphere, naturally:

1) you give a meaninful name to the object itself, or its mesh, to tell your
script to calculate the bounding sphere for it, based on its bounding box.

2) you can use an empty, putting it at the object's center and giving it some
meaninful name, like "boundSphere" or something.  Then all objs with such
emptys parented must have bounding spheres and with the empty's position and
one vertex returned by the meshobj.getBoundBox() method you have both your
circle's center and radius.

But if you need to define the sphere size by hand, then parent a mesh sphere
to your objs, giving it a meaninful name and take care with those buttons in
Blender that define where the obj center is.  Better not mess with the
vertices, only move / resize the sphere Object, not its verts directly.  This
way you get the sphere center and size from the sphere obj's position and size
parameters.  But anyway, even if the verts were moved -- all together, so it's
still a sphere -- if you know / get the center, just have to use one vertex to
know the radius of each "bounding box sphere" you added by hand.

--
Willian, wgermano at ig.com.br




More information about the Bf-python mailing list