xboxscene.org forums

Author Topic: Use Maxscript To Import Models  (Read 144 times)

X360_Guy

  • Archived User
  • Newbie
  • *
  • Posts: 5
Use Maxscript To Import Models
« on: December 27, 2010, 08:29:00 PM »

thought I'd drop this here, during my free time off during the holidays I wanted to make a video guide on how to use MaxScript aka 3dsmax to import models.

these videos will show you some basics on using maxscript to import data from random binary files...

I'm fairly new to maxscript, or programing in general so please forgive me if I got a thing here or there wrong. tongue.gif



http://www.youtube.com/watch?v=CEwSgXxkZMc
http://www.youtube.com/watch?v=NeQYfxi8KW4

the PMD samples I got from the MikUMikuDance, some PMD were packed with the program.

http://www.geocities...uu4/index_e.htm

and here is the sample script I did in the video

CODE

f = fopen "E:\\Hacking Projects\\PMD\\MEIKO.pmd" "rb"
clearlistener()


fn ReadFixedString bstream fixedLen =
(
    local str = ""
    for i = 1 to fixedLen do
    (
        str0 = ReadByte bstream #unsigned
        if str0!=0xFD AND str0!=0xFC do str+= bit.intAsChar str0
    )
    str
)


Face_array=#()
Vert_array=#()
UV_array=#()


fileName =ReadFixedString f 3
fileVersion=readfloat f
modelName=ReadFixedString f 20
comments=ReadFixedString f 256


count=readlong f #unsigned


for x = 1 to count do(

vx=readfloat f
vy=readfloat f
vz=readfloat f
p4=readfloat f
p5=readfloat f
p6=readfloat f
tu=readfloat f
tv=readfloat f
p9=readshort f
p10=readshort f
p11=readshort f
append Vert_array[vx,vz,vy]
append UV_array[tu,tv,0]
)



count=readlong f #unsigned

print count


for x = 1 to count/3 do(
fa=readshort f #unsigned+1
fb=readshort f #unsigned+1
fc=readshort f #unsigned+1
append Face_array[fc,fb,fa]
)



msh = mesh vertices:Vert_array faces:Face_array
msh.numTVerts = UV_array.count
buildTVFaces msh
msh.name=modelName
-- convertTo msh PolyMeshObject
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]


Print ("Last Read @ 0x"+((bit.intAsHex(ftell f))as string))
gc()
fclose f


Logged