POV-Ray : Newsgroups : povray.programming : Moray/Pov-Ray coordinate system converter. Server Time
29 Jul 2024 08:20:58 EDT (-0400)
  Moray/Pov-Ray coordinate system converter. (Message 1 to 2 of 2)  
From: Thomas Lake
Subject: Moray/Pov-Ray coordinate system converter.
Date: 28 Apr 2002 07:57:40
Message: <3ccbe3b4$1@news.povray.org>
I'm trying to write a program that converts Moray's povray output, which
uses the right hand coordinate system, to povray's native left handed
system. As you can see from the images bellow I'm not quite 1/2 way there
yet. The method I use is simply to comment out the sky and up key words in
Moray's output thereby defaulting to povray's lefthanded system. Then for
all vectors I switch the z and y positions. For example

translate <10,-50,100>

becomes

translate <10,100,-50>

This seems to work fine for translate and scale but rotation is a different
matter all together. I found a way to get rotation to work some of the time
by reversing the sign of the magnitude and rotating around the Z axis before
the y axis, so for example

rotate <-28.678608, -34.926117, 42.857418>

becomes

rotate 28.678608*x rotate 34.926117*z rotate -42.857418*y

As you can see from the image below this works for the rotated box in the
background but not for the superellipsoid in the front. Also I get all kinds
of nightmarish things happening if I try to work with csg and rotation. Can
anyone help here cause I feel like I'm close to a solution.

<SEE P.B.I under same Subject for pictures>

--
----------------------------------------------------------------------------
-----------
Home Page: http://www.geocities.com/~thomaslake/
----------------------------------------------------------------------------
-----------


Post a reply to this message

From: Alan Kong
Subject: Re: Moray/Pov-Ray coordinate system converter.
Date: 28 Apr 2002 16:57:45
Message: <1foocu08n9b8s152dlq7l5vk6dcr6aj3m5@4ax.com>
On Sun, 28 Apr 2002 04:57:57 -0700 Thomas Lake wrote:

>I'm trying to write a program that converts Moray's povray output, which
>uses the right hand coordinate system, to povray's native left handed
>system.

  See if John Van Sickle's "Thoroughly Useful Macros" is helpful to you.
It's a nice collection of John's stuff at:

http://enphilistor.users4.50megs.com/macs.htm

-- 
Alan
ako### [at] povrayorg
a k o n g <at> p o v r a y <dot> o r g


Post a reply to this message

From: Thomas Lake
Subject: Re: Moray/Pov-Ray coordinate system converter.
Date: 29 Apr 2002 04:44:45
Message: <3ccd07fd$1@news.povray.org>
>   See if John Van Sickle's "Thoroughly Useful Macros" is helpful to you.
> It's a nice collection of John's stuff at:
>
> http://enphilistor.users4.50megs.com/macs.htm

Thanks for the link! With his macros I was introduced to matrix transforms
and was able to solve "most" of my problems. Placing:

matrix <1,0,0, 0,0,1, 0,1,0, 0,0,0>

At the end of all the transformations in every object correctly switches the
scene from right to left handed. However the tricky part is creating a
program that knows where to place this. For example:

sphere{
    <0,0,0>,2
    scale <10,1,10>
    rotate <45,67,180>
    translate <45,12,-78>
    rotate 45*z
    matrix <1,0,0, 0,0,1, 0,1,0, 0,0,0>
}

This is easy to place but this is not:

union{
    object{
        myobject
            scale...
            rotate...
            translate...
    }
    object{
        myobject2
            scale...
            rotate...
            translate...
    }
}

Here each object should get a copy of the matrix transform However in the
following:

#declare HgtFld001 = object {
  height_field {
    tga "C:\Program Files\Moray For Windows\Maps\test - roundabout
street.tga"
    water_level 0.0
  }
  rotate    <-90, 0, 0> // Turn onto XY plane. Now points along -Z
  scale     <  2, 2,-2> // Scale to Cube size. Now points along +Z
  translate < -1,-1,-1> // Center around origin
  material {
    Dirt
  }
  scale <25.6306, 25.6306, 0.96627>
  translate  0.481242*z
matrix <1,0,0, 0,0,1, 0,1,0, 0,0,0>

}
intersection { // CSG001
  cylinder { // Cylndr001
    <0,0,1>, <0,0,0>, 1
    scale <19.211306, 19.211306, 3.194606>
    translate  -0.791182*z
matrix <1,0,0, 0,0,1, 0,1,0, 0,0,0>

  }
  object { HgtFld001 }
  material {
    Dirt
  }
}

The placement is even more tricky. Because of this I was only able to get my
program to correctly apply the matrix transformation about 60-70% of the
time. This is a little too complicated for me for now so I've decided to
give up for the time being.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Moray/Pov-Ray coordinate system converter.
Date: 29 Apr 2002 08:57:51
Message: <3ccd434f@news.povray.org>
Hi Thomas!
Looks good!
I do a lot of converting from Moray to POV-Ray and from POV-Ray to Moray (in
that case as includes in Moray).
In the first case, I always add the following lines to the POV-Ray output
from Moray (after some editing, and declaring a particular object for
instance):

scale <-1,1,1>
rotate <-90,0,0>

This always works fine in further work in POV-Ray. The object is mirrored
correctly for POV-Ray (you need to do that, else the object is not like the
original). The object answers now to the POV-Ray coordinate system and you
can place it wherever you want.

In the second case, I add the following lines:

scale <1,1,-1>
rotate <90,0,0>

And include the file to the Moray scene. This is more tricky of course
because you do not see the object in Moray. But if you are careful, you can
even place Moray things on the POV-Ray thing, if you see what I mean.

Could this help you for your program? Because these two lines seem the only
things to matter really...

Best wishes,

Thomas de Groot



"Thomas Lake" <tla### [at] REMOVE-THISshawca> schreef in bericht
news:3ccbe3b4$1@news.povray.org...
>
> I'm trying to write a program that converts Moray's povray output, which
> uses the right hand coordinate system, to povray's native left handed
> system. As you can see from the images bellow I'm not quite 1/2 way there
> yet. The method I use is simply to comment out the sky and up key words in
> Moray's output thereby defaulting to povray's lefthanded system. Then for
> all vectors I switch the z and y positions. For example
>
> translate <10,-50,100>
>
> becomes
>
> translate <10,100,-50>
>
> This seems to work fine for translate and scale but rotation is a
different
> matter all together. I found a way to get rotation to work some of the
time
> by reversing the sign of the magnitude and rotating around the Z axis
before
> the y axis, so for example
>
> rotate <-28.678608, -34.926117, 42.857418>
>
> becomes
>
> rotate 28.678608*x rotate 34.926117*z rotate -42.857418*y
>
> As you can see from the image below this works for the rotated box in the
> background but not for the superellipsoid in the front. Also I get all
kinds
> of nightmarish things happening if I try to work with csg and rotation.
Can
> anyone help here cause I feel like I'm close to a solution.
>
> <SEE P.B.I under same Subject for pictures>
>
> --
> --------------------------------------------------------------------------
--
> -----------
> Home Page: http://www.geocities.com/~thomaslake/
> --------------------------------------------------------------------------
--
> -----------
>
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.