Blender export problem

Started by
6 comments, last by Daaark 11 years, 4 months ago
Okay.

DirectX and Blender don´t share the same coordinate system.
I used to fix this by importing my models like this.
Also the UV system isnt the same. but i used to fix my models like this:

[source lang="cpp"]for(int i=0;i<m_vertexCount;i++) {
model_vertices.Color = color;
model_vertices.Normal.x = Level1Vertices.Normal.x;
model_vertices.Normal.y = Level1Vertices.Normal.y;
model_vertices.Normal.z = Level1Vertices.Normal.z;
model_vertices.U = Level1Vertices.U;
model_vertices.V = Level1Vertices.V;
//THIS IS WHERE I DO MY FIX
model_vertices.X = position.x + Level1Vertices.X;
model_vertices.Y = position.y + Level1Vertices.Z;
model_vertices.Z = position.z + -Level1Vertices.Y;
}[/source]

Suddenly now my models are mirrored left to right. *sight*...
It feels like the export from blender is Random, It gets right 1 time of 10. Pretty frustrating not to be able to rely on the export.
This trouble takes to much time from my development.


Any ideas?
Advertisement
There is an XNA option for the .x export. Take a look at the corresponding python script to see how they are handling everything.

In Blender:

X is length
Y is depth
Z is height
I still dont understand.
The modls are correct just they are mirrored.

I use Ctrl-N to make the normal look good. And if i "Flip Direction".
The model is correct in my game but the normals are upside down.

Why cant blender just implement a way to change coordsystem to right-handed... =(

Why cant blender just implement a way to change coordsystem to right-handed... =(

Because it is not the task of the modelling tool but the exporter.


model_vertices.Normal.x = Level1Vertices.Normal.x;
model_vertices.Normal.y = Level1Vertices.Normal.y;
model_vertices.Normal.z = Level1Vertices.Normal.z;

You need to flip the normals too, much like the position, experiment with this:

model_vertices.Normal.x = Level1Vertices.Normal.x;
model_vertices.Normal.y = Level1Vertices.Normal.z;
model_vertices.Normal.z = -Level1Vertices.Normal.y;
Late answer but, is the normal connected to the draw pipeline?

How can the normals affect the rendering? isnt my triangles drawned just by x,y,z positions?

I am about to give up my development as Blender exporting just is to buggy right now. It seems that my walls are rendered with normals all over the place. I will definetly try to change the normal as you suggested.

thank you for your answer.
A normal is the direction that the vertex is pointing. It's very important for knowing if a triangle is even facing the camera or not, and important for culling. It's also important for lighting so the light knows if the triangle is even facing it.

You have to make sure that your normal is facing the correct direction in Blender. Press the N key in the 3D viewport while in edit mode and check off the option that lets you see what direction the normal is pointing. Blender will do this by drawing a line out from the polygons. Make sure it;s in the right direction. If not, you can flip it.

You can also change the rendering mode (button at the bottom of the viewport window with the sphere) to textured. You will easily be able to see which faces are pointing the wrong way, because they will be culled.
What is the right direction? when i flip all the normal is pointing inside and it don´t feel correct. The Texture mode was great, now i see my misstakes before i import model and saves me time.

But my model is rendered mirrored. If i use Ctrl-N and do this for both normal and vertecies it shows correct just that it is mirrored.


[source lang="cpp"]for(int i=0;i<m_vertexCount;i++) {
model_vertices.Color = color;
model_vertices.Normal.x = Level1Vertices.Normal.x;
model_vertices.Normal.y = Level1Vertices.Normal.z;
model_vertices.Normal.z = -Level1Vertices.Normal.y;
model_vertices.U = Level1Vertices.U;
model_vertices.V = Level1Vertices.V;
model_vertices.X = position.x + Level1Vertices.X;
model_vertices.Y = position.y + Level1Vertices.Z;
model_vertices.Z = position.z + -Level1Vertices.Y;
}[/source]

i sometimes solve the mirror thing by flip the normals but then it don´t get rendered correctly with my walls, the normals are not right...

How can i upload images to show you my model with normals?
The correct direction for normals to face is up to you, and depends on what the models are. The normal should face the camera.

If you make a big box and you want it to represent the inside of a room, then you want to have the normals facing inside.
If you make a box and you want it to be a crate or something, the normals need to face on the outside.

If you go inside the model, the normals need to point inside. If you see the model from the outside, they point outside.

Press Print Screen, past your image in an image editor and save a jpg, then upload your image to image shack, dropbox, or photobucket, or somewhere similar. Then post the link.

This topic is closed to new replies.

Advertisement