PDA

View Full Version : 3D Studio file madness!

Peter Svensson
11-28-2000, 01:15 PM
Hello!

I need some help with loading a .3ds file. The problem is when i load the object i want it to be centered around origo even if it wasn't that in the scene. I have found a transformation matrix (chunk 4160) that i think can be used to do the job, but i have no clue how to use it... Does anyone have a clue?

// Peter - Thanx!

Michael Steinberg
11-29-2000, 08:43 AM
I really don't know, but I could guess that you'll have to inverse that matrix (1/ for every component that is multiplied) and the multiplicate it with the vertices.
But I'm totally unsure about that.

11-29-2000, 09:47 AM
What I do is just transform the vertexes on
their own without looking at extra data. This
is very easy; just calculate the "center
weight" for your vertexes with the weighting
function of your choice, and then translate
with the negative of that result.

(1, 4, 4) and (9, 6, 8)

the linear center weight would be
(5, 5, 6)

Thus, you translate all your vertexes by
(-5, -5, -6) to end up with

(-4, -1, -2) (4, 1, 2)

If you have some specific constraints (such
as the bottom-most vertex always needs to be
at Z 0) you can easily add that to your
weighting function.

This works fine, because all the other data
(texture U/V, normals, etc) is location-
independent.

Btw: I also inspect the mesh data to
calculate normals, because I haven't found a
description of the format which includes
normal information. My current method
calculates the normal of each triangle, and
then averages/normalizes them for all the
triangles connecting each vertex.

Michael Steinberg
11-29-2000, 11:25 AM
But it isn't guaranteed that the weight off all objects' vertices is really the center of it.

11-29-2000, 01:38 PM
Umm... there is no single "center" of an
object. It all depends on what you want the
"center" to be, and thus how you choose
your weighting function will of course be
dependent on how you define "center".

Or does 3dsMax have some "center" definition
for its models? I don't own it, and have
only seen it used briefly, and I didn't
notice any "center" moniker or gizmo...

Olive
11-29-2000, 11:24 PM
Working with object centers (what is refered to as pivot points in Max) in a .3ds file is a headache ! We've developped a .3ds loader for our engine with the 3DSFTK library found (but not sure it's still there) at the Autodesk FTP site. There isn't in the format description a clear explanation of how the object pivot position, local matrix and keyframe position/orientations really mix together to get the correct object frame.
First of all, I think you should define what you mean by "the center of an object". If its just, as it was mentioned, the barycenter of the object then, fine. But if its the pivot point defined in MAX, well, good luck! If you succeed in finding a method for computing the correct object frame that works for any model, I'd love to know.

Olive
11-29-2000, 11:28 PM
Working with object centers (what is refered to as pivot points in Max) in a .3ds file is a headache ! We've developped a .3ds loader for our engine with the 3DSFTK library found (but not sure it's still there) at the Autodesk FTP site. There isn't in the format description a clear explanation of how the object pivot position, local matrix and keyframe position/orientations really mix together to get the correct object frame.
First of all, I think you should define what you mean by "the center of an object". If its just, as it was mentioned, the barycenter of the object then, fine. But if its the pivot point defined in MAX, well, good luck! If you succeed in finding a method for computing the correct object frame that works for any model, I'd love to know.

Peter Svensson
11-30-2000, 06:36 AM