Blender's polygons in wrong order
I made a custom 3D object exporter for Blender to use with my little demo. the plug in half ass works. The polygons are all messed up. The vertex information is wrote correctly, but the polygon indices are not because D3DPT_TRIANGLESTRIP gives me a really crappy looking DrawIndexedPrimitive() result. Now it pretty obvious what's going on here, the indices are not in the correct order for the rendering process. So, I ask you! Do any of you know how to detect the order of indices in Blender so that I may change them while modeling. This will only save me from a few problems though. How do I write triangles that are not in a list or strip with indexed primitives in Direct3D?
Take back the internet with the most awsome browser around, FireFox
No takers? Oh well, I figured it out any ways. Hey, if any of you need help with Python extensions or writing Blender scripts, drop me a line. Or maybe I should write a tutorial.
Take back the internet with the most awsome browser around, FireFox
I assume this is left handed vs right handed issue.
Usually in D3D, people use LHS but probably Blender is RHS.
Usually in D3D, people use LHS but probably Blender is RHS.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Well, actually I'm rendering it perfectly with D3DPT_TRIANGLELIST. I think one of the problems was the fact that the polygons were quads and not triangles. That fixed the model problem, but with out depth buffering I can see a few problems in the mesh. Maybe I should just switch to drawing triangles, if Direct3D doesn't suppor it, I can just ditch Direct3D and switch to OpenGL which I know does support that kind of operation. Anyby drawing triangles, I mean traingle by triangle not list, fans or strips, but one by one as a batch.
But any ways, I still have a problem. The model's UV(texture) coordinates are not exporting properly. Either that, or I just don't know how to texture in Blender. My model's texture is all chopped up over the mesh. I write the UVs using the.....screw it! I'll just show you the source to the script
But any ways, I still have a problem. The model's UV(texture) coordinates are not exporting properly. Either that, or I just don't know how to texture in Blender. My model's texture is all chopped up over the mesh. I write the UVs using the.....screw it! I'll just show you the source to the script
#!BPY# """# Name: 'MOD File Format (.MOD)'# Blender: 232# Group: 'Export'# Tooltip: 'Export custom MOD format by Matthew R. Erdman'# """___author___ = "Matthew R. Erdman"___version___ = "1.0"import Blender, mod_meshtoolsimport structMODSig = 0x4D4F4421Ldef write( FileName ): File = open( FileName, "wb" ) # Initialize Blender interfaces ObjSel = Blender.Object.GetSelected( ) ObjNam = ObjSel[ 0 ].name MshNam = ObjSel[ 0 ].data.name Mesh = Blender.NMesh.GetRaw( MshNam ) Obj = Blender.Object.Get( ObjNam ) # Retrieve object inforamtion NumVerts = long( len( Mesh.verts ) ) OffVerts = 0L NumFaces = long( len( Mesh.faces ) ) OffFaces = 0L Color = 0xFFFFFFFFL TexCoords = [ ] for I in range( 0, NumFaces ): TexCoords.append( Mesh.faces.uv[ <span class=cpp-number>0</span> ] )<br> TexCoords.append( Mesh.faces.uv[ <span class=cpp-number>0</span> ] )<br> TexCoords.append( Mesh.faces.uv[ <span class=cpp-number>0</span> ] )<br><br> File.write( <span class=cpp-keyword>struct</span>.pack( <span class=cpp-literal>"LLLLL"</span>, MODSig, NumVerts, OffVerts, NumFaces, OffFaces ) )<br><br> # Write vertex information<br> OffVerts = File.tell( )<br> <span class=cpp-keyword>for</span> I in range( <span class=cpp-number>0</span>, NumVerts ):<br> File.write( <span class=cpp-keyword>struct</span>.pack( <span class=cpp-literal>"fffLff"</span>, Mesh.verts.co.x,<br> Mesh.verts.co.y,<br> Mesh.verts.co.z,<br> Color,<br> TexCoords[ <span class=cpp-number>0</span> ],<br> TexCoords[ <span class=cpp-number>1</span> ] ) )<br><br> # Write polygon information<br> OffFaces = File.tell( )<br> <span class=cpp-keyword>for</span> I in range( <span class=cpp-number>0</span>, NumFaces ):<br> File.write( <span class=cpp-keyword>struct</span>.pack( <span class=cpp-literal>"HHH"</span>, Mesh.faces.v[ <span class=cpp-number>0</span> ].index,<br> Mesh.faces.v[ <span class=cpp-number>1</span> ].index,<br> Mesh.faces.v[ <span class=cpp-number>2</span> ].index ) )<br><br> # Write the header<br> File.seek( <span class=cpp-number>0</span> )<br> File.write( <span class=cpp-keyword>struct</span>.pack( <span class=cpp-literal>"LLLLL"</span>, MODSig, NumVerts, OffVerts, NumFaces, OffFaces ) )<br> File.close( )<br><br>def fs_callback( FileName ):<br> <span class=cpp-keyword>if</span> FileName.find( '.mod', -<span class=cpp-number>4</span> ) <= <span class=cpp-number>0</span>: FileName += '.mod'<br> write( FileName )<br><br>Blender.Window.FileSelector( fs_callback, <span class=cpp-literal>"Export Mod"</span> )<br><br></pre></div><!–ENDSCRIPT–><br><br>I've tried subtracting the V coordinate from 1, because I though the OpenGL might be causing the problem do to the fact of different UV system. But that didn't help either.<br><br>NOTE: The Mesh.verts has UV coordinates, but their "sticky". I tried exporting them and I got nothing. Except the color of the model was tinted the texture color.
Take back the internet with the most awsome browser around, FireFox
I don't know Blender script, but this part looks suspicious
for I in range( 0, NumFaces ):
TexCoords.append( Mesh.faces.uv[ 0 ] )<br> TexCoords.append( Mesh.faces.uv[ 0 ] )<br> TexCoords.append( Mesh.faces.uv[ 0 ] )<br><br>D3D doesn't support quads, so you can reprocess those into tris.<br>
for I in range( 0, NumFaces ):
TexCoords.append( Mesh.faces.uv[ 0 ] )<br> TexCoords.append( Mesh.faces.uv[ 0 ] )<br> TexCoords.append( Mesh.faces.uv[ 0 ] )<br><br>D3D doesn't support quads, so you can reprocess those into tris.<br>
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Well V-Man, if you read my other post then you would have known that I did change that.
I go the polygons to render, but I have to use a depth buffer or I will see through them. Also, the texture coordinates are all messed up. Like I said, the texture i all chopped up over the model. I got parts of the texture zig zagging all over.
I go the polygons to render, but I have to use a depth buffer or I will see through them. Also, the texture coordinates are all messed up. Like I said, the texture i all chopped up over the model. I got parts of the texture zig zagging all over.
Take back the internet with the most awsome browser around, FireFox
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement