To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 11654
11653  |  11655
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Thu, 24 Jun 2004 17:53:31 GMT
Viewed: 
4034 times
  
In lugnet.cad, Don Heyse wrote:
In lugnet.cad, Carl Nelson wrote:
What about a flag for default behavior?  I've been coding to ignore
ones with default rotations,

Why?  I have a slow PC, and running the mirwiz.exe program is
nearly instantaneous.  It's a lookup and 2 matrix multiplies per
part.  If the exception matrix lookup fails, use the default matrix.
It would take extra, unneeded code to ignore things.  Resist the
urge...

Why process something as an exception when the default behavior is needed?  It's
all in what one sees as extra, unneeded code. ;-)

Though I just did some timing and I don't see any performance differences
between ignoring them and not.

but there are plenty of parts (especially slopes) that need a
(-1 0 0 0 1 0 0 0 1) rotation

Stop saying rotation.  It makes me think you're not doing it right.
That's a mirror matrix.

Exception matrix would probably be the best term, since it *always* mirrors and
*may* rotate.

If you *always* do the same matrix math there's no need to
distinguish.  If you're not, then you're making extra busy work
for yourself and possibly introducing bugs.  Here's the pseudo code.

  for (*ALL* parts in the subfile)
  {
    float m[4][4];  // Tempory working matrix.
    float md[4][4] = { // Default = left-right mirror
      {-1.0,0.0,0.0,0.0},
      {0.0,1.0,0.0,0.0},
      {0.0,0.0,1.0,0.0},
      {0.0,0.0,0.0,1.0}
    };
    float *me = md; // Init exception mirror to left-right (the default).
    float *mp = md; // Init global subfile mirror to left-right.

    for( i=0; i< numExceptions; i++ )
    {
       if (exception[i] matches this part)
       {
  // Use the matrix from the exception list (instead of md).
  me = exception[i].matrix
  // Also use the substitute partname
  strcpy(datname, exception[i].datname);
  break;
}
    }
    M4M4Mul(m,LinePtr->v,me); // Run the initial mirror on the part
    M4M4Mul(LinePtr->v,mp,m); // Apply global subfile mirror to part

    // NOTE: You can set mp to mirror across whatever plane you want.
    //       The example here mirrors the subfile across the YZ plane.
  }

It's simple and it's all done with mirrors, except for a few weird
parts which might contain a rotation and/or translation component
mixed in with the mirroring in the me matrix.

My reservation about doing it this way is that it is exclusively tied to a reflection matrix of (-1 0 0 0 1 0 0 0 1)--please see my response to your 2nd message.

So far I've only found a few door parts that need a translation
component.  See http://ldglite.sf.net/mirror.ini for details on
the doors.

Same here.  BTW, do you want me to send you the parts that I've changed
mirror.ini for already?  I've also confirmed some as correct by rotating
different models.

Carl



Message has 2 Replies:
  Re: Quick way to mirror-image a model?
 
(...) Well, yeah. But it's simpler to process it all -- the only exceptional processing you need is "look for the part in mirror.ini. If not found, use the default settings". With your method, you have to also add "if the matrix looks like MD, then (...) (20 years ago, 24-Jun-04, to lugnet.cad)
  Re: Quick way to mirror-image a model?
 
Oops, I missed replying to one point. (...) If you mean (-1 0 0 0 1 0 0 0 1) as the 'default' matrix, my response is: that default matrix works for *any* reflection across any arbitrary plane. If you mean (-1 0 0 0 1 0 0 0 1) as the reflection (...) (20 years ago, 24-Jun-04, to lugnet.cad)

Message is in Reply To:
  Re: Quick way to mirror-image a model?
 
(...) Why? I have a slow PC, and running the mirwiz.exe program is nearly instantaneous. It's a lookup and 2 matrix multiplies per part. If the exception matrix lookup fails, use the default matrix. It would take extra, unneeded code to ignore (...) (20 years ago, 24-Jun-04, to lugnet.cad)

65 Messages in This Thread:

















Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR