realbasic-games
[Top] [All Lists]

Re: Tearing in trimesh morphs

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Tearing in trimesh morphs
From: "Joseph J. Strout" <joe at strout dot net>
Date: Tue, 14 Feb 2006 09:43:54 -0700
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <AD2720A3-FE2D-43AB-A346-B11C9EAF0B19 at mindspring dot com> <a0620073bc0115bf6e836 at [10 dot 0 dot 1 dot 13]> <CB9FFBC4-8741-461E-B76C-D8BE4980D5E8 at chaoticbox dot com> <a0620073fc011766b1b83 at [10 dot 0 dot 1 dot 13]> <B78BCBE3-2AE6-4BFE-8415-3730A760860A at chaoticbox dot com> <C31343CF-851B-46FA-804F-16593F025A78 at mindspring dot com> <a06200770c01711e88cce at [10 dot 0 dot 1 dot 13]> <21F204E6-C77C-4E5B-973B-4506B7230E02 at mindspring dot com>
At 8:21 AM -0800 2/14/06, Jeff Quan wrote:

I'll look into this too (and shout for help if need be!). My only goal in this test is to get the morphing working and solve my backfaces triangle problem -- I haven't optimized anything yet. As a teaser, this demo app might show up in my talk at REALworld if I can clear out enough of the bugs to make it presentable :)

Sounds great! I took a moment to play with it some more this morning, and came up with this:

  // Calculate the percentage to morph based on elapsed time and
  // the frames/sec of the animation in question.
  percent = (FPS - timeLeft) / FPS

  Dim startList As VectorList = start.VertexPositions
  Dim goalList As VectorList = goal.VertexPositions

  // Calculate difference vector between start and goal.
  Dim target As VectorList = mObjTrimesh.VertexPositions
  target.SetToDifference( goalList, startList )

  // Calculate how far to move along difference vector.
  target.MultiplyAllBy percent

  // Add it back to original positions to get final move.
  target.AddList startList

This works fine, *if* I remember that you can't use something you're already morphing as either the "start" or "goal" pose. Well, you could, but the result is probably not going to be what you wanted! The simplest rule is to have one trimesh that you morph, and a set of "target" poses that you never muck with, so that you can always interpolate between them; if have a mesh that is both a target and is being morphed, it gets a lot more complicated to keep track of what's going on.

Your demo was using mObjTrimesh(0) as both the mesh to morph, and as one of the poses. I just changed this so that it uses only meshes 1 through 8 as target poses, and then it seemed to work fine.

Note that this problem should occur regardless of whether you're updating the vectors all at once, or one at a time -- I'm not sure why your original code didn't show the problem.

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>


<Prev in Thread] Current Thread [Next in Thread>