chrrox

Member
  • Content count

    3
  • Joined

  • Last visited

Community Reputation

105 Neutral

About chrrox

  • Rank
    Newbie
  1. sorry the problem was an error in my reading of triangle strips the script works fine now.
  2. Hello everyone I am trying to import a mesh format into maya and I can get the geometry to import fine but I can not figure out how uv's work correctly to save my life. any help is great [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Here is my current script I can send a sample file if needed to see what I am doing wrong. [CODE] # Maya Python script import maya.cmds as cmds import maya.OpenMaya as om import struct def get_mobject(node): selectionList = om.MSelectionList() selectionList.add(node) oNode = om.MObject() selectionList.getDependNode(0, oNode) return oNode fname = cmds.fileDialog2(fm=1, ff='Music Girl:Hatsune Miku .mdl (*.mdl);;All Files (*.*)')[0] f = open(fname, "rb") magic = struct.unpack("4s",f.read(4))[0] header = struct.unpack("4i",f.read(16)) f.seek(0x60, 0) vertInfo = [] for i in range(0 ,header[3]): meshInfo = struct.unpack("4i",f.read(0x10)) meshMatrix = struct.unpack("12f",f.read(0x30)) meshInfo2 = struct.unpack("4i",f.read(0x10)) vertInfo.append([meshInfo,meshMatrix,meshInfo2]) print(f.tell()) boneInfo = struct.unpack("4i",f.read(0x10)) texInfo = struct.unpack("4i",f.read(0x10)) matInfo = struct.unpack("4i",f.read(0x10)) vertOff = struct.unpack(str(header[3]) + "i",f.read(header[3] * 4)) faceOff = struct.unpack(str(header[3]) + "i",f.read(header[3] * 4)) weightOff = struct.unpack(str(header[3]) + "i",f.read(header[3] * 4)) for i in range(0 ,header[3]): vertexArray = om.MFloatPointArray() normalArray = om.MFloatPointArray() uArray = om.MFloatArray() vArray = om.MFloatArray() uvCounts = om.MIntArray() uvIds = om.MIntArray() f.seek(vertOff[i], 0) for a in range(0 ,vertInfo[i][0][1]): verts = struct.unpack("8f",f.read(32)) pt = om.MFloatPoint(verts[0],verts[1], verts[2]) vertexArray.append(pt) uArray.append(verts[6]) vArray.append((verts[7] * -1) + 1) f.seek(faceOff[i], 0) pConnects = om.MIntArray() pCounts = om.MIntArray() for a in range(0 ,vertInfo[i][0][0]): faceCount = struct.unpack("H",f.read(2))[0] matID = struct.unpack("H",f.read(2))[0] fstart = f.tell() StartDirection = -1 f1 = struct.unpack("H",f.read(2))[0] f2 = struct.unpack("H",f.read(2))[0] FaceDirection = StartDirection while f.tell() < (fstart + (2 *faceCount )): f3 = struct.unpack("H",f.read(2))[0] if f3 == 0xFFFF: f1 = struct.unpack("H",f.read(2))[0] f2 = struct.unpack("H",f.read(2))[0] FaceDirection = StartDirection else: FaceDirection *= -1 if (f1 != f2 and f1 != f3 and f3 != f2) : if FaceDirection > 0: pConnects.append(f1) pConnects.append(f2) pConnects.append(f3) else: pConnects.append(f1) pConnects.append(f3) pConnects.append(f2) pCounts.append(3) f1 = f2 f2 = f3 f.seek(weightOff[i], 0) uvCounts = pCounts mesh = om.MFnMesh() ShapeMesh = cmds.group(em=True) # <-- we create an empty group/ trnasform node that will receive the mesh node as a sibling parentOwner = get_mobject( ShapeMesh ) meshMObj = mesh.create(vertInfo[i][0][1], len(pCounts), vertexArray, pCounts, pConnects, uArray, vArray ,parentOwner ) #<-- don't forget to add a parent owner cmds.sets( 'null' + str(i + 1), e=True,forceElement='initialShadingGroup') # <--assign the defaut lambert shader defaultUVSetName = '"hello"' mesh.setUVs( uArray, vArray, defaultUVSetName ) #for a in range(0 ,mesh.numPolygons()): # for point in range(0 ,3): # mesh.assignUV(a, point, pConnects[a*3+point] ) mesh.assignUVs(pCounts,pConnects, defaultUVSetName) f.close() [/CODE]
  3. this is kind of an old topic but i made a tool to convert direct x compressed files to .cab files if anyone is interested. http://forum.xentax.com/viewtopic.php?f=21&t=9064