Jump to content


Photo

Use Maxscript To Import Models


  • Please log in to reply
No replies to this topic

#1 X360_Guy

X360_Guy

    X-S Enthusiast

  • Members
  • 4 posts

Posted 28 December 2010 - 04:29 AM

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







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users