Home » Activities » LDraw & POV-Ray » LDraw to SimCity Email

LDraw to SimCity


Update 12/23/07: Minor rewording and formatting changes.

Update 10/11/05: I fixed some errors in the POV-Ray code with respect to camera placement. I also added the Rotate parameter to allow rotation of the camera around the y-axis (vertical axis).

Introduction:

Welcome. This tutorial instructs you on how to import LDraw models into SimCity 3000 Unlimited.

Maxis, the makers of SimCity 3000 Unlimited, have created their own tutorial on how to render objects and import them into the game. It is not required to complete this tutorial. To read it anyway, visit their website:
         http://simcity3000unlimited.ea.com/us/guide/tips/unlimited_tips/ccp1.phtml

Required Software:

For starters, let's go over the programs involved. The Building Architect Tool (BAT) and the SimCity 3000 Urban Renewal Kit (SC3URK) allow you to design and import your own buildings into SimCity 3000 and SimCity 3000 Unlimited, respectively. Of the two, SC3URK is the better tool for our purposes—but it only works with SimCity 3000 Unlimited!

This tutorial assumes that you are using SC3URK. SC3URK is not included on the SimCity 3000 Unlimited installation disk. Instead, it is available as a separate download from the SimCity website (see below).

You should already know how to build models using LDraw or MLCad and render them using POV-Ray (a program called L3P is used to convert between these two formats). For further information regarding these programs, as well as tutorials on how to use them, visit the LDraw website.

You will also need a paint program, such as Windows Paint.

Links:

  1. http://www.ldraw.org - LDraw Home Page
  2. http://simcity3000unlimited.ea.com/us/guide/ - SimCity 3000 Home Page
  3. http://simcity3000unlimited.ea.com/us/simexchange/downloads/sc3krk/index.phtml - download link for SC3URK
  4. http://www.povray.org/ - POV-Ray Home Page
PIC
DESCRIPTION
Yellow Castle
TYPE/ZONE
Residential
TILE SIZE
1x1
.SJS FILE
Download
.MPD FILE
Download
PIC
DESCRIPTION
Mining Facility
TYPE/ZONE
Industrial
TILE SIZE
2x2
.SJS FILE
Download
.MPD FILE
Download

The above images were created before this tutorial was finalized. Your images may look slightly different (especially the shadows).

Instructions:

  1. Build a model in LDraw or MLCAD.

  2. Orient your completed model so that it is centered within the coordinate system, with the bottom of the model resting upon the x-z plane, as shown below:


    In the above image, the x-axis is colored red, the y-axis is colored green, and the z-axis is colored blue. (Note that the coordinate axes will not appear when editing your model.)

  3. Convert your model into a *.POV file using L3P.

  4. Open up the *.POV file in POV-Ray and replace the light sources with the following code:

    // Warm lights:
    light_source
    {
    	<0, 0, 100000,>
    	color rgb <255/255, 249/255, 232/255,>
    	spotlight
    	parallel
    	point_at <0, 0, 0,>
    }
    light_source
    {
            <0, 0, -100000,>
    	color rgb <255/255, 249/255, 232/255,>
    	spotlight
    	parallel
            point_at <0, 0, 0,>
    }
    
    // Neutral lights:
    light_source
    {
            <0, 0, 0,>
    	color rgb <198/255, 198/255, 198/255,> * 0.75
           	spotlight
    	parallel
            point_at vaxis_rotate(<0, 100, 0,>, x, 30)
            translate <0, -100000, 0,>
    }
    light_source
    {
            <0, 0, 0,>
            color rgb <198/255, 198/255, 198/255,> * 0.75
    	spotlight
    	parallel
            point_at vaxis_rotate(<0, 100, 0,>, x, -30)
            translate <0, -100000, 0,>
    }
    
    // Cold lights:
    light_source
    {
            <100000, 0, 0,>
    	color rgb <98/255, 98/255, 133/255,> * 1.3
    	spotlight
    	parallel
            point_at <0, 0, 0,>
    }
    light_source
    {
            <-100000, 0, 0,>
    	color rgb <98/255, 98/255, 133/255,> * 1.3
    	spotlight
    	parallel
            point_at <0, 0, 0,>
    }
    					
  5. Now, replace the background and camera with the following code:

    // Background color
    background {color rgb <1, 0, 1,>}
    
    // Default tile size
    #declare Tile = 4;                      // Width (in tiles) of building.  1 = 1x1 tile; 2 = 2x2 tile, etc.
    
    // Specify a camera y-rotation angle
    #declare Rotate = 0;			// the camera is rotated around the y-axis by this amount
    
    // Camera:
    camera
    {
    	#local LegLength = sqrt(pow(640, 2) / 2) * 2;
    	orthographic
    	sky -y
    	up y * LegLength * Tile * image_height / image_width
    	right x * LegLength * Tile
    	location vaxis_rotate(<1, 0, 1,>, <1, 0, -1,>, 30) * LegLength * Tile
    	look_at <0, 0, 0,>
    	rotate y * Rotate
    	#if (frame_number > 0)
    		rotate y * 360/final_frame * (frame_number - 1)
    	#end
    }
    					

    Change the TILE keyword to reflect the width of your building, measured in SimCity tiles. To preserve the proper scale, one SimCity tile should equal one LDraw baseplate.

    You can rotate the camera around the y-axis by changing the ROTATE keyword to an angle in degrees. For instance, if the camera normally faces the NW corner of your model, you can change the ROTATE keyword to equal 180 to have it face the SE corner of your model.

  6. Create a new text file and paste the following code into it:

    ;; SC3URK 128px x 512px Output Bitmap
    Width = 128
    Height = 512
    Final_Frame = 4                 ;; Number of frames/views  
    Final_Clock = 3                 ;; Number of frames/views minus one
    Output_File_Name = c:\lego\ldraw\images\
    					

    Save or rename this text file as LDR2SC3K.INI and place it within the RENDERER directory in your POV-Ray installation directory.

    This file determines the height and width dimensions of the final images that POV-Ray will generate, as well as the number of images (frames) that will be rendered. A total of four images will be rendered -- one for each direction: NW, NE, SW and SE. The images should be 128 pixels wide if your building is 1x1 tiles in size, 256 pixels wide if it is 2x2 tiles in size -- and so forth, increasing in width by 128 pixels for each additional tile. You will need to experiment in order to determine what values are suitable for the HEIGHT parameter, as they will vary depending on your building's height.

    The last line specifies the directory you would like the rendered images saved to. Change this to a preferred location. Make sure you leave a back-slash ('\') at the end of the path.

  7. To render your model, select RENDER from the POV-Ray menu. Then, select EDIT SETTINGS/RENDER. Where it says INI FILE, click on BROWSE and find the LDR2SC3K.INI file. Once it's selected, click OK. Now click on SET BUT DON'T RENDER. This should bring you back to the main POV-Ray window. Now, click on the green RUN icon at the top of the screen. POV-Ray will now render your model and output the images into the directory you specified in LDR2SC3K.INI.

  8. If you are using BAT to import your images into SimCity 3000 (i.e., not SimCity 3000 Unlimited), you will have to crop the images in a paint program so that they properly fit the template images included with the program (you can also find them on the SimCity web site). If you are using SC3URK, instead (as is recommended), you will need to crop your images so that your building is aligned with the sides and bottom, like this:

  9. Run SC3URK and import the images. (Make sure you import them in the correct order.)

  10. After you've imported them into SimCity 3000 or SimCity 3000 Unlimited, an in-game screenshot featuring your completed building should look something like this:

    That's it! You're done!


Alternative instructions:

As an alternative to following the above steps, you could install the following *.INC and *.INI files (which I have created for you) and achieve the same results as you would have by following the tutorial, above.

  1. Follow steps 1 through 3 in the first tutorial.

  2. Download the following archive:
             LDR2SC3K_v1_2.ZIP

    Decompress the archive file using WinZip. Place the *.INC file within the INCLUDE directory of your POV-Ray installation directory. Place the *.INI file within the RENDERER directory of your POV-Ray installation directory.

  3. Open up your *.POV file in POV-Ray and replace the background, camera, and light sources with the following declarations and include-statements:

    // Default tile size
    #declare Tile = 4;                      // Width (in tiles) of building.  1 = 1x1 tile; 2 = 2x2 tile, etc.
    
    // Specify a camera y-rotation angle
    #declare Rotate = 0;			// the camera is rotated around the y-axis by this amount
    
    // SC3URK Scene Description Language
    #include "LDR2SC3K.INC"                 // Source of the camera and lighting code
    					

    Change the TILE declaration to reflect however wide your building is (in tiles):

  4. Select the *.INI file from the POV-Ray RENDER menu (see step 6, above). Render the images by pressing RENDER.

  5. Crop and import your building images into SimCity 3000, as described in steps 7 and 8, above.


LEGOŽ is a trademark of the LEGO Group, which does not sponsor, authorize, or endorse this site.

1