Sign in to follow this  
Kurt-olsson

Blender export problem

Recommended Posts

Kurt-olsson    254
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[i].Color = color;
model_vertices[i].Normal.x = Level1Vertices[i].Normal.x;
model_vertices[i].Normal.y = Level1Vertices[i].Normal.y;
model_vertices[i].Normal.z = Level1Vertices[i].Normal.z;
model_vertices[i].U = Level1Vertices[i].U;
model_vertices[i].V = Level1Vertices[i].V;
//THIS IS WHERE I DO MY FIX
model_vertices[i].X = position.x + Level1Vertices[i].X;
model_vertices[i].Y = position.y + Level1Vertices[i].Z;
model_vertices[i].Z = position.z + -Level1Vertices[i].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? Edited by KurtO

Share this post


Link to post
Share on other sites
Daaark    3553
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

Share this post


Link to post
Share on other sites
Kurt-olsson    254
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... =(

Share this post


Link to post
Share on other sites
Ashaman73    13715
[quote name='KurtO' timestamp='1353328329' post='5002323']
Why cant blender just implement a way to change coordsystem to right-handed... =(
[/quote]
Because it is not the task of the modelling tool but the exporter.

[quote name='KurtO' timestamp='1353228260' post='5001985']
model_vertices[i].Normal.x = Level1Vertices[i].Normal.x;
model_vertices[i].Normal.y = Level1Vertices[i].Normal.y;
model_vertices[i].Normal.z = Level1Vertices[i].Normal.z;
[/quote]
You need to flip the normals too, much like the position, experiment with this:
[quote name='KurtO' timestamp='1353228260' post='5001985']
model_vertices[i].Normal.x = Level1Vertices[i].Normal.x;
model_vertices[i].Normal.y = Level1Vertices[i].Normal.z;
model_vertices[i].Normal.z = -Level1Vertices[i].Normal.y;
[/quote]

Share this post


Link to post
Share on other sites
Kurt-olsson    254
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. Edited by KurtO

Share this post


Link to post
Share on other sites
Daaark    3553
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.

Share this post


Link to post
Share on other sites
Kurt-olsson    254
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[i].Color = color;
model_vertices[i].Normal.x = Level1Vertices[i].Normal.x;
model_vertices[i].Normal.y = Level1Vertices[i].Normal.z;
model_vertices[i].Normal.z = -Level1Vertices[i].Normal.y;
model_vertices[i].U = Level1Vertices[i].U;
model_vertices[i].V = Level1Vertices[i].V;
model_vertices[i].X = position.x + Level1Vertices[i].X;
model_vertices[i].Y = position.y + Level1Vertices[i].Z;
model_vertices[i].Z = position.z + -Level1Vertices[i].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? Edited by KurtO

Share this post


Link to post
Share on other sites
Daaark    3553
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this