Re: pfuCollideGnd question

New Message Reply Date view Thread view Subject view Author view

Lance R. Marrou (marrou++at++vsl.ist.ucf.edu)
Mon, 6 Mar 1995 13:59:56 -0500 (EST)


On Fri, 3 Mar 1995, Torres Mario 678-5430 AMSRL-BE-M wrote:

> A question along this lines has been asked before but I have not seen
> a reply (or missed it) here. How can one have a vehicle (or any object)
> be dropped/placed ON the ground of the scene? I am currently importing
> various objects into the scene while its being rendered. The problem
> comes in that the objects will sometimes be floating above the ground or
> partly underground. I know that its doing this because I am placing the
> object on the scene at a position relative to the objects center. Can I
> find out the center of the object after bringing it into the scene? The
> center of the bounding sphere or box? I would guess that I need to do a
> collision of the objects bounding box/segments against the ground, but it
> escapes me as to how to go about it? Any hints are appreciated.

There are two solutions. The first one, which I recommend as the better
solution, is to find the bottom (center, or whatever placement point you want)
of the model through the modeling package used to create it. If this is
impossible, then you need to find the bounding box of the model, and determine
the center of it. An example of this:

pfBox bbox;
pfVec3 bot_center;

pfuTravCalcBBox(node,&bbox);
PFSET_VEC3(bot_center,(bbox.max[0]+bbox.min[0])/2.0f,
                       (bbox.max[1]+bbox.min[1])/2.0f,
                        bbox.min[2]);
Now performer your intersection test, drop the model on the terrain and
further offset it by the vector bot_center. Another point to be made here is
when the model has some protrusions which need to "go into" the terrain most
of the time. In other wors, you cannot use these protrusions in the
calculation of the bounding box. In this case intersection a segment UP from
the terrain to the model and get the bottom of the model that way. Of course,
you would only do this one time (at loading) so it is not such a big waste
after all.

______________________________________________________________________________
           /\ ______ /\____ ______ ______ E-mail: marrou++at++vsl.ist.ucf.edu
Visual / / / _ / / __ // ____// ____/ VSL: (407)658-5073
Systems / /__ / /_/ / / / / // /___ / __/_ R. Marrou Fax: (407)658-5059
Lab /____//____/\\/_/ /_//_____//_____/ http://www.vsl.ist.ucf.edu/~marrou
"Reap the whirlwind." "We don't need no thought control."


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:02 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.