Jump to content

3D World Studio - Static Meshes


Dirkie
 Share

Recommended Posts

Hi

 

I've recently purchased 3D World Studio and we're trying to build some concepts for a game. I'm however struggling to get the static meshes imported correctly from the .3dw file.

 

I'm using XNA in combination with the following content processor http://xna3dws.codeplex.com/ to import the content. But the meshes seem be all over the place but not where they should be. Can maybe explain to me how the tranformation matrix in 3D World Studio work? Is it using euler angles or are there any differences with XNA that anybody knows of?

 

The code I'm using to place the meshes are something like this:

 

Matrix worldMatrix = Matrix.Identity;

 

worldMatrix *= absoluteTransforms[MeshPart.ParentBone.Index];

worldMatrix *= scale;

worldMatrix *= Matrix.CreateFromYawPitchRoll(rotation.X, rotation.Y, rotation.Z);

worldMatrix *= Matrix.CreateTranslation(position);

 

Thanks!

Link to comment
Share on other sites

I doubt anyone here has any experience of this importer as it's been written for XNA. I have no idea what output this importer creates or how accurate it is. I'd suggest looking through the .3dw file format documentation for starters.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

I actually found a XNA thread associated with this that Josh was contributing to here

so maybe he knows more about this than I at first thought. Guess Josh might be able to shed some light on this! The last references and comments to this I was able to find was it was all working bar some issues with terrain. Does it not come with any example code ?

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

3D World Studio stores meshes with Euler rotations. You may need to flip a few signs to get the eulers to match the coordinate system in XNA. I think someone has already done a loader for XNA, though, so you might want to look at that.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Thanks alot guys, I finally got it working.

 

Both of your advice helped alot, I looked at the example code and found some sign swapping that I needed to do which got the models sitting in the correct places. The thing that took me the longest to figure out was that I had to discard the scaling from the absolute transform. So basically I had to decompose the absolute transform so that I can access the rotation and translation individually without the scaling. For some reason it seems that 3D World Studio ignores that scaling and it caused some of my meshes to be way bigger/smaller in XNA than what they were in 3D World Studio.

 

In the end my code was something like this:

 

 

Vector3 tempScale, tempTranslation;

Quaternion tempRotation;

 

foreach (ModelMesh mesh in worldStudioMesh)

{

absoluteTransforms[mesh.ParentBone.Index].Decompose(out tempScale, out tempRotation, out tempTranslation);

 

Matrix worldMatrix = Matrix.Identity * Matrix.CreateFromQuaternion(tempRotation) * Matrix.CreateTranslation(tempTranslation);

 

worldMatrix *= Matrix.CreateScale(scale);

worldMatrix *= Matrix.CreateFromYawPitchRoll(rotation.Y, rotation.X, -rotation.Z);

worldMatrix *= Matrix.CreateTranslation(position);

 

... set shader params and render

}

 

 

Thanks again

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...