Getting World Matrix (Mesh Space)

Started by
9 comments, last by Norman Barrows 9 years, 3 months ago

Hello,

I loaded .obj file model for rendering in DX11, then I read vertices, UV, normal, etc.. from the file.

Sometimes, the mesh position in the 3D modeling software is not 0.0f, 0.0f, 0.0f

How do I get the the world matrix of the mesh based on the mesh space?

Advertisement
The vertices are already transformed inside the file. There is no matrix information to be gotten.
This is one reason why, when people ask, “How do I load/convert .OBJ files?”, the answer is, “Slam your head into a wall until you forget what .OBJ files are, then convert/load .DAE or .FBX.”


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

How do I get the the world matrix of the mesh based on the mesh space?

The vertex positions are given w.r.t. a reference space. This space is conventionally called the model space. Recomputing the vertex positions w.r.t. another space requires the existence of a model-to-other space transform. This transform must be explicit. It cannot be implicitly given by the vertexes themselves.

The only thing you can do is to estimate another origin by computing the center of all vertex positions (or something similar). This works for symmetric geometry reasonably well. Otherwise you need to handcraft the transform and add / apply it during import.

EDIT: L. Spiro's practical tipps ;D

Slam your head into a wall until you forget what OBJ files are


loaded .obj file model for rendering in DX11, then I read vertices, UV, normal, etc.. from the file.

Sometimes, the mesh position in the 3D modeling software is not 0.0f, 0.0f, 0.0f

load it into the modeler, center it, save it. job done. get a beer! <g>.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


loaded .obj file model for rendering in DX11, then I read vertices, UV, normal, etc.. from the file.

Sometimes, the mesh position in the 3D modeling software is not 0.0f, 0.0f, 0.0f

load it into the modeler, center it, save it. job done. get a beer! <g>.

you forgot: ...and then export it in a sane format that can be sensibly loaded.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


loaded .obj file model for rendering in DX11, then I read vertices, UV, normal, etc.. from the file.

Sometimes, the mesh position in the 3D modeling software is not 0.0f, 0.0f, 0.0f

load it into the modeler, center it, save it. job done. get a beer! <g>.

The problem is that sometimes I will have a model with multiple meshes in the same file.

So lets say I have a tank model, there must be parts of the tank that will not be centered to 0.0f, 0.0f, 0.0f such as the tank gun


The problem is that sometimes I will have a model with multiple meshes in the same file.

It appears you want to model a hierarchical object - e.g., you want to orient a tank turret which moves with but rotates separately from the tank body itself. If so, reread the responses you've gotten very carefully - in particular, L. Spiro's post (#2). The message is: choose another file format.

Take a look at the OBJ file format. In particular, note "Obj files also do not support mesh hierarchies or any kind of animation or deformation."

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


loaded .obj file model for rendering in DX11, then I read vertices, UV, normal, etc.. from the file.

Sometimes, the mesh position in the 3D modeling software is not 0.0f, 0.0f, 0.0f

load it into the modeler, center it, save it. job done. get a beer! <g>.

you forgot: ...and then export it in a sane format that can be sensibly loaded.

Is there such a thing as a sane format? I've written a FBX/DAE importer/exporter and they have plenty of madness within themselves.

Perception is when one imagination clashes with another
You could use any format you like, if you can retrieve the subobjects somehow. Then you can construct the matrices that transform the subobjects to the parent.

I know there's no more development going one with he X file format, never the less in my case it does everything I need (including materials, multi texturing, tangents, hierarchy etc). And it's relatively easy to read/ interpret.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me


you forgot: ...and then export it in a sane format that can be sensibly loaded.

good point. i'm using .x and lucked out and found copies of both truespace 6 and rosetta, so i can import just about anything and export it directly to .x used by the game.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement