Jump to content
  • Advertisement
Sign in to follow this  

MaxScript Exporter and Unwrap UVW

This topic is 4292 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i'm trying to write an exporter for my engine and spent last two days learning MaxScript. Finally I managed to make it work... this is the model in Max: and this is a result in my engine: As you can se, it works good and i'm very satisfied, so i tryied to step up. Within Max (i'm using Max 8) i did a render to texture step and created an ambient occlusion map. Then applyed the Unwrap UVW modifier on the mesh (uv channel 1) and tryed to export. This is a screenshot of the model as it should be: and this is in my engine: It's totally messed up! These are the relevant parts of the script:

struct tVertex

struct tFace

struct tMesh
	Verts = #(),
	Faces = #(),

fn AddTriangle obj triindx self =(
   vertindices = getFace obj triindx
   UV1_indices = meshop.getmapface obj 1 triindx
   vertindices = #(vertindices.x as integer, vertindices.y as integer, vertindices.z as integer)
   UV1_indices = #(UV1_indices.x as integer, UV1_indices.y as integer, UV1_indices.z as integer)	

   matId = getfacematid obj triindx
   VList = #()
   for i=1 to 3 do
	pos = obj.verts[vertindices].pos
        uv1 = meshop.getmapvert obj 1 UV1_indices
	newVert = tVertex pos #(uv1.x, uv1.y) 
        append self.Verts newVert
	VList = self.Verts.count
   append self.Faces (tFace VList[1] VList[2] VList[3] matId )	

fn WriteToFile self oFile = 	(
   format "Faces: % - Vertices: %\n" self.Faces.count self.Verts.count to:oFile
   for v = 1 to self.Verts.count do
      format "[%, %, %] - " self.Verts[v].pos.x self.Verts[v].pos.y self.Verts[v].pos.z to:oFile
     format "[%, %]\n" self.Verts[v].uv1[1] self.Verts[v].uv1[2] to:oFile
  for f = 1 to self.Faces.count do
      self.Faces[f].v1 = self.Faces[f].v1 - 1
      self.Faces[f].v2 = self.Faces[f].v2 - 1
      self.Faces[f].v3 = self.Faces[f].v3 - 1
      self.Faces[f].matId = self.Faces[f].matId - 1
      format "[%, %, %] - [%]\n" self.Faces[f].v1 self.Faces[f].v2 self.Faces[f].v3 self.Faces[f].matId to:oFile

) -- end of tMesh struct

MeshList = #()

for o=0 to --every object in the scene
   obj = -- i-th object
   MeshList[o] = tMesh()

   for f = 1 to obj.numfaces do 
	MeshList[o].AddTriangle obj f MeshList[o]
   MeshList[o].WriteToFile MeshList[o] out_file

Any clues?

Share this post

Link to post
Share on other sites
It looks like the ambient occlusion map uses other UV coordinates than the one used for standard textures (which you exported). I guess you can either tell max to use standard UVs or export 2 UV sets.

[Edited by - therealremi on March 11, 2007 8:06:36 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!