I finally took some time to look at Jeff's example, and I think I've
found the problem. The models Jeff is loading have triangle normals.
These are an optional attribute of a trimesh, though they're usually
a good idea since they save the renderer the trouble of calculating
them on the fly. But in the case of morphing meshes, they're a
hindrance; they don't get updated just because you've changed the
triangle positions, and because they're NOT calculated on the fly,
they remain in effect, causing triangles to be culled
inappropriately. (And if you don't have vertex normals, then it
causes them to be shaded inappropriately too.)
Fortunately, there is a pretty easy fix: don't use triangle normals
with models you're going to morph! Then Quesa/QD3D will recalculate
them on each frame, and they'll always be correct even as your model
morphs.
Meshwork doesn't have an option for this, but it does comment its
3DMF output, so it's easy to find the "triangle normals" section and
cut it out. An automated post-processor could of course be made to
do this if you need it a lot.
Another way around it is to copy the original TriMesh into one you
have more control over, like so:
Protected Function CopyTrimesh(tm As Trimesh) As Trimesh
// Make a new Trimesh with the same geometry as the given one.
// But this way, we make sure we don't have any extra attributes
// we don't want (like triangle normals!).
Dim out As New Trimesh
out.VertexCount = tm.VertexCount
out.VertexPositions.Copy tm.VertexPositions
out.TriangleCount = tm.TriangleCount
out.Triangles.Copy tm.Triangles
return out
End Function
Jeff, in your demo, simply adding the above method and loading your poses with:
mPoses.Append CopyTrimesh( Obj.Trimesh(0) )
in the Box constructor seems to fix it. Note that I haven't copied
the material here -- in a real app, you'd almost certainly want to
copy that too.
As a side note, Jeff, I notice in your demo that you're looping over
the vertices and interpolating for each one. That's OK, but not as
fast (nor as easy!) as it could be; the VectorList class has methods
to operate on the entire list at once. I'd demonstrate, but I have
to run; let me know if you want any help figuring that out.
Best,
- Joe
--
Joseph J. Strout
joe at strout dot net
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|