Important information: this site is currently scheduled to go offline indefinitely by end of the year.

MaxScript [Video Guide]

Post questions about game models here, or help out others!
mariokart64n
ultra-veteran
ultra-veteran
Posts: 586
Joined: Sun Jun 05, 2005 12:00 pm
Location: Ontario, Canada
Has thanked: 36 times
Been thanked: 243 times

MaxScript [Video Guide]

Post by mariokart64n »

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.

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

http://www.youtube.com/watch?v=1ORnfYnlXOw
http://www.youtube.com/watch?v=dbPLKe-yMmY
http://www.youtube.com/watch?v=CEwSgXxkZMc
http://www.youtube.com/watch?v=NeQYfxi8KW4
http://www.youtube.com/watch?v=rcPfA4ix6WM
http://www.youtube.com/watch?v=LPxlqN6OoI4
http://www.youtube.com/watch?v=1dAIMdb-xYQ

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

http://www.geocities.jp/higuchuu4/index_e.htm

and here is the sample script I did in the video

Code: Select all

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









Functions
functions are script operations that you can call at any time later in your script.

so say for example I want to spell hello world a few times, I would make a function that I could call later
example:
fn hw(
print "hello"
print "world"
)

I've now created a function, that can now be called by using the designator "hw".
so the advantage to this, is that instead of printing hellowworld over and over again when I need it. I can just type hw, and that earlier operation gets carried out
so in short a functions allow you to save space by being able to repeat an earlier defined operation.

below are some common functions I copied off of chrrox, which were handy to me. which also can be used to help you read different endians, such as reading from xbox360 game files

readBEshort, lets you read 2bytes in reversed order.. which is actually right to left.

Code: Select all

fn readBEshort fstream = (
short = readshort fstream #unsigned
short = bit.swapBytes short 1 2
return short
) 

readBElong, lets you read 4bytes in big endian, aka reversed order (which is actually right to left)

Code: Select all

fn readBElong fstream = (
long = readlong fstream
long = bit.swapBytes long 1 4
long = bit.swapBytes long 2 3
return long
)

readHalfFloat, aka 16bit floats. max doesnt have a default read function on its own. this is for little endian.
if you want to reverse the byte order for bing endian (xbox360) then change the hf= line. instead of readshort, replace with. readBEshot
but make sure the readBEshort function gets paste before this. otherwise how can you call something that doesnt exist yet.

Code: Select all

fn readHalfFloat fstream = (
    hf=readshort fstream #unsigned
    sign = bit.get hf 16
    exponent = (bit.shift (bit.and hf (bit.hexasint "7C00")) -10) as integer - 16
    fraction = bit.and hf (bit.hexasint "03FF")
    if sign==true then sign = 1 else sign = 0
    exponentF = exponent + 127
    outputAsFloat = bit.or (bit.or (bit.shift fraction 13) \
    (bit.shift exponentF 23)) (bit.shift sign 31)
    return bit.intasfloat outputasfloat*2
    )
for reading a 32bit float, only in reversed order.. same speel as before. you'll need for xbox360

Code: Select all

fn ReadBEfloat fstream = (
    fpt=readfloat fstream
    itger = bit.floatAsInt fpt
    hih = bit.intashex itger
    while hih.count < 8 do hih = "0" + hih
    shn = (substring hih 7 2) + \
    (substring hih 5 2) + \
    (substring hih 3 2) + \
    (substring hih 1 2)
    bit.intAsFloat (bit.hexasint shn)
    )
for reading text ONLY. its handy cause the default maxscript readstring doesnt normally let you set a character reading limit.

Code: Select all

fn ReadFixedString bstream fixedLen = (
    local str = ""
    for i = 1 to fixedLen do
    (
        str += bit.intAsChar (ReadByte bstream #unsigned)
    )
    str
)
Last edited by mariokart64n on Fri Dec 31, 2010 7:45 pm, edited 2 times in total.
Maxscript and other finished work I've done can be found on my DeviantArt account
SLIFallen
advanced
Posts: 67
Joined: Tue Sep 28, 2010 4:26 pm
Been thanked: 3 times

Re: MaxScript [Video Guide]

Post by SLIFallen »

Are you trying to get the capture data (from a kinect..being used in MikUMikuDance app) into max?!? That would be AWESOME. I just DL'ed MikUMikuDance (v4.03 english version, yay!) and apparently you can reapply bone settings to make other skeletal rigs work with that app. So, in a very roundabout (and decidedly NOT user friendly) way, you could get a character into MikUMikuDance and reorient the bone assignments, then use the kinect to get your mo-cap and then export that back into max to then reapply to that character. (I guess?)
FEATHER
advanced
Posts: 75
Joined: Sun Jun 13, 2010 6:47 am
Has thanked: 3 times
Been thanked: 4 times

Re: MaxScript [Video Guide]

Post by FEATHER »

Amazing video tutorial, i just finish to see it few minutes ago the tutorial isn't complete but i understand that, make this videos for us (the noobs) is a hard work, i will study the videos more carefully and post some noobs questiosn about it... thanks a lot Mario!!

Postdata to Mario: I LOL with the joke of file extension, hello kitty files !!!

Postdata to SLIFallen: Thanks for the "original idea" but the topic is not about Kinetic... Just use the converter of MMD animations to max, use google for find it

Postdata to some moderator: This need be in tutorial forum i don't Know why Mario put the topic here lol
SLIFallen
advanced
Posts: 67
Joined: Tue Sep 28, 2010 4:26 pm
Been thanked: 3 times

Re: MaxScript [Video Guide]

Post by SLIFallen »

FEATHER wrote:Postdata to SLIFallen: Thanks for the "original idea" but the topic is not about Kinetic... Just use the converter of MMD animations to max, use google for find it
Indeed. Thanks for clearing that up. Kinect is simply a new way to animate the MMD characters. As I said, a roundabout way (for now) to get Kinect capture data into max, but it's a start!

I dont see this converter you speak of. I think thats in fact, what mariocart64 is after: http://www.vocaforum.com/showthread.php?t=1644

???
User avatar
Rimbros
ultra-veteran
ultra-veteran
Posts: 495
Joined: Fri Jul 09, 2010 12:23 am
Has thanked: 41 times
Been thanked: 16 times

Re: MaxScript [Video Guide]

Post by Rimbros »

I have here $100dlls, i am greath fan of saint seiya series, i have 2 options pay you for a script to import the models with textures in max or donate to xentax or pay a external coder to make one scrypt, i really love this series and search this models by 4 years.

Tread with files format samples, fatduck tell me he not have pc just now but he advance on this investigation

viewtopic.php?f=16&t=5525
Renders Art by Rimbros
http://s303.photobucket.com/albums/nn12 ... E/Renders/

Personal Game repository samples, send PM
mariokart64n
ultra-veteran
ultra-veteran
Posts: 586
Joined: Sun Jun 05, 2005 12:00 pm
Location: Ontario, Canada
Has thanked: 36 times
Been thanked: 243 times

Re: MaxScript [Video Guide]

Post by mariokart64n »

i thought the files were encrypted?

if you need the models ASAP, just use 3dvia on the pcsx2 emu
Maxscript and other finished work I've done can be found on my DeviantArt account
Mr.Mouse
Site Admin
Posts: 4073
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 450 times
Been thanked: 682 times
Contact:

Re: MaxScript [Video Guide]

Post by Mr.Mouse »

He really is desperate for those models. Great job by the way mariokart64n!! Cool tut!
mariokart64n
ultra-veteran
ultra-veteran
Posts: 586
Joined: Sun Jun 05, 2005 12:00 pm
Location: Ontario, Canada
Has thanked: 36 times
Been thanked: 243 times

Re: MaxScript [Video Guide]

Post by mariokart64n »

I'm having a hard time uploading the 5th video, youtube keeps failing on it. I've tried a dozen different codecs, and I ony get shoty quality. hopefully I'll get it figured out soon and upload the rest of the videos.

the aim is to get more people involved with maxscript, besides chrrox and fact duck. who seem to use this as a primary model importing method. since maxscript is soo easy many n00bs should be able to pick this up.
Maxscript and other finished work I've done can be found on my DeviantArt account
jcarl904
n00b
Posts: 13
Joined: Mon Apr 12, 2010 4:08 pm
Has thanked: 5 times

Re: MaxScript [Video Guide]

Post by jcarl904 »

Hope you can get that last video uploaded and thank you again for sharing this with us.
User avatar
Rimbros
ultra-veteran
ultra-veteran
Posts: 495
Joined: Fri Jul 09, 2010 12:23 am
Has thanked: 41 times
Been thanked: 16 times

Re: MaxScript [Video Guide]

Post by Rimbros »

mariokart64n wrote:i thought the files were encrypted?

if you need the models ASAP, just use 3dvia on the pcsx2 emu
I try with 3d ripper but every time the models are flated because the coordenate z are mising, this its because the pcsx2 emulators use overlay system.
Renders Art by Rimbros
http://s303.photobucket.com/albums/nn12 ... E/Renders/

Personal Game repository samples, send PM
User avatar
Rimbros
ultra-veteran
ultra-veteran
Posts: 495
Joined: Fri Jul 09, 2010 12:23 am
Has thanked: 41 times
Been thanked: 16 times

Re: MaxScript [Video Guide]

Post by Rimbros »

Mr.Mouse wrote:He really is desperate for those models. Great job by the way mariokart64n!! Cool tut!
Yeaaaa i love this series :)
Renders Art by Rimbros
http://s303.photobucket.com/albums/nn12 ... E/Renders/

Personal Game repository samples, send PM
mariokart64n
ultra-veteran
ultra-veteran
Posts: 586
Joined: Sun Jun 05, 2005 12:00 pm
Location: Ontario, Canada
Has thanked: 36 times
Been thanked: 243 times

Re: MaxScript [Video Guide]

Post by mariokart64n »

people dont know the differece between no z axis, and just reallly flat. scale the Y axis by 20 000 000 x and the mesh should unfold. this only works with 3dvia.
Maxscript and other finished work I've done can be found on my DeviantArt account
User avatar
Rimbros
ultra-veteran
ultra-veteran
Posts: 495
Joined: Fri Jul 09, 2010 12:23 am
Has thanked: 41 times
Been thanked: 16 times

Re: MaxScript [Video Guide]

Post by Rimbros »

yes bro but scale vertex by vertex of this axis to make the model its a crazy work, can take a lots and lots of time. any idea? maybe something maxscript can combine 2 captures, or something filter to unpack the files from the post of the models unripeed.
Renders Art by Rimbros
http://s303.photobucket.com/albums/nn12 ... E/Renders/

Personal Game repository samples, send PM
mariokart64n
ultra-veteran
ultra-veteran
Posts: 586
Joined: Sun Jun 05, 2005 12:00 pm
Location: Ontario, Canada
Has thanked: 36 times
Been thanked: 243 times

Re: MaxScript [Video Guide]

Post by mariokart64n »

you've misunderstood what I meant, and I dont think clarification would even matter
Maxscript and other finished work I've done can be found on my DeviantArt account
User avatar
Rimbros
ultra-veteran
ultra-veteran
Posts: 495
Joined: Fri Jul 09, 2010 12:23 am
Has thanked: 41 times
Been thanked: 16 times

Re: MaxScript [Video Guide]

Post by Rimbros »

Yes, cause im new on this and you are expert, mesed up vertex from point 0 to 20 000 000 put all the X vertex in the same position i test in milkshape with other models cause 3DVIA cant capture the models only textures with this configuration

This its the configuration of the EMULATOR
Image

This its the captured data you can see the window to the right
Image

I use koichi senada plugin in max to load the 3dxml files generated by 3DVIA PRINT SCREEN
Image

3DVIA only capture texture files png, not capure vertex data, maybe the configuration of the emulator its wrong, i dont know, you are the expert, i come here xentax cause people tell me here the people its good and all can help to all.

Maybe this can be more ussefull for you
viewtopic.php?f=16&t=5525

Abouth this you tell clarification would even matter, you are expert now because in the past other give you clarification. yes yes yes im a noob and noobs are despreciable.

I try with your video but looks blur i cant read the lethers bro, can upload with more quality? thanks.
Renders Art by Rimbros
http://s303.photobucket.com/albums/nn12 ... E/Renders/

Personal Game repository samples, send PM
Post Reply