Problems positioning camera with exporter, utnits may be dif

General discussion regarding exporter development in general.

Moderators: Ratow, coordinators

Re: Problems positioning camera with exporter, utnits may be

Postby Lord Crc » Wed Dec 07, 2011 12:24 am

Yes, the SDK documentation is vague, so I downloaded it and had a look at the code. If you have a Matrix34, then you can use that to set the transform directly for the camera or an object, and I think you can do it like this, if I got the ordering right:

Code: Select all
void ExportCamera(std::ostream &outputstream, HCamera *camera) {
   Matrix34 m = camera->GetGlobalMatrix();

   outputstream << "Translate [" <<
       m[0][0] << " " << m[1][0] << " " << m[2][0] << " 0.0 " <<
       m[0][1] << " " << m[1][1] << " " << m[2][1] << " 0.0 " <<
       m[0][2] << " " << m[1][2] << " " << m[2][2] << " 0.0 " <<
       m[0][3] << " " << m[1][3] << " " << m[2][3] << " 1.0]" << std::endl;

   outputstream << "Camera \"perspective\"" << std::endl;
   outputstream << "\t" << "\"float fov\ [" << 90.0 << "]" << std::endl; // here you'd use camera->GetFocalLength() to compute true FOV value
}


At least that's the general idea. Thus you don't have to use LookAt or any of the others at all, just export the global transformation as-is.
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4447
Joined: Sat Nov 17, 2007 2:10 pm

Re: Problems positioning camera with exporter, utnits may be

Postby rasikrodri » Wed Dec 07, 2011 7:47 pm

Wow! Thanks for doing all that to help me!

I tested it but it did not work

What would you sugest me to do?

I did some testings and I think I got the scale and translation rigth according to the Luxrender reference http://www.luxrender.net/wiki/Scene_fil ... formations
But I don't know how the rotation should be!

Do I need to swap the z for the y and multiply the y by -1?, or are matrices usually compatible from everyware?
rasikrodri
 
Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

Re: Problems positioning camera with exporter, utnits may be

Postby Lord Crc » Thu Dec 08, 2011 1:31 am

rasikrodri wrote:Do I need to swap the z for the y and multiply the y by -1?, or are matrices usually compatible from everyware?


They should be, but there are some caveats. Since I don't have Visual Studio 7, just 2008 and 2010, I couldn't actually build any of the SDK samples to test.

First you could try using GetModelToWorldMatrix() instead of GetGlobalMatrix(). If that doesn't work, could you please try the following and post the results here?

Code: Select all
   Matrix34 m = Rotatef(45.0, 1.0, 0.0, 0.0);

   outputstream << "X-45 [" <<
       m[0][0] << " " << m[1][0] << " " << m[2][0] << " 0.0 " <<
       m[0][1] << " " << m[1][1] << " " << m[2][1] << " 0.0 " <<
       m[0][2] << " " << m[1][2] << " " << m[2][2] << " 0.0 " <<
       m[0][3] << " " << m[1][3] << " " << m[2][3] << " 1.0]" << std::endl;

   m = Rotatef(45.0, 0.0, 0.0, 1.0);

   outputstream << "Z-45 [" <<
       m[0][0] << " " << m[1][0] << " " << m[2][0] << " 0.0 " <<
       m[0][1] << " " << m[1][1] << " " << m[2][1] << " 0.0 " <<
       m[0][2] << " " << m[1][2] << " " << m[2][2] << " 0.0 " <<
       m[0][3] << " " << m[1][3] << " " << m[2][3] << " 1.0]" << std::endl;

   m = Translatef(2.0, 3.0, 4.0);

   outputstream << "T [" <<
       m[0][0] << " " << m[1][0] << " " << m[2][0] << " 0.0 " <<
       m[0][1] << " " << m[1][1] << " " << m[2][1] << " 0.0 " <<
       m[0][2] << " " << m[1][2] << " " << m[2][2] << " 0.0 " <<
       m[0][3] << " " << m[1][3] << " " << m[2][3] << " 1.0]" << std::endl;


This way I can verify the way it stores the matrices. When we get that sorted out, what remains is to use the right matrix.

Trying to extract rotation and translation values is very tricky and prone to error. It would be much preferable to just use the matrix directly.
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4447
Joined: Sat Nov 17, 2007 2:10 pm

Re: Problems positioning camera with exporter, utnits may be

Postby rasikrodri » Mon Dec 12, 2011 10:52 am

Here are the results

X-45 [1 0 0 0.0 0 0.707107 0.707107 0.0 0 -0.707107 0.707107 0.0 0 0 0 1.0]
Z-45 [0.707107 0.707107 0 0.0 -0.707107 0.707107 0 0.0 0 0 1 0.0 0 0 0 1.0]
T [1 0 0 0.0 0 1 0 0.0 0 0 1 0.0 2 3 4 1.0]
rasikrodri
 
Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

Re: Problems positioning camera with exporter, utnits may be

Postby rasikrodri » Thu Dec 15, 2011 12:21 pm

So, what do you think?
rasikrodri
 
Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

Re: Problems positioning camera with exporter, utnits may be

Postby Lord Crc » Thu Dec 15, 2011 12:24 pm

Sorry, been a bit busy here, lost track. I'll get back to you tonight.
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4447
Joined: Sat Nov 17, 2007 2:10 pm

Re: Problems positioning camera with exporter, utnits may be

Postby Lord Crc » Fri Dec 16, 2011 4:53 am

Ok I've verified the order and it was correct. However it was a typo in my original code! :oops: :oops:

Code: Select all
outputstream << "Translate

should be
Code: Select all
outputstream << "Transform


Thus the correct code should be
Code: Select all
void ExportCamera(std::ostream &outputstream, HCamera *camera) {
   Matrix34 m = camera->GetGlobalMatrix();

   outputstream << "Transform [" <<
       m[0][0] << " " << m[1][0] << " " << m[2][0] << " 0.0 " <<
       m[0][1] << " " << m[1][1] << " " << m[2][1] << " 0.0 " <<
       m[0][2] << " " << m[1][2] << " " << m[2][2] << " 0.0 " <<
       m[0][3] << " " << m[1][3] << " " << m[2][3] << " 1.0]" << std::endl;

   outputstream << "Camera \"perspective\"" << std::endl;
   outputstream << "\t" << "\"float fov\ [" << 90.0 << "]" << std::endl; // here you'd use camera->GetFocalLength() to compute true FOV value
}
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4447
Joined: Sat Nov 17, 2007 2:10 pm

Re: Problems positioning camera with exporter, utnits may be

Postby rasikrodri » Fri Dec 16, 2011 6:38 pm

I think the order of the matrix we are using is wrong. If I rotate the x axix in Animation Master when I export the file and open it in luxrender another axis is rotated(the one that rolls the camera, which in Luxrender is Y)

I also think I need, some how, rotate the camera 180 degrees so it looks back because in AM the camera if rotation is set to 0 then the camera looks front.
rasikrodri
 
Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

Re: Problems positioning camera with exporter, utnits may be

Postby Lord Crc » Fri Dec 16, 2011 7:08 pm

If you move/translate the camera along the three axis, is there a difference as well? If so, which axis to which? Ie if you move camera and camera target along the x axis, what happens in lux? And for the other axes as well.

edit: If you have time, I'll be on IRC around noon and midnight GMT tomorrow. Might be faster to get this sorted :)
May contain traces of nuts.
User avatar
Lord Crc
Developer
 
Posts: 4447
Joined: Sat Nov 17, 2007 2:10 pm

Re: Problems positioning camera with exporter, utnits may be

Postby rasikrodri » Fri Dec 16, 2011 10:01 pm

OK, I started with the rotation:
I set the translation and Rotation of the camera in Animation Master to 0, and started with the rotation parameters, one at a time:

Rotation
X value is actually correct, except that the camera in Luxrender, aparently, by default(0,0,0), starts looking up with the top of the camera towards the front view. In Animation Master the camera, by default(0,0,0), looks to the front view and it's top towards the top view.

I also found the y from Animation Master rotates z in Luxrender, and viseversa, as the documentation of Luxrender says, I will need to swap the y and z, because in Animation Master y is up/down, and z is back/forward.

As for tgranslation:
X appears to move rigth.
But y and z again will have to be swaped, pluss the y multiplied by -1.

I think I got it wrigth, but how to do that with the matrix? is the problem now
rasikrodri
 
Posts: 24
Joined: Sat Apr 10, 2010 1:26 pm

PreviousNext

Return to General

Who is online

Users browsing this forum: No registered users and 0 guests