PDA

View Full Version : Exported Normals Wierdness


Kickflipkid687
12-07-2011, 11:00 PM
So I found a script to export Geo from Max to Xaml to create a 3D Object.

This is all good and all, except the Normals come out odd in the end. I think someone else posted something similar/the same on here, but I cannot find it again.

If I Export as .Obj and drag/drop into WPF, it looks fine, like this (http://dl.dropbox.com/u/6895456/wpfTest.jpg)

But if I use the exported data, it looks like this (http://dl.dropbox.com/u/6895456/fail.jpg)


The code I'm using is the following:

fn ExportMesh msh outFile = (
print "fn ExportMesh"
tmesh = snapshotAsMesh msh

num_verts = tmesh.numverts
num_faces = tmesh.numfaces

--format "%,%\n" num_verts num_faces to:out_file
format "<MeshGeometry3D " to:outFile
print "Exporting:" + msh.name
format "x:Key = \"g%\"\n" (CleanString msh.name) to:outFile
format "Positions=\n\t \"" to:outFile
for v = 1 to num_verts do
(
vert = getVert tmesh v
format "%,%,% " vert.x vert.y vert.z to:outFile
)
format "\" \n" to:outFile

format "TriangleIndices=\n\t\"" to:outFile
for f = 1 to num_faces do
(
face = getFace tmesh f
format "%,%,% " ((face.x-1) as integer) ((face.y-1) as integer) ((face.z-1) as integer) to:outFile
)

format "\" \n" to:outFile

format "Normals=\n\t\"" to:outFile
for f = 1 to num_faces do
(
normal = getFaceNormal tmesh f
format "%,%,% " normal.x normal.y normal.z to:outFile
)

format "\" \n" to:outFile

if (getNumTVerts tmesh) > 0 then (
format "TextureCoordinates=\n\t\"" to:outFile
for f = 1 to num_verts do
(
UVW = getTVert tmesh f
format "% %" UVW.x UVW.y to:outFile
if f < num_verts then format ", " to:outFile
)
format "\" \n" to:outFile
)

format "/>\n\n" to:outFile

delete tmesh
)


Any Ideas?

CGTalk Moderation
12-07-2011, 11:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.