Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
LEGO in POV-Ray

     Virtual LEGO® Models from CAD Programs in POV-Ray
Rendering of virtual LEGO® models from CAD programs
like LDraw™ and LeoGEO or LEGO Digital Designer® in POV-Ray

Français français
Italiano Italiano
Deutsch Deutsch

Home
- POV-Ray Tutorial
 
LEGO® and POV-Ray
   Content
CAD for LEGO®
  - LEGO Digital Designer®
  - LDraw ™
  - LDraw + LeoCAD
  - LDraw + MLCad

CAD to POV-Ray
  - LeoCAD to POV-Ray
  ->Axes + Scales
  - Adapted Colors
  - LGeo POV-Ray Objects

  - LEGO® Model Sizes + Grid

                                       

Adapting Axes and Scale
of CAD Objects converted to POV-Ray Objects

Virtual LEGO® models in LeoGEO are using a right handed system of coordinates,
(x right to the background (red), y left to the background (green)and z right up (blue))
The LeoCAD POV-Ray scene file output uses also a right handed system,
with a camera, a background and a light for a Brick_2x4 looks like this:

// File created by LeoCAD --------------//
#include "Brick_Test1.inc"

camera {
  sky <0,0,1>
  location <-10, -9, 6>
  look_at < 0.00, 0.00, 0.00>
  angle 30
}

background{ color rgb <1, 1, 1> }

light_source{<-10,-5,20> White shadowless}

object {
 lg_3001
 texture { lg_red }
 matrix <-1.0000, 0.0000, 0.0000,
          0.0000,-1.0000, 0.0000,
          0.0000, 0.0000, 1.0000,
          0.0000, 0.0000, 0.0000>
} // ----------------------------------// 
Where the include file "Brick_Test1.inc"
essentially is containing the following 3 lines:
#include "lg_color.inc"
#include "lg_defs.inc"
#include "lg_3001.inc" 

The LeoCAD POV-Ray scene file output
with some axes added for better orientation.

LDraw file for LeoCAD:
Brick_Test1.dat
Scene file for POV-Ray:
Brick_Test1.pov
with the according include file:
Brick_Test1.inc


Adapting Axes: In POV-Ray normally a left handed system is used.
So we have to convert not only the camera and light but also the objects to fit correctly in a left handed system.

Adapting Scale: In LDraw + LeoGEO a scale of 1 unit = 10mm is used. In POV-Ray we normally use 1 unit = 1m.
So if we want to integrate virtual LEGO models in our virtual POV-Ray world we have to scale the modells by "scale 0.01".


// LeoCAD POV-Ray Output File ---------//
// Adapted to left handed system  -----//
#declare lg_quality = 4; // 0~4
#include "lg_color.inc"
#include "lg_defs.inc"
#include "lg_3001.inc" // brick 2x4
// no additional include file needed!

#declare L_Transform =
 transform{ rotate<-90,-90,0> // y<->z
            scale 0.01       // 1 = 1m
            translate<0,0.0094,0> //up
          } // end L_Transform

camera {
  right x*image_width/image_height
  location <-0.04, 0.05, -0.0>
  look_at < 0.004, 0.00, 0.00>
  angle 30
}

background{ color rgb <1, 1, 1> }

light_source{<-10,15,-20> White}

object {
 lg_3001
 texture { lg_red }
 matrix <-1.0000, 0.0000, 0.0000,
          0.0000,-1.0000, 0.0000,
          0.0000, 0.0000, 1.0000,
          0.0000, 0.0000, 0.0000>
 transform{ L_Transform }
} // ----------------------------------// 

The Adapted LeoCAD POV-Ray scene file output
with some axes added for better orientation.

Adapted scene file for POV-Ray:
Brick_Test1_adapted.pov



© Friedrich A. Lohmüller, 2009
email email: (legacy email redacted)
www.f-lohmueller.de

 LEGO ® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this site.
LEGO has its own homepage:
www.lego.com, and a page on the Mindstorms system: mindstorms.lego.com