Notifications
Clear all

[Closed] Exported Normals Wierdness

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

But if I use the exported data, it looks like this

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

		format "TriangleIndices=
	\"" 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 "\" 
" to:outFile

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

		if (getNumTVerts tmesh) > 0 then (
			format "TextureCoordinates=
	\"" 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 "\" 
" to:outFile
		)
		
		format "/>

" to:outFile
		
		delete tmesh
	)

Any Ideas?