Export model with Collision in Max

Return to Pipeline

Export model with Collision in Max

Postby silveralex » Tue Jan 24, 2012 12:16 pm

Hi, hoping someone can advise.
The artist I'm working with is having a lot of trouble exporting a model with collision solids from 3DS Max.

It's a large terrain, so he then decided to try something simpler. He put the ball from the Panda SDK Maze tutorial into our game and it looks perfect - it's solid. (we can see the collision solid in pview as well)

He then tried importing this back into Max and then exported again - it stops working as expected. (loses the collision solids)

By copying text into the .egg file he eventually makes the exported version he did work like the one that comes with the tutorial (it's solid in the game), but we're not 100% sure why.

Is there a post or manual page that goes into more detail on exactly how to export collision solids in Max? I've seen this page, but is there a bit more?

http://www.panda3d.org/manual/index.php ... Studio_Max

Thanks!
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY

Postby wezu » Tue Jan 24, 2012 1:41 pm

I think the importer skips collision geometry (and animations... and bones from time to time). I never tried the trick with setting custom properties in max, but editing an egg to change normal geometry to collision geometry is just a matter of adding "<Collide> colision { Polyset descend}" to its group...just export as any other geometry, note its name and add <Collide> colision { polyset descend} inside the <Group> with that name.
I may be totally wrong, cause I'm a dancin' fool.
User avatar
wezu
 
Posts: 518
Joined: Tue May 19, 2009 1:03 pm

Postby silveralex » Tue Jan 24, 2012 1:50 pm

Hi wezu,
thx for the reply.

So editing the .egg file directly is the only way to do this?

Does the Max exporter not support collisions properly via its interface? TGhere are a bunch of collision options, so we're not sure what we shoudl be setting them as.

Hand-editing the files is going to be a big job if we have multiple groups in a big city scene. Hoping there's a better way?
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY

Postby wezu » Tue Jan 24, 2012 3:52 pm

Editing the egg is not the only way, I just think it's the best way.

If you write down the names of your objects from max, then all you need to do is find a group with that name and add one more line. Let's say you have the object named 'my_collision_1' - use any text editor that has find/replace options (even Notepad has that!)
find:
Code: Select all
  <Group> my_collision_1 {

replace with:
Code: Select all
  <Group> my_collision_1 {
    <Collide> my_collision_1 { Polyset descend }

repeat for my_collision_2, my_collision_3, ..., my_collision_179

As for the options I best quote the manual:
<Collide> name { type [flags] }

This entry indicates that geometry defined at this group level is
actually an invisible collision surface, and is not true geometry.
The geometry is used to define the extents of the collision
surface. If there is no geometry defined at this level, then a
child is searched for with the same collision type specified, and
its geometry is used to define the extent of the collision
surface (unless the "descend" flag is given; see below).

Valid types so far are:

Plane

The geometry represents an infinite plane. The first polygon
found in the group will define the plane.

Polygon

The geometry represents a single polygon. The first polygon is
used.

Polyset

The geometry represents a complex shape made up of several
polygons. This collision type should not be overused, as it
provides the least optimization benefit.

Sphere

The geometry represents a sphere. The vertices in the group are
averaged together to determine the sphere's center and radius.

InvSphere

The geometry represents an inverse sphere. This is the same as
Sphere, with the normal inverted, so that the solid part of an
inverse sphere is the entire world outside of it. Note that an
inverse sphere is in infinitely large solid with a finite hole
cut into it.

Tube

The geometry represents a tube. This is a cylinder-like shape
with hemispherical endcaps; it is sometimes called a capsule or
a lozenge in other packages. The smallest tube shape that will
fit around the vertices is used.


The flags may be any zero or more of:

event

Throws the name of the <Collide> entry, or the name of the
surface if the <Collide> entry has no name, as an event whenever
an avatar strikes the solid. This is the default if the
<Collide> entry has a name.

intangible

Rather than being a solid collision surface, the defined surface
represents a boundary. The name of the surface will be thrown
as an event when an avatar crosses into the interior, and
name-out will be thrown when an avater exits.

descend

Instead of creating only one collision object of the given type,
each group descended from this node that contains geometry will
define a new collision object of the given type. The event
name, if any, will also be inherited from the top node and
shared among all the collision objects.

keep

Don't discard the visible geometry after using it to define a
collision surface; create both an invisible collision surface
and the visible geometry.

level

Stores a special effective normal with the collision solid that
points up, regardless of the actual shape or orientation of the
solid. This can be used to allow an avatar to stand on a
sloping surface without having a tendency to slide downward.


In most cases you should use 'Polyset descend' for invisible collision geometry and 'Polyset keep descend' if you want to use the visible geometry to make collision.


I just tested the exporter (and the maxscript) and it work... provided you don't want to export the collisions with both 'keep' and 'descend' flags. The max-script-gui-thing doesn't allow to put two flags, written manually only the first one will get exported.
I may be totally wrong, cause I'm a dancin' fool.
User avatar
wezu
 
Posts: 518
Joined: Tue May 19, 2009 1:03 pm

Postby silveralex » Tue Jan 24, 2012 5:32 pm

Thx! That's very helpful!
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY

Postby silveralex » Tue Jan 24, 2012 6:09 pm

A few follow ups - to check my understanding as I'm not a 3d artist.

If I just add the collide tag to an existing egg, I'm telling panda that this is special collider geometry. Does that mean:

A. the group I put the tag on is now invisible (like collision solids normally would be). So I actually would need 2 copies of the group (1 for visible, 1 for collision )

B. if I use polyset rather than a simpler shape, the resulting collision solid might be complex enough to hurt performance. , right? I'm assuming it's still better than just putting a collide mask on viewable geometry as the collision solid is internally optimized for collision checking. Correct?

Thanks

Edit: just re-read the explanation of the keep flag. It says using this would create both collision and visible geometry. So I sold use this to pt have to make 2 copies of everything? And it would still use the collision version and so would be optimized? Correct?
User avatar
silveralex
 
Posts: 235
Joined: Tue Apr 21, 2009 1:48 pm
Location: New York, NY


Return to Pipeline

Who is online

Users browsing this forum: No registered users and 0 guests

cron