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: Jeff Quan <jquan at mindspring dot com>
Date: Thu, 9 Feb 2006 18:07:50 -0800
Delivered-to: realbasic-games at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=mindspring.com; b=oysylIjkxcLJThaZWr3jrQRC2TnJdng6CUMDV0Ox2cYbHEyOA3Ng0ADGCcdPVWOL; h=Received:Mime-Version:In-Reply-To:References:Content-Type:Message-Id:From:Subject:Date:To:X-Mailer:X-ELNK-Trace:X-Originating-IP;
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>

On Feb 9, 2006, at 4:32 PM, Frank Condello wrote:

On 9-Feb-06, at 5:48 PM, Joseph J. Strout wrote:

You don't think it would be caused by the simple normal interpolation Jeff is trying to do?

Sure why not! @Jeff: Maybe post some code so we can have a look-see...


Okay, here's the code which does the morph. You'll notice that I've commented out the normals part, but that doesn't solve my problem -- I still get tearing. I think I should add that I'm working with a trimesh which is broken up with several seams, so it's not one continuous mesh.

Note: mObjectTrimesh holds the Trimesh in the RB3Dspace.

Sub UpdateMorph(timeLeft As Double, FPS As Double, start As Trimesh, goal As Trimesh)
  // Given the time elapsed between frames, the frames/sec speed
  // to animate at, and start/goal morph targets, update the current
  // mObjTrimesh to morph towards that goal.

  Dim i, j, lastFrame As Integer
  Dim percent As Double
  Dim v0, v1, n0, n1 As Vector3D
  Dim vFinal, nFinal As Vector3D

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

  j = mObjTrimesh.VertexCount - 1
  for i = 0 to j
    // Calculate difference vector between start and goal.
    v0 = start.VertexPositions.GetVector(i)
    v1 = goal.VertexPositions.GetVector(i)
    'n0 = start.VertexNormals.GetVector(i)
    'n1 = goal.VertexNormals.GetVector(i)

    vFinal = v1.Minus(v0)
    'nFinal = n1.Minus(n0)

    // Calculate how far to move along difference vector.
    vFinal.MultiplyBy percent
    'nFinal.MultiplyBy percent

    // Add it back to original positions to get final move.
    vFinal.Add(v0)
    'nFinal.Add(n0)

    // Copy it back to current trimesh.
    mObjTrimesh.VertexPositions.SetVector(i, vFinal)
    'mObjTrimesh.VertexNormals.SetVector(i, nFinal)
  Next




==
Jeff Quan
jquan at mindspring dot com
http://www.geocities.com/jeffqportfolio/

_______________________________________________
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>