Rendering an object from all angles?

Rendering an object from all angles?

Hello,

My objective is to come up with an easily repeatable method of rendering an object rotated in all possible positions at N degree increments. For example, 20 degree increments would produce 18 images along a single axis with a total of 18 * 18 * 18 for the entire set (5832 frames in total).

I imagine the best way to do this is via a simple script; although at the level of documentation for the javascript SDK this is quite difficult.

example code:

//percentage degree change
var n,x,y,z;
//how do we get an object? (Question 1)
var obj=doc.???? ("Folder1")
n=20;
for (x=0; x<=360;x+n) {
for (y=0; y<=360;y+n) {
for (z=0;z<=360;z+n){
//get radians
ix=Math.PI*2*cx/360;

//determine position of camera
cx=d*Math.sin(ix)
cy=d*Math.cos(iy)
cz=d*Math.sin(iz)

//some how set rotation of entity (Question 2)
obj.setParameter("rotation",cx,cy,cz)


//render the current frame to movie (or render & save)
doc.render() //how to get this to save to movie? (Question 3)
}
}
}

I'm finding this difficult to write because:

a) how do I reference an entity within a scene (like doc.getActiveCamera() except for objects / folders)
b) I assume it's just object.setparameter("rotation"),x,y,z) to change an objects orientation - is this correct?
c) i know about doc.render(); - is there way to save files automatically or to render to a movie file? (saving by hand each job is not practical)

Any help in this matter would very much be appreciated...
 
Hi,
sorry but your plan isn't possible yet. Mainly because the Javascript API and documentation isn't finalized yet. Some features are still missing like merging different renderings to a movie.

To set a rotation you have to use the following funktion because "rotation" is a vector parameter:
Code:
obj.setParameter("rotation",new Vector(cx,cy,cz));

To get access to the selected object use:
Code:
doc.getSelectedObject();

To get access to the scene graph use something like that:
Code:
var i;
var obj=doc.getRoot();

for(i=0;i<obj.childCount();i++){
   var child=obj.childAtIndex(i);
   
   print(child.getParameter("name");
   }


In genral I would recommend to write a script wich writes the animation into the rotation track and then render the animation with the "Render Animation" command. So you don't need an extra class for merging certain frames to a movie.

After the next update I will focus more on the Javascript stuff and try to finalize it.

By,
Martin
 
Back
Top