## Problems positioning camera with exporter, utnits may be dif

General discussion regarding exporter development in general.

Moderators: Ratow, coordinators

### Problems positioning camera with exporter, utnits may be dif

Trying tofigure out the coordinates that should be given by an exporter I am testing. The program I am testing the exporter on has the positions of all the objects and camera as centimeters, and the rotations as angle. Testing with the camera the rotation seems to to transfer perfectly to luxrender camera but the position does not!

Does luxrender uses centimeters when positioning objects?
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

### Re: Problems positioning camera with exporter, utnits may be

Internally, Lux scale is in meters.
Linux builds packager

SATtva

Posts: 5500
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

### Re: Problems positioning camera with exporter, utnits may be

There most be other settings that need to be set up.
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

### Re: Problems positioning camera with exporter, utnits may be

If you want a non-square output, you need to set up the screenwindow parameter as well. The film width and height is made to fit within the screenwindow, which by default is square. Thus if you want to have "square pixels" you'll need to adjust the screen window to have the same aspect ratio as your film.

If width is greater than height, then compute a = height / widht, and use the following screen window: [-1 1 -a a]. If height is greater than width, use a = width / height, and [-a a -1 1].

For example, if you want an output resolution of 1920x1080, then a = 1080 / 1920 = 0.5625, and you want to use the following settings:

Code: Select all
Camera "perspective"   "float fov" [49]   "float screenwindow" [-1.0 1.0 -0.5625 0.5625]Film "fleximage"   "integer xresolution" [1920]   "integer yresolution" [1080]   ...
May contain traces of nuts.

Lord Crc

Posts: 4460
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Problems positioning camera with exporter, utnits may be

Thanks it worked!

But I have another problem with which I have been having problems for days, and it is how to correctly position the camera?
Seamingly it does not makes sence what happens, I can't gett it to work!

Also everything appears flipped horizontally.

As I understand the camera is suposed to be looking to the back with this parameters, am I rigth?

LookAt 0 0 0
0 0 1
0 1 0
Translate 0 -50 0
Rotate -180 1 0 0
Rotate 0 0 1 0
Rotate 0 0 0 1

Or what will be the parameters to point the camera back, front, left or rigth!
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

### Re: Problems positioning camera with exporter, utnits may be

Please! someone that has worked with making a Luxrender plugin
Please explain how to translate and rotate througth a lux file.

I can't figure it out, is a mess!
The scene file format page has not helped at all!

From the app I am exporting the file
Translate X, positives goes to the rigth
Translate Y, positives goes up
Translate Z, positives goes to the front

Rotate X, positives rotates the camera downwards
Rotate Y, positives rotates the camera towards it left side
Rotate Z, positives rolls the camera to it's rigth side

Thanks
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

### Re: Problems positioning camera with exporter, utnits may be

Usually for cameras one only uses the LookAt transform, however you are of course free to use a compound transformation as shown above.

Transformations are applied last to first. That is, if you have
Code: Select all
LookAt 0 0 0    0 0 1    0 1 0Translate 0 -50 0 Rotate -180 1 0 0

Then it will first rotate -180 degrees along the x axis, then translate -50 units along the y axis, and then concatenate with the LookAt transformation. As such I suspect you might want to try putting the LookAt last, ie

Code: Select all
Translate 0 -50 0 Rotate -180 1 0 0LookAt 0 0 0    0 0 1    0 1 0

Also, when using Rotate for each axis, keep gimbal lock in mind. Depending on the application you're writing an exporter for, you might get the orientation of an object or camera as a matrix. In that case you should use it with the Transform command, to avoid gimbal lock and other tricky issues with rotation.
May contain traces of nuts.

Lord Crc

Posts: 4460
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Problems positioning camera with exporter, utnits may be

I am exporting from Animation Master, it only provides euler roitations and/or quaternions!

But if I am to use only "LookAt" can you give an example on how to point the camera to the back and 45 degress down, pnly with the look at!

Thanks!
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

### Re: Problems positioning camera with exporter, utnits may be

Quaternions would be preferable, but you'll then have to convert them axis-angle form. See for example http://en.wikipedia.org/wiki/Rotation_r ... quaternion

Looking at the SDK for Animation Master, it looks like you can get the orientation matrix directly though? It seems HCamera should have a GetModelToWorldMatrix() method which you could use for this. http://hash.com/ftp/pub/Sdk/AMSDKDoc/classHCamera.html

As for the LookAt, it depends on which axis you'd like to have up and right etc. I'll assume a right-handed coordinate system, +x right, +y forwards and +z up. Then you'll have
Code: Select all
LookAt  0 0 0   0 -1 -1   0 0 1

I think... This should make the camera be situated at the origin (0, 0, 0), point towards the point (0, -1, -1), ie -1 unit along the y and x axis thus back (negative y) and 45 degrees down (negative x), keeping camera up as (0, 0, 1), ie world up.
May contain traces of nuts.

Lord Crc

Posts: 4460
Joined: Sat Nov 17, 2007 2:10 pm

### Re: Problems positioning camera with exporter, utnits may be

Yes Animation Master SDK apparently can do it, but again how to organize it for LuxRender!
The explanation in the documentation is really vage. I can get the scale vector and the x, y and z Axis.
each of them containing 3 values, x y and z values.

Just in case I am not just playing with the camera and rotation just for fun, I already have the meshes exported nicelly, and have some
basic materials set up too, so when I figure that rotation problem with the camera I will jump into materials!
In other words I am not waisting your time if you help me.
rasikrodri

Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

Next