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 / 11614
11613  |  11615
Subject: 
Re: Quick way to mirror-image a model?
Newsgroups: 
lugnet.cad
Date: 
Mon, 21 Jun 2004 20:02:35 GMT
Viewed: 
2961 times
  
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?

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 that looks like:

<?xml version="1.0" encoding="utf-8" ?>
<LMirrorPartList xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
SerialNumber="2004062104">
<ExceptionPartList>
<Part>
<PartFile>3045.dat</PartFile>
<SubstitutePartNumber>3045.dat</SubstitutePartNumber>
<Translation>
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Translation>
<XReflectionMatrix>
<A>1</A>
<B>0</B>
<C>0</C>
<D>0</D>
<E>1</E>
<F>0</F>
<G>0</G>
<H>0</H>
<I>1</I>
</XReflectionMatrix>
<ZReflectionMatrix>
<A>0</A>
<B>0</B>
<C>-1</C>
<D>0</D>
<E>1</E>
<F>0</F>
<G>1</G>
<H>0</H>
<I>0</I>
</ZReflectionMatrix>
<ReverseTransformFor90Rotations>false</ReverseTransformFor90Rotations>
</Part>
<Part>
<PartFile>2357.dat</PartFile>
<SubstitutePartNumber>2357.dat</SubstitutePartNumber>
<Translation>
<X>0</X>
<Y>0</Y>
<Z>0</Z>
</Translation>
<XReflectionMatrix>
<A>0</A>
<B>0</B>
<C>1</C>
<D>0</D>
<E>1</E>
<F>0</F>
<G>-1</G>
<H>0</H>
<I>0</I>
</XReflectionMatrix>
<ZReflectionMatrix>
<A>0</A>
<B>0</B>
<C>-1</C>
<D>0</D>
<E>1</E>
<F>0</F>
<G>1</G>
<H>0</H>
<I>0</I>
</ZReflectionMatrix>
<ReverseTransformFor90Rotations>true</ReverseTransformFor90Rotations>
</Part>
</ExceptionPartList>
</LMirrorPartList>.

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!

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.

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.

If we take, for example, 3747 (slope 33 3 x 2 inverted) being mirrored about the
Z axis (left-to-right mirroring), the 180-degree rotation is desirable for a
part oriented 3 studs across by 2 high but not for one oriented 2 studs across
by 3 high.  (That's what the
<ReverseTransformFor90Rotations>true</ReverseTransformFor90Rotations> element
above was intended to deal with, by applying a 180-degree rotation after the
initial 180-degree rotation for parts oriented under certain conditions--but I
have not thoroughly identified those conditions nor arrived at an optimal
solution yet.)

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?  None of the committees really seem
appropriate--the LSC is concerned with the file specification, the Tech List
with the website operations, the Content List with the website contents, and the
parts reviewers for parts issues.

Thanks for humoring my random queries!

Carl



Message has 1 Reply:
  Re: Quick way to mirror-image a model?  [DAT]
 
(...) 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. (...) XML works, but it's harder for humans (ie. me) to read. (...) Under Steve's scheme (...) (20 years ago, 22-Jun-04, to lugnet.cad)

Message is in Reply To:
  Re: Quick way to mirror-image a model?
 
(...) Take a peek at the MLCAD.INI file for minifig posing. Could you use a config file like this to handle the exceptions? I'd imagine if you pick one axis for mirroring that works best with most parts, (I think Travis said most were symmetric (...) (20 years ago, 18-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