LDraw.org Discussion Forums

Full Version: LDView povray export
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Here are some things I suggest for LDView's povray export. They all make things easier when using an external file to set variables, which I do often. I.e. I will create a "wrapper" file that is used in common by several scenes.

1. Precede all variable declarations with #IFNDEF. For instance:

Change this

Code:
#declare LDXQual = 3;

To this

Code:
#ifndef (LDXQual) #declare LDXQual = 3; #end

2. Check the variable's value when disabling lights and camera. For instance:

Change this

Code:
// Camera
#ifndef (LDXSkipCamera)
camera {
    #declare LDXCamAspect = image_width/image_height;
    location LDXCameraLoc
    sky LDXCameraSky
    right LDXCamAspect * < -1,0,0 >
    look_at LDXCameraLookAt
    angle 77.011589
}
#end

To this

Code:
// Camera
#ifndef (LDXSkipCamera) #declare LDXSkipCamera = false; #end

#if (LDXSkipCamera = false)
camera {
    #declare LDXCamAspect = image_width/image_height;
    location LDXCameraLoc
    sky LDXCameraSky
    right LDXCamAspect * < -1,0,0 >
    look_at LDXCameraLookAt
    angle 77.011589
}
#end

3. Create a variable to enable/disable the background. For instance:

Code:
#if (LDXShowBackground = true) background { color rgb <LDXBgR,LDXBgG,LDXBgB> } #end

4. Lastly, if you could do the camera calculations inside the POV file instead of "hardcoding" the values, that would be great. For instance, start with latitude, longitude and radius to generate the camera location; then translate the camera based on the center of the bounding box. (I'm not 100% sure exactly what LDView does to output the camera.)


Thank you!!
(2019-06-20, 6:47)Michael Horvath Wrote: [ -> ]Here are some things I suggest for LDView's povray export. They all make things easier when using an external file to set variables, which I do often. I.e. I will create a "wrapper" file that is used in common by several scenes.

1. Precede all variable declarations with #IFNDEF. For instance:

Change this

Code:
#declare LDXQual = 3;

To this

Code:
#ifndef (LDXQual) #declare LDXQual = 3; #end

The above should be unnecessary. The intent is for you to redefine all of these values in whatever file you tell LDView to use as its "Top include". This filename (if set) gets #included immediately following all of the declares, so you can redefine (or undefine) any of them there.


(2019-06-20, 6:47)Michael Horvath Wrote: [ -> ]2. Check the variable's value when disabling lights and camera. For instance:

Change this

Code:
// Camera
#ifndef (LDXSkipCamera)
camera {
    #declare LDXCamAspect = image_width/image_height;
    location LDXCameraLoc
    sky LDXCameraSky
    right LDXCamAspect * < -1,0,0 >
    look_at LDXCameraLookAt
    angle 77.011589
}
#end

To this

Code:
// Camera
#ifndef (LDXSkipCamera) #declare LDXSkipCamera = false; #end

#if (LDXSkipCamera = false)
camera {
    #declare LDXCamAspect = image_width/image_height;
    location LDXCameraLoc
    sky LDXCameraSky
    right LDXCamAspect * < -1,0,0 >
    look_at LDXCameraLookAt
    angle 77.011589
}
#end

Once again, the expectation is that you would use "#undef LDXSkipCamera" in your top include to force LDXSkipCamera to not be defined (if that is your goal).


(2019-06-20, 6:47)Michael Horvath Wrote: [ -> ]3. Create a variable to enable/disable the background. For instance:

Code:
#if (LDXShowBackground = true) background { color rgb <LDXBgR,LDXBgG,LDXBgB> } #end

This makes sense (although I would probably use "#ifndef (LDXSkipBackground) ..." for consistency.


(2019-06-20, 6:47)Michael Horvath Wrote: [ -> ]4. Lastly, if you could do the camera calculations inside the POV file instead of "hardcoding" the values, that would be great. For instance, start with latitude, longitude and radius to generate the camera location; then translate the camera based on the center of the bounding box. (I'm not 100% sure exactly what LDView does to output the camera.)

It's been a long time since I worked on the POV-Ray stuff, so I'm not sure about how difficult this would be. I'll at the very least look into it.
(2019-06-20, 17:37)Travis Cobbs Wrote: [ -> ]The above should be unnecessary. The intent is for you to redefine all of these values in whatever file you tell LDView to use as its "Top include". This filename (if set) gets #included immediately following all of the declares, so you can redefine (or undefine) any of them there.

Up until now I have been wrapping the model files (generated using L3P up until this point) inside an outer file with scene settings, camera, etc. This is a lot easier for me since I don't have to edit each model file when a wrapper gets edited, renamed or merged together with other wrappers. I have dozens of models, and a dozen or so wrappers, so this is not trivial. And each time I make a change to a model I have to push each file to GitHub/SourceForge.

Here's an example of one of my wrapper files:

Code:
#version 3.7;


// -------------------------------------------------------------
// LDCad settings with LGEO

#include "settings_common_before.inc"
#include "settings_showcase_normal.inc"
#include "lg_defs.inc"
#include "lg_color.inc"
#include "blurred_reflection.inc"
#include "materials_ldc_shadowno.inc"                // LQ
//#include "materials_ldc_shadowno_mjh.inc"            // MQ
//#include "materials_ldc_shadowno_clipka.inc"        // HQ
#include "materials_ldc_out.inc"
#include "materials_all_missing.inc"
#include "materials_all_convert.inc"


// -------------------------------------------------------------
// LDView models

//#include "ldv_nice_androbot_mech_new.pov"
//#include "ldv_nice_red_devil_racer_new.pov"
#include "ldv_nice_dune_rover_new.pov"                // takes too long to render

The models are at the bottom. And each model may be included in *several* wrappers, depending on if I want a different viewpoint or background, or a scene with multiple models. I don't think this would break your top includes either.

(2019-06-20, 17:37)Travis Cobbs Wrote: [ -> ]Once again, the expectation is that you would use "#undef LDXSkipCamera" in your top include to force LDXSkipCamera to not be defined (if that is your goal).

I think it would be better to set a variable to equal true or false versus deleting, commenting out, or undeffing a line each time you want to skip or unskip a camera or light source.

Changing this

#declare LDXSkipCamera = true;

to this

#undef LDXSkipCamera;

each time is more error prone and more typing.
(2019-06-20, 23:03)Michael Horvath Wrote: [ -> ]Up until now I have been wrapping the model files (generated using L3P up until this point) inside an outer file with scene settings, camera, etc. This is a lot easier for me since I don't have to edit each model file when a wrapper gets edited, renamed or merged together with other wrappers. I have dozens of models, and a dozen or so wrappers, so this is not trivial. And each time I make a change to a model I have to push each file to GitHub/SourceForge.

OK, I'll wrap all of the #declare statements in #ifndefs.


(2019-06-20, 23:03)Michael Horvath Wrote: [ -> ]I think it would be better to set a variable to equal true or false versus deleting, commenting out, or undeffing a line each time you want to skip or unskip a camera or light source.

Changing this

#declare LDXSkipCamera = true;

to this

#undef LDXSkipCamera;

each time is more error prone and more typing.

I'm not going to change this, because I don't really agree, and your suggested change will change the behavior for everyone else. If you want to define your own camera, #declare LDXSkipCamera to anything, and the generated POV will omit defining a camera. If you want to use the defined camera, don't define LDXSkipCamera (or #undef it instead of setting it to false if you define it in multiple places). Similarly, I will add #ifndef (LDXSkipBackground) around the background definition, so you can define that (to any value) to have LDView's POV omit its background declaration.
(2019-06-20, 17:37)Travis Cobbs Wrote: [ -> ]
(2019-06-20, 6:47)Michael Horvath Wrote: [ -> ]4. Lastly, if you could do the camera calculations inside the POV file instead of "hardcoding" the values, that would be great. For instance, start with latitude, longitude and radius to generate the camera location; then translate the camera based on the center of the bounding box. (I'm not 100% sure exactly what LDView does to output the camera.)

It's been a long time since I worked on the POV-Ray stuff, so I'm not sure about how difficult this would be. I'll at the very least look into it.

I've come to the conclusion that I'm not conversant enough in POV-Ray syntax to do this. If you can come up with a camera definition that takes the following inputs, I can incorporate your definition into the generated POV code when lat/long camera positioning is used:
  • LDXCameraLookAt (The center of the model, and the point at which the camera is looking.)
  • LDXCamAspect (The aspect ratio of the rendered scene; used in the "right" vector right now.)
  • LDXCameraDistance (The distance from the camera to the center of the model.)
  • LDXCameraLatitude
  • LDXCameraLongitude
  • LDXCameraAngle

If you need more input parameters, let me know; I can probably provide them, but I think the above is all that should be needed.
(2019-06-21, 2:04)Travis Cobbs Wrote: [ -> ]I'm not going to change this, because I don't really agree, and your suggested change will change the behavior for everyone else. If you want to define your own camera, #declare LDXSkipCamera to anything, and the generated POV will omit defining a camera. If you want to use the defined camera, don't define LDXSkipCamera (or #undef it instead of setting it to false if you define it in multiple places). Similarly, I will add #ifndef (LDXSkipBackground) around the background definition, so you can define that (to any value) to have LDView's POV omit its background declaration.

 I did a quick test rendering the following scene:

Code:
// -------------------------------------------------------------
// Test code

#undef LDXSkipCamera

// -------------------------------------------------------------
// LDView models

#include "ldv_nice_dune_rover_new.pov"

POV-Ray issues a warning, but thankfully does not halt the render with an error.

Quote:line 5: Parse Warning: Attempt to undef unknown identifier
(2019-06-21, 21:56)Michael Horvath Wrote: [ -> ] I did a quick test rendering the following scene:

Code:
// -------------------------------------------------------------
// Test code

#undef LDXSkipCamera

// -------------------------------------------------------------
// LDView models

#include "ldv_nice_dune_rover_new.pov"

POV-Ray issues a warning, but thankfully does not halt the render with an error.
Just throw an #ifdef in there.
(2019-06-21, 22:00)Orion Pobursky Wrote: [ -> ]Just throw an #ifdef in there.

Also, LDXSkipCamera will never be defined by LDView, so unless your own code defines it, there's no need for a #undeclare. The same will be true in the future for the new LDXSkipBackground.
(2019-06-21, 22:00)Orion Pobursky Wrote: [ -> ]Just throw an #ifdef in there.

I guess I could also do this:

Code:
#declare EnableCamera = true;
#if (EnableCamera = false)
    #declare LDXSkipCamera = true;
#elseif (EnableCamera = true)
  #ifdef (LDXSkipCamera)
    #undef LDXSkipCamera
  #end
#end

This is very convoluted compared to just switching a variable from true to false or the reverse, however. As if my include files didn't already have too much junk in them.
(2019-06-21, 23:53)Travis Cobbs Wrote: [ -> ]Also, LDXSkipCamera will never be defined by LDView, so unless your own code defines it, there's no need for a #undeclare. The same will be true in the future for the new LDXSkipBackground.

If you want to be consistent then you may change the LDXFloor true/false flag to LDXSkipFloor since you are just toggling an object on/off versus changing the informational value of data.
Pages: 1 2