Animated Rotation of Model


Animated Rotation of Model
#1
I was wondering if there was a way to make LDView export a series of images showing a rotation around the model incrementally.

Could it be accomplished using the batch command (which I know next to nothing about)?
Reply
RE: Animated Rotation of Model
#2
(2016-05-14, 1:59)Tanner S. Wrote: I was wondering if there was a way to make LDView export a series of images showing a rotation around the model incrementally.

Could it be accomplished using the batch command (which I know next to nothing about)?

I did such an animation a couple of years ago.
 
There must be somewhere a script for this animation on one of my harddisks, but I can't remember the right one.

Maybe I can find it the next days, but there is no guarantee for this task ;-)

If I remember right, you need to export to a Povray file and manually edit this file to load the POV script.

/Max
Reply
RE: Animated Rotation of Model
#3
(2016-05-14, 1:59)Tanner S. Wrote: I was wondering if there was a way to make LDView export a series of images showing a rotation around the model incrementally.

Could it be accomplished using the batch command (which I know next to nothing about)?

LDView doesn't support this inherently. A batch file could be made relatively easily, with a constant latitude and increasing longitude from 0 to 360. This would be done with the -cg option, like -cg 30,0 for 30 degrees latitude, 0 degrees longitude. I'll try to get back to you with actual batch file contents.
Reply
RE: Animated Rotation of Model
#4
OK, here is the contents of a batch file:

Code:
@echo off
SET LDVIEW=C:\Program Files\LDView\LDView64.exe
FOR %%F IN (%*) DO (
   FOR /L %%L IN (0,1,359) DO (
        ECHO %%~nF-%%L.png
       "%LDVIEW%" -SaveSnapshot="%%~nF-%%L.png" -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L "%%F"
    )
)

I'm not batch file expert, and I haven't tested it with filenames with spaces (although it might work), nor have I tested it with full paths. Specify an LDraw file (or LDraw files) as the parameters for the program. It will generate PNG files from 0 to 359. Note that this is set up for a 64-bit LDView. Change the second line to the correct full path to your LDView.
Reply
RE: Animated Rotation of Model
#5
(2016-05-15, 5:31)Travis Cobbs Wrote: I'm not batch file expert, and I haven't tested it with filenames with spaces (although it might work), nor have I tested it with full paths. Specify an LDraw file (or LDraw files) as the parameters for the program. It will generate PNG files from 0 to 359. Note that this is set up for a 64-bit LDView. Change the second line to the correct full path to your LDView.

This is the code that I put in:

Code:
@echo off
SET LDVIEW=C:\Program Files (x86)\LDraw\LDView\LDView.exe
FOR %%F IN (%*) DO (
  FOR /L %%L IN (0,22.5,360) DO (
       ECHO %%~nF-%%L.png
      "%LDVIEW%" -SaveSnapshot="%%~nF-%%L.png" -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L "%%F"
   )
)

The code runs when I open a file with the batch file, but the rendered images are blank. Is the code wrong or is something else going on?
Reply
RE: Animated Rotation of Model
#6
(2016-05-17, 0:43)Tanner S. Wrote: The code runs when I open a file with the batch file, but the rendered images are blank. Is the code wrong or is something else going on?

Try deleting all the text between "%LDVIEW%" and "%%F" and see if LDView opens the file interactively. If not, that means that LDView can't find the file. If the filename (or path to the file) contains spaces, try renaming the file to not contain any spaces, and storing it in a path where nothing in the path contains spaces.
Reply
RE: Animated Rotation of Model
#7
(2016-05-17, 1:38)Travis Cobbs Wrote: Try deleting all the text between "%LDVIEW%" and "%%F" and see if LDView opens the file interactively. If not, that means that LDView can't find the file. If the filename (or path to the file) contains spaces, try renaming the file to not contain any spaces, and storing it in a path where nothing in the path contains spaces.

Sure enough, it was the space in the file path. Thanks. By the way, am I correct in assuming that it renders using the last selected preference setting?
Reply
RE: Animated Rotation of Model
#8
(2016-05-18, 20:48)Tanner S. Wrote:
(2016-05-17, 1:38)Travis Cobbs Wrote: Try deleting all the text between "%LDVIEW%" and "%%F" and see if LDView opens the file interactively. If not, that means that LDView can't find the file. If the filename (or path to the file) contains spaces, try renaming the file to not contain any spaces, and storing it in a path where nothing in the path contains spaces.

Sure enough, it was the space in the file path. Thanks. By the way, am I correct in assuming that it renders using the last selected preference setting?

Good to hear. And yes, it uses the last settings. You can easily change that by creating a Preference Set in LDView with all the settings you want, then adding a -PreferenceSet=<PrefSetName> to the command line in the bat file. I would strongly suggest not having spaces in the preference set name.

Note that the bat file can almost certainly be fixed to deal with spaces in input filenames, but I don't know off-hand how to do so.
Reply
RE: Animated Rotation of Model
#9
Cool, and thanks so much for your help. I'm sorry, but I have one last question.

Is there a way to make it render at specific angles, rather than using a "counter" per say. It doesn't appear that the program is able to render half-degrees, and I need it to output a series of images at the angles: 0, 22, 45, 67, 90, etc. Can this be done?
Reply
RE: Animated Rotation of Model
#10
(2016-05-19, 2:43)Tanner S. Wrote: Cool, and thanks so much for your help. I'm sorry, but I have one last question.

Is there a way to make it render at specific angles, rather than using a "counter" per say. It doesn't appear that the program is able to render half-degrees, and I need it to output a series of images at the angles: 0, 22, 45, 67, 90, etc. Can this be done?

First of all, I believe that the LDView command line supports real numbers there, not just integers, so 22.5 should work fine. Secondly, I think you can update the following line to use specific values instead of a loop from 0 to 359:

Code:
FOR /L %%L IN (0,1,359) DO (

Change it to look like this instead:

Code:
FOR %%L IN (0,22.5,45,67.5,90) DO (

Put whatever angles you want inside the parentheses. (Don't forget to also remove the /L.)
Reply
RE: Animated Rotation of Model
#11
Ok, here is the script, I used with POVRay:



Code:
Input_File_Name=model.pov

Initial_Frame=1
Final_Frame= 360

Subset_Start_Frame = 1
Subset_End_Frame = 359

Initial_Clock=1
Final_Clock=360 
Width=1024
Height=768 
Cyclic_Animation=off
Pause_when_Done=off
Output_File_Type=N
Output_Alpha=on 
Antialias=On
Antialias_Threshold=0.3    
Display=On



As far as I can remember I created the POV code with the LDView export and started this script.

/Max
Reply
RE: Animated Rotation of Model
#12
(2016-05-19, 18:32)Max Martin Richter Wrote: As far as I can remember I created the POV code with the LDView export and started this script.

/Max

Thanks! This may prove useful to me in the future, so I appreciate it.
Reply
RE: Animated Rotation of Model
#13
That's the ticket! Thanks so much for all of your help. This will make my job so much easier. The new bit of code worked wonderfully, and you were right, it did indeed work with non-integer numbers, so all is well.
Reply
RE: Animated Rotation of Model
#14
As a newbie to this forum and LDraw/Cad etc, this is exactly what I'm interested in achieving.
How do i actually implement this batch script?
From LCad/LView or POV?
Do i need to open a file in a text editor and add this or do I do it from within one of the mention software apps?
And how would I implement incremental angles less than 1 degree. (Reading earlier posts suggests this is possible)

I'm completely computer literate but not a "coder", though happy to open and modify etc if pointed in the right direction.

Advance thanks (and apologies).
Reply
RE: Animated Rotation of Model
#15
(2018-03-22, 4:03)AdamM Wrote: As a newbie to this forum and LDraw/Cad etc, this is exactly what I'm interested in achieving.
How do i actually implement this batch script?
From LCad/LView or POV?
Do i need to open a file in a text editor and add this or do I do it from within one of the mention software apps?
And how would I implement incremental angles less than 1 degree. (Reading earlier posts suggests this is possible)

I'm completely computer literate but not a "coder", though happy to open and modify etc if pointed in the right direction.

Advance thanks (and apologies).

The text in the Code sections is designed to be saved in a file with a file extension of .bat. You can copy from the forum here, and then paste into (for example) an empty file in Notepad. When you save the file in Notepad, include .bat at the end of the filename. Once you have the file, you should be able to just drop .ldr files onto it in Windows Explorer if you don't know how to use the command prompt. But if you do that, make sure there aren't any spaces anywhere in the filename or the path to the filename, because my batch file doesn't work if there are.

Note that if you install the 64-bit version of LDView, the second line of the file would look like this:

Code:
SET LDVIEW=C:\Program Files\LDraw\LDView\LDView64.exe

If you don't have a 64-bit version of Windows, it would look like this:

Code:
SET LDVIEW=C:\Program Files\LDraw\LDView\LDView.exe

As can hopefully be inferred from above, LDView's -DefaultLatLong option supports floating point values, so you could make it do fractional degrees. However, doing so in the batch file I originally presented would be most easily accomplished by copying and pasting the LDView command line inside the for loop, and then adding a hard-coded decimal part, and making the image filename unique for each line. So, for example, the following does a 45-degree spin in half-degree increments:

Code:
@echo off
SET LDVIEW=C:\Program Files (x86)\LDView\LDView.exe
FOR %%F IN (%*) DO (
   FOR /L %%L IN (0,1,45) DO (
       ECHO %%~nF-%%L-1.png
       "%LDVIEW%" -SaveSnapshot="%%~nF-%%L-1.png" -AutoCrop=0 -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L "%%F"
       ECHO %%~nF-%%L-2.png
       "%LDVIEW%" -SaveSnapshot="%%~nF-%%L-2.png" -AutoCrop=0 -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L.5 "%%F"
   )
)

Note that the -SaveZoomToFit=0 and -ZoomToFit=0 options are there so that all angles will have the same zoom level. LDView's default zoom level allows a model to be rotated to any angle without going outside the view boundaries. The AutoCrop=0 is option is there to make sure that all the images that are generated are the same size.

This will generate a bunch of PNG files. You will have to use some other program to combine them together into a movie file. To do it on the command line, you can use ffmpeg, but you're going to definitely going to have to read up on what the appropriate options would be to use with that.
Reply
RE: Animated Rotation of Model
#16
(2018-03-22, 6:04)Travis Cobbs Wrote:
(2018-03-22, 4:03)AdamM Wrote: As a newbie to this forum and LDraw/Cad etc, this is exactly what I'm interested in achieving.
How do i actually implement this batch script?
From LCad/LView or POV?
Do i need to open a file in a text editor and add this or do I do it from within one of the mention software apps?
And how would I implement incremental angles less than 1 degree. (Reading earlier posts suggests this is possible)

I'm completely computer literate but not a "coder", though happy to open and modify etc if pointed in the right direction.

Advance thanks (and apologies).

The text in the Code sections is designed to be saved in a file with a file extension of .bat. You can copy from the forum here, and then paste into (for example) an empty file in Notepad. When you save the file in Notepad, include .bat at the end of the filename. Once you have the file, you should be able to just drop .ldr files onto it in Windows Explorer if you don't know how to use the command prompt. But if you do that, make sure there aren't any spaces anywhere in the filename or the path to the filename, because my batch file doesn't work if there are.

Note that if you install the 64-bit version of LDView, the second line of the file would look like this:

Code:
SET LDVIEW=C:\Program Files\LDraw\LDView\LDView64.exe

If you don't have a 64-bit version of Windows, it would look like this:

Code:
SET LDVIEW=C:\Program Files\LDraw\LDView\LDView.exe

As can hopefully be inferred from above, LDView's -DefaultLatLong option supports floating point values, so you could make it do fractional degrees. However, doing so in the batch file I originally presented would be most easily accomplished by copying and pasting the LDView command line inside the for loop, and then adding a hard-coded decimal part, and making the image filename unique for each line. So, for example, the following does a 45-degree spin in half-degree increments:

Code:
@echo off
SET LDVIEW=C:\Program Files (x86)\LDView\LDView.exe
FOR %%F IN (%*) DO (
   FOR /L %%L IN (0,1,45) DO (
       ECHO %%~nF-%%L-1.png
       "%LDVIEW%" -SaveSnapshot="%%~nF-%%L-1.png" -AutoCrop=0 -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L "%%F"
       ECHO %%~nF-%%L-2.png
       "%LDVIEW%" -SaveSnapshot="%%~nF-%%L-2.png" -AutoCrop=0 -SaveZoomToFit=0 -ZoomToFit=0 -SaveSeries=1 -SaveWidth=1024 -SaveHeight=1024 -DefaultLatLong=30,%%L.5 "%%F"
   )
)

Note that the -SaveZoomToFit=0 and -ZoomToFit=0 options are there so that all angles will have the same zoom level. LDView's default zoom level allows a model to be rotated to any angle without going outside the view boundaries. The AutoCrop=0 is option is there to make sure that all the images that are generated are the same size.

This will generate a bunch of PNG files. You will have to use some other program to combine them together into a movie file. To do it on the command line, you can use ffmpeg, but you're going to definitely going to have to read up on what the appropriate options would be to use with that.

Thanks so much.
I'll keep you posted with my success or failure.
Cheers
Reply
RE: Animated Rotation of Model
#17
(2018-03-24, 5:14)ShireBrickz.com Wrote: Thanks so much.
I'll keep you posted with my success or failure.
Cheers

I have only recently discovered LDraw and can already appreciate the decades of work you guys have put into this. Also, sorry to revive an old thread but this seemed the most relevant to what I'm about to accomplish.

I would like to render individual pieces in isometric pixel art style so that the zoom level stays constant between each render. I've been using LDView on the command line to accomplish this. I haven't found any way to fix the zoom level. Only thing that seems to directly affect the size of the produced snapshot are the -SaveWidth= and -SaveHeight= parameters. 

Is there any way to fix the zoom level so that an invidual 1x1 stud is NxM pixels in each isometric render regardless of the size of the original brick?

If not possible with LDView is it possible in combination with other tools like L3P and POV-Ray?

Edit: Turns out it produces exactly the desired output by using the -cg30,45,50000 parameter
Reply
RE: Animated Rotation of Model
#18
(2020-12-17, 18:33)P Ko Wrote: I have only recently discovered LDraw and can already appreciate the decades of work you guys have put into this. Also, sorry to revive an old thread but this seemed the most relevant to what I'm about to accomplish.

I would like to render individual pieces in isometric pixel art style so that the zoom level stays constant between each render. I've been using LDView on the command line to accomplish this. I haven't found any way to fix the zoom level. Only thing that seems to directly affect the size of the produced snapshot are the -SaveWidth= and -SaveHeight= parameters. 

Is there any way to fix the zoom level so that an invidual 1x1 stud is NxM pixels in each isometric render regardless of the size of the original brick?

If not possible with LDView is it possible in combination with other tools like L3P and POV-Ray?

Edit: Turns out it produces exactly the desired output by using the -cg30,45,50000 parameter

You found an answer, but there should be two ways to do this:

Use -ModelSize=<size> to instruct LDView to pretend the model is the specified size. As long as the size you give it is at least as big as the biggest thing you render, it should do what you want. The size is the diameter of a sphere big enough to fully enclose the model centered at the model's center.

Alternatively (as you discovered), you can use -cg<lat>,<lon>,<rad>, and specify a fixed value for the camera globe radius. You'll have to figure out the appropriate radius. You can use Tools->Show POV-Ray Camera Info to show the camera location and the look_at point. The distance between those two points is the value you want for the radius (assuming you have the FOV set the same).
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 9 Guest(s)