You definitely don't want to use a polysoup for this.  You'll
dramatically increase the cost of physics for every object you do this
to.

Unfortunately, there isn't an API in vphysics that allows you to
construct non-polysoup convexes with a specific triangulation.  So
you're not going to be able to solve this exactly.  The planar
constraints will be the same, but the triangulation of those planar
polygons may not be (since it gets chosen by the code that creates
convex hulls).

Anyway, the best method I can think of is to use what vbsp uses:

                ICollisionQuery *pQuery =
physcollision->CreateQueryModel( pCollide );
                int convex = pQuery->ConvexCount();
                for ( int i = 0; i < convex; i++ )
                {
                        int triCount = pQuery->TriangleCount( i );
                        int brushIndex = pQuery->GetGameData( i );

                        Vector points[3];
                        for ( int j = 0; j < triCount; j++ )
                        {
                                pQuery->GetTriangleVerts( i, j, points
);

        // REPLACE THIS CODE
                                Vector normal = TriangleNormal(
points[0], points[1], points[2] );
                                dbrushside_t *pside = FindBrushSide(
brushIndex, normal );
                                if ( pside->texinfo != TEXINFO_NODE )
                                {
                                        int prop =
g_SurfaceProperties[texinfo[pside->texinfo].texdata];

pQuery->SetTriangleMaterialIndex( i, j, RemapWorldMaterial( prop ) );
                                }
        // REPLACE THIS CODE
                                // pQuery->SetTriangleMaterialIndex( i,
j, your index here );
                        }
                }
                physcollision->DestroyQueryModel( pQuery );


And then replace that bracketed code with something that matches to the
nearest face in the SMD collision model to get your texture/material.

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Justin Krenz
> Sent: Tuesday, September 06, 2005 1:35 AM
> To: [email protected]
> Subject: Re: [hlcoders] Model Surface Properties
>
> Ok, I checked out the studiomdl source to find out how to go
> about doing this.  It looks like when the collision model is
> built, it first gets the vertices, creates a convex hull, and
> then makes the final collision element.  That's no good so I
> altered it to take the vertices and turn them into triangles
> using the "Poly Soup" functions and then build the collidable
> from the soup where I can assign a material id per face.
> Unfortunately, only a few of the triangles are actually where
> they should be with some having vertices that can't possibly
> be right.  The model reports 72 vertices, but then the
> original function to turn the vertices into convex hulls only
> reports 14 non-duplicate vertices.  If I try using all 72, it
> outputs yellow text errors in the command window.
> Can you offer any advice?  My brain is fried for now, but I
> suppose it's just a matter of messing with it until it works.
>  I only hope that the exported .phy file is actually saving
> the material index for the faces.
>
> Jay Stelly wrote:
>
> >The collision models built by the MDL/studiomdl path have the same
> >low-level features as the ones built in Hammer.  But the
> tools do not
> >put per-face materials on the collision models.  So you
> would have to
> >modify the model compiler or do this in a post-process in
> your mod.  At
> >runtime, there is a 7-bit material index available per
> triangle on any
> >collision model.  In vbsp, the world model compiler builds a
> table of
> >the different surfaceprops used by the world and stores an
> index into
> >that table on each triangle.  You could do the same for your models,
> >but currently our tools do not do this.
> >
> >Jay
> >
> >
> >
> >
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED] On Behalf Of
> >>[EMAIL PROTECTED]
> >>Sent: Saturday, September 03, 2005 8:53 AM
> >>To: [email protected]
> >>Subject: [hlcoders] Model Surface Properties
> >>
> >>I want to be able to group faces/triangles of a collision
> mesh in one
> >>of my models into separate groups.  Inside my mod, I want
> to be able
> >>to tell from a trace which group of faces was hit by the
> trace.  The
> >>closest thing I can see at doing that is by looking at the
> "surface"
> >>(csurface_t) of the trace.  This doesn't give me much
> information, but
> >>from there I can use "surface.surfaceProps" to get to surfacedata_t.
> >>From there, I can get to "surfacegameprops_t" which has an
> interesting
> >>variable named "material".
> >>I was hoping from that I could get information about the material
> >>assigned to the collision mesh's faces.
> >>Unfortunately, the entire model yields the same material no matter
> >>what texture is assigned to it, and it looks like it's
> intended for a
> >>material defined in Hammer.  I'd rather not use hitboxes,
> but I will
> >>if that's the only alternative.
> >>
> >>_______________________________________________
> >>To unsubscribe, edit your list preferences, or view the
> list archives,
> >>please visit:
> >>http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>
> >>
> >>
> >>
> >
> >_______________________________________________
> >To unsubscribe, edit your list preferences, or view the list
> archives, please visit:
> >http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> >
> >
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list
> archives, please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to