- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, first let me say thank you for such a state-of-the-art kernel for CPU, it is by far the best ever developed.
I'm trying to rotate an instance by setting the RTCMatrix parameter of rtcSetTransform but I can't seen to figure it out. I know it is an affine transformation matrix, but no matter what I do, it never rotate properly.
My question, is there an example available showing the members of the matrix used for rotation? I know you have a tutorial but it only set the matrix to the identity matrix and use the last members as a position change only, no rotation.
Thanks and I appreciate any info on this.
-Al
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you give some more details about the kind of rotation you want to have, or even better post your code around rtcSetTransform? Maybe the matrix layout (ROW_MAJOR vs. COLUMN_MAJOR) is wrong?
Thanks,
Carsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your reply.
I use the following...
http://upload.wikimedia.org/math/f/4/a/f4ad490993bbaa220e41f727f07a5bd0.png
and it doesn't matter if I use row or col major, it's not rotating on the correct axis and it's also sheering. I move the members of the matrix in different position and still can't get it to work. Trying a simple 45 degree rotate along the X axis using every combinations I can think off still does not result a proper rotation. If I play with the order of the matrix, I get scaling, sheering, rotation, or any combination of them, but I still can't find the proper way to do it.
Say for example, if I want to rotate it on the up/dn axis by 10 degrees and also scale it twice as large on all axis, how would the matrix be setup?
Also, the rotation seems to also happen not at the center of the BBox but at the position defined by the last 4 members of the matrix. Is that how it's suppose to do it? Move the instance to that position and then rotate it around it's original position?
I have no problem to use the rotation matrix in OpenGL, even use it for scaling, but in Embree I'm at a complete stop and lost.
Thanks for helping...
-Al
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi AI,
I've modified the 'device_render' function in tutorial04_device.cpp so that the spheres rotate around themselves and scale their size. The modified code looks like:
/* called by the C++ code to render */
extern "C" void device_render (int* pixels,
const int width,
const int height,
const float time,
const Vec3fa& vx,
const Vec3fa& vy,
const Vec3fa& vz,
const Vec3fa& p)
{
/* create identity matrix */
AffineSpace3f xfm;
xfm.l.vx = Vec3fa(1,0,0);
xfm.l.vy = Vec3fa(0,1,0);
xfm.l.vz = Vec3fa(0,0,1);
xfm.p = Vec3fa(0,0,0);
float t = 0.7f*time;
float t_rot = 0.9f*time;
// rotate each sphere around the y-axis
xfm.l.vx = Vec3fa(cos(t_rot),0,-sin(t_rot));
xfm.l.vy = Vec3fa(0,1,0);
xfm.l.vz = Vec3fa(sin(t_rot),0, cos(t_rot));
// apply some scaling to each sphere
float s = 1.0f + sin(t) * 0.5f;
AffineSpace3f scale;
scale.l.vx = Vec3fa(s,0,0);
scale.l.vy = Vec3fa(0,s,0);
scale.l.vz = Vec3fa(0,0,s);
scale.p = Vec3fa(0,0,0);
xfm *= scale;
/* move instances */
xfm.p = 2.0f*Vec3fa(+cos(t),0.0f,+sin(t));
rtcSetTransform(g_scene,g_instance0,RTC_MATRIX_COLUMN_MAJOR,(float*)&xfm);
xfm.p = 2.0f*Vec3fa(-cos(t),0.0f,-sin(t));
rtcSetTransform(g_scene,g_instance1,RTC_MATRIX_COLUMN_MAJOR,(float*)&xfm);
xfm.p = 2.0f*Vec3fa(-sin(t),0.0f,+cos(t));
rtcSetTransform(g_scene,g_instance2,RTC_MATRIX_COLUMN_MAJOR,(float*)&xfm);
xfm.p = 2.0f*Vec3fa(+sin(t),0.0f,-cos(t));
rtcSetTransform(g_scene,g_instance3,RTC_MATRIX_COLUMN_MAJOR,(float*)&xfm);
/* update scene */
rtcUpdate(g_scene,g_instance0);
rtcUpdate(g_scene,g_instance1);
rtcUpdate(g_scene,g_instance2);
rtcUpdate(g_scene,g_instance3);
rtcCommit (g_scene);
/* render all pixels */
const int numTilesX = (width +TILE_SIZE_X-1)/TILE_SIZE_X;
const int numTilesY = (height+TILE_SIZE_Y-1)/TILE_SIZE_Y;
launch_renderTile(numTilesX*numTilesY,pixels,width,height,time,vx,vy,vz,p,numTilesX,numTilesY);
rtcDebug();
}
Does this help you further?
Best regards,
Carsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
WOW! thank you very much! I didn't expect such an elaborate and detailed answer. Much appreciated.
My best to you and the team.
-Al
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One more thing, how is the position defined? is it relative to the master of the instance? So it seems if I set the position to zero and simply use an identity matrix for the rotation, it is at the same place as the master. But as soon as I use a rotation, it no longer stay at the same place even though the position is set to zero!!??
Thanks
-Al
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The transformation passed to rtcSetTransform
transforms from the local space of the instantiated scene, to world space. About your rotation/translation issue, could you post some example code?
Thanks,
Carsten
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using your tutorial #4 and all works perfectly now with positioning but I have one last question, what do I need to do in the shading code to shade rotated instances properly? They shade properly if not rotated, but not when rotated.
Thanks for your help.
-Al
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page