Motion Blur Implementation
Motion Blur Implementation
How about some info on implementing motion blur? I thought I read that Ono emailed some stuff to fused. Can someone please explain the XML tags related to motion blur?
Re: Motion Blur Implementation
Check out motion_blur_test.igs and camera_motion_blur_test.igs from the testscenes dir in Indigo 2.0.4.
Re: Motion Blur Implementation
Ono,
is the intent of the rotation quaternion element to represent the current orientation or the change in orientation from the previous keyframe? It seems to represent a change...
is the intent of the rotation quaternion element to represent the current orientation or the change in orientation from the previous keyframe? It seems to represent a change...
Re: Motion Blur Implementation
It describes a rotation transformation, applied after any <rotation> element transformation if present.
So it's not relative to the last keyframe.
So it's not relative to the last keyframe.
Re: Motion Blur Implementation
so what if you don't have a <rotation> element present?OnoSendai wrote:It describes a rotation transformation, applied after any <rotation> element transformation if present.
So it's not relative to the last keyframe.
Re: Motion Blur Implementation
OK. Could someone just spell it out for me?
I would like to see actual code that does the following:
Given vectors for the x,y,z axes of a model, convert to the type of quaternion that is accepted by Indigo. I know I am on the right track but I need a bit of help here.
![Smile :)](./images/smilies/icon_smile.gif)
Given vectors for the x,y,z axes of a model, convert to the type of quaternion that is accepted by Indigo. I know I am on the right track but I need a bit of help here.
Re: Motion Blur Implementation
I'll ask Nick tomorrow and get back to you.
Re: Motion Blur Implementation
Dont be confused by the word "quaternion", it just expects simple axis rotation that is internally converted to a quaternion. i implemented 3 different ways to convert it and never got correct results, then asked nick and he told me that.Whaat wrote:OK. Could someone just spell it out for me?I would like to see actual code that does the following:
Given vectors for the x,y,z axes of a model, convert to the type of quaternion that is accepted by Indigo. I know I am on the right track but I need a bit of help here.
i think the easiest is that the <rotation> just carries an identity matrix (maybe with scale) when using motion blur.
heres some of my (experimental) motion blur code:
Code: Select all
[...bleh...]
//SCALE
SceneExportRealValue("scale", 1.0, model);
//MESH_NAME
SceneExportStringValue("mesh_name", meshname.GetFileString(), model);
//Motion blur
Real strength = 1.0;
LONG num_keyframes_inbetween = 0;
if (ObjectHasMotionBlurTag(obj, strength, num_keyframes_inbetween)) {
//experimental mb stuff
SceneExportMoBlurMatrix(model, m); //exports the identity matrix with applied scale
LONG fps = mDoc->GetFps();
BaseTime time = BaseTime(m_frame, fps);
//get topmost object with animation, neccecary so all childs will be correctly animated
//if found, animate
BaseObject *topmost = GetTopmostAnimated(obj);
if (topmost) mDoc->AnimateObject(topmost, time, ANIMATE_QUICK);
Real rotation;
Vector axis;
Vector position;
position = obj->GetMg().off;
MatrixToRotAxis(obj->GetMg(), &axis, &rotation);
SceneExportKeyframe(0.0, model, rotation, axis, position); //exports the first keyframe
//some stuff to get along with c4d animation stuff. only whole keyframes can be
//exported for now - getting values inbetween is a bit tricky
Real m_exposure = 0.3333333;
Real newFrame = (Real)m_frame + (fps * m_exposure);
Real step = 1 / Floor((fps * m_exposure) + 0.5);
//export all other keyframes
for (int i = m_frame+1; i < newFrame-0.5; i++)
{
time = BaseTime(i, mDoc->GetFps());
topmost = GetTopmostAnimated(obj);
if (topmost) mDoc->AnimateObject(topmost, time, ANIMATE_QUICK);
position = obj->GetMg().off;
MatrixToRotAxis(obj->GetMg(), &axis, &rotation);
SceneExportKeyframe(step*i, model, rotation, axis, position);
}
time = BaseTime(newFrame, mDoc->GetFps());
topmost = GetTopmostAnimated(obj);
if (topmost) mDoc->AnimateObject(topmost, time, ANIMATE_QUICK);
position = obj->GetMg().off;
MatrixToRotAxis(obj->GetMg(), &axis, &rotation);
SceneExportKeyframe(1.0, model, rotation, axis, position);
} else { //if no motion blur, normal rotation
//POS/ROTATION/SCALE
SceneExportPosAndMatrix(model, m);
}
![Smile :)](./images/smilies/icon_smile.gif)
Re: Motion Blur Implementation
I think the part I am interested in the most is this:
Do you mind exposing this method?
Or is part of the API?
Code: Select all
MatrixToRotAxis(obj->GetMg(), &axis, &rotation);
![Smile :)](./images/smilies/icon_smile.gif)
Re: Motion Blur Implementation
Its part of the API, but no problem ![Smile :)](./images/smilies/icon_smile.gif)
you can clearly see that maxons coders dont give a damn about writing english comments ![Wink ;)](./images/smilies/icon_wink.gif)
probably copyrighted by maxon or so, so make sure you dont copy that 1:1. be inspired![Razz :P](./images/smilies/icon_razz.gif)
added some translation for you...
![Smile :)](./images/smilies/icon_smile.gif)
Code: Select all
void MatrixToRotAxis(const Matrix &mm, Vector *v, Real *w)
{
Matrix m = mm;
// MatrixVectoren MUESSEN normiert sein!!! ---vec's must be normalized
m.v1=!m.v1;
m.v2=!m.v2;
m.v3=!m.v3;
// Winkel berechnen ---calculate angles
*w = ACos((m.v1.x+m.v2.y+m.v3.z-1.0)/2.0);
// Achse berechnen ---calc axis
v->x= m.v2.z-m.v3.y;
v->y= m.v3.x-m.v1.z;
v->z= m.v1.y-m.v2.x;
*v = !(*v);
if (*v==0.0)
{
*v = Vector(0.0,1.0,0.0);
*w = 0.0;
}
}
![Wink ;)](./images/smilies/icon_wink.gif)
probably copyrighted by maxon or so, so make sure you dont copy that 1:1. be inspired
![Razz :P](./images/smilies/icon_razz.gif)
added some translation for you...
Who is online
Users browsing this forum: No registered users and 18 guests