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 / 11616
11615  |  11617
Special: 
[DAT] (requires LDraw-compatible viewer)
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Tue, 22 Jun 2004 13:40:29 GMT
Viewed: 
3493 times
  
In lugnet.cad, Carl Nelson wrote:
In lugnet.cad, Don Heyse wrote:
It'd be really nice to create a MIRROR.INI file, put it in the ldraw
directory and keep it updated with the parts.  Then if you could put
some wrappers around your program to allow it to be used as an MLCAD
generator and an LDDP plugin, that'd be fantastic.

Is there any documentation about what functionality needs to be
exposed to make an MLCAD plugin?

Hmm, I don't know.  I'm pretty sure there's documentation on language
DLL creation, but I'm not so sure about the generators.  Ask this on the
.mlcad group.

I've been playing with this in a class-based architecture, that has an
LMirrorExceptionList that contains an array of LMirrorExceptionPart.
I've been using XmlSerializer to write this to an XML file

XML works, but it's harder for humans (ie. me) to read.

<PartFile>3045.dat</PartFile>
<SubstitutePartNumber>3045.dat</SubstitutePartNumber>

Under Steve's scheme the exception matrix for 3045.dat would be
created by multiplying a mirror matrix by a rotate 90 matrix.  This
would create a part that looks identical, but is in fact mirrored. So
I don't think you need more than one exception matrix per part.  Look
at this.  The second part looks similar, but is actually mirrored.
That's the exception matrix for MIRROR.INI (except for the -32 Z
offset).

1 2 0 0 0 1 0 0 0 1 0 0 0 1 3045.dat
1 1 0 -32 0 0 0 -1 0 1 0 -1 0 0 3045.dat

Here's Steve's method using homogeneous 4x4 matrices (because they
make the math pretty):

  Default = MD = (-1, 0, 0, 0,   0, 1, 0, 0,    0, 0, 1, 0,    0, 0, 0, 1)
  Exception = ME = (a, d, g, 0,   b, e, h, 0,    c, f, i, 0,    x, y, z, 1)

    For a typical (left right symmetric) part ME = MD

  Current = MC = (A, D, G, 0,   B, E, H, 0,    C, F, I, 0,    X, Y, Z, 1)
  Mirror across an arbitrary plane = MP = (...)
    see http://www.geocities.com/SiliconValley/2151/matrices.html
    (or use a simple mirror across the xy, yz, or xz plane).

  For each part, calculate MF (final matrix) where:
  Mirrored (with no mirrored parts) = MF = MP * MC * ME

It's easy enough to add a SaveText() method that would do it as a
single-line text format like your mirror.ini file too, but it's
easier to deal with XML than text parsing!

Unless the text parsing code is already written.  Then it's the same.
I put the MLCAD.INI (minifig configurator) file parsing in CVS on the
sourceforge, and the proposed MIRROR.INI file uses the same format.
However if you want to convert to and from XML, that's ok with me.

Ideally, the LMirror program could include an exception list editor.
I can expose a web service to receive updates to the mirror list and
retrieve the most current list to client apps--that'd be my
preferred way to deal with that problem.

Sounds like it could work.

Now that I've played with the problem some more in code, I'm
thinking the approach of defining a rotation + translation to
accurately depict the part may be addressing the symptom, rather
than the problem.  Really, the trick is under what conditions we
ignore a part rather than applying a rotation.  Universally applying
a rotation works for the majority of parts for a simple reason: most
parts exhibit symmetry of the X and Z axes about their center of
rotation.

Forget about rotation and use Steve's plan.  Universally applying
2 mirror matrices works for all parts.  In this case, the exceptions
use a default left-right mirror matrix for the initial mirror.

If we take, for example, 3747 (slope 33 3 x 2 inverted)

Under Steve's algorithm, this part is ordinary because of the symmetry
and doesn't need any special considerations, so we could leave it
out of MIRROR.INI.

Please pardon any errors above, and feel free to correct my
misunderstandings!  I've only really looked at the LDraw format
since last week and am completely given to errors.

Have you considered making the source code available?

Absolutely.  I'm a little loathe to do so anonymously until I'm at
some more stable code, but if you want it now send me an e-mail and
I'll post it when it's a little more polished.  I've also started a
.NET class library to deal with LDraw data that anyone is welcome to
receive.

This brings up a larger question.  LDraw.org is a great resource for
anyone wanting to get started as a user or those dealing with the
parts library, but doesn't contain much information for developers
other than the file specification.  It would be especially
instructive to me to see how others have coped with these
rotation/graphics matrix issues, and I can benefit from either
public inspection of my own source or being able to see others'
source.  What resources exist for LDraw developers?

This is the resource.  lugnet.cad.dev.  If you want code, it's
available for many of the programs.  Which ones were you looking for?
Ldglite code is available here.

  http://cvs.sourceforge.net/viewcvs.py/ldglite/ldglite/

I think the L3P parser and matrix functions are fairly easy to follow.
Better than anything I've written, anyways.

You can also look at the old ldraw FAQ.

  http://www.ldraw.org/OLD/community/memorial/archive/FAQ/

It seems to have some info that I can't always find in the newer
divided FAQs and specs.

Enjoy, Don



Message has 2 Replies:
  Re: Quick way to mirror-image a model?
 
(...) Steve, Don--thanks for the explanations; this now makes complete sense to me (finally!). For a reflection about the plane containing the Z & Y axes (left-to-right), the reflection matrix (Mp) should be: -1 0 0 0 1 0 0 0 1 Then Mp * (part-file (...) (20 years ago, 22-Jun-04, to lugnet.cad)
  Developing MLCAD plugins?
 
(...) I forwarded this question to here because I don't know the answer. Apparently there has been some discussion in the past about developing plugins for MLCAD: (URL) there a specification for plugin development? Thanks, Don (20 years ago, 23-Jun-04, to lugnet.cad, lugnet.cad.mlcad)

Message is in Reply To:
  Re: Quick way to mirror-image a model?
 
(...) Is there any documentation about what functionality needs to be exposed to make an MLCAD plugin? I've been playing with this in a class-based architecture, that has an LMirrorExceptionList that contains an array of LMirrorExceptionPart. I've (...) (20 years ago, 21-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