Using auto-include files from LDView POV export

Using auto-include files from LDView POV export
Following some discussion elsewhere I figured it would be worth writing a bit about this issue. I'll add to this if I think of things and welcome questions.


LDView has offered the option of POVray export for quite a while now. This allows some quite powerful manipulations via POVray. Here I'll focus on two important options: Top include file and Bottom include file.

As the name suggests this inserts a line including a file either up top (straight after all parameters have been declared) or down bottom (right at the end of the file). Combined with the list of parameters this allows quite a lot of automation via these include files, beyond that which could be expected from the export alone.

Top include file

This file is particularly useful for overriding colours but might also be used for other things. It has access to all parameters output by LDView including details of the camera, floor, model bounds and other details but typically would probably just include personal declarations for colours.

Note that the colours LDview declares are only ever called if the colour isn't already declared. So whatever colours you declare will carry through to all other parts.

I've attached my default file here (note it calls but you can comment this out).

Bottom include file

This file is very important. It can be used to declare the floor, override the camera, declare lights (if you don't like the defaults switch them off and set them here). And it too has access not only to the same declared parameters as the top include file, but also indirectly to the filename details [1].

For example I like to surround all my POVray files by a large sphere with a skymap to improve (IMO) render quality. This depends both on the distance of the lights and camera (they must be inside the sphere) but also on the floor position (so I can center the sphere appropriately). The details are unimportant but I can get all this useful information straight from the main file.

Similarly I like to set my own lights to improve rendering. Again these are set in the include file.

Perhaps most useful for many people (and the reason this file is called last) is the ability to use the include file to override the camera. POVray only ever uses the last declared camera so whatever is declared in the include file is what will be used in the rendering. This is especially useful for animation. Note that the camera you set here means the camera set by LDView will be ignored. If you wish to use the camera set by LDView you must use the parameters LDXCameraLoc, LDXCameraSky and LDXCameraLookAt

I've attached my default file here (it may not run due to other files but it can be read).

[1] If you know the filename of the main submodel or model (for ldr files) just set
#ifdef (LDX_Filename_ldr)
Model specific actions go here
and you can deal with special cases in a generic way.

Attached Files
.inc (Size: 1.27 KB / Downloads: 1)
.inc (Size: 1.74 KB / Downloads: 2)
.inc (Size: 17.58 KB / Downloads: 1)
Re: Using auto-include files from LDView POV export
The other auto-include files (parts)

It should be noted that LDView also automatically includes another type of include file: those for parts. If it finds an in the parts includes directory where XXXX is a part number included in the original file, it will then call that part.

For example I declare a custom (and to make the old-style wheel. I place (attached) in the /ldraw/pov/parts folder (you may choose a different directory) and when I generate a POV file through LDView it inserts #include "" rather than a declaration of the part. must return a part in the format
#declare _132_dot_dat = union {
where the details of the part go inside. Be wary of sub-declares in these parts to make sure they don't override others in the main model.

Attached Files
.inc (Size: 1.12 KB / Downloads: 0)
.inc (Size: 1.12 KB / Downloads: 0)
Re: Using auto-include files from LDView POV export
Another reason to use include files is of course if you wish to add sky, landscape, or other non-LDraw objects.
Re: Using auto-include files from LDView POV export
Yes absolutely. And you can use the information LDView provides to make these work well.

Re: Using auto-include files from LDView POV export
Thanks for sharing, Tim. What does "" do at the end of your Could you provide that as well?
« Next Oldest | Next Newest »

Forum Jump:

Users browsing this thread: 1 Guest(s)