mariokart64n Posted January 7, 2011 Report Share Posted January 7, 2011 I created these videos over the christmas, deals with hacking really.. the last video is still pending, and would contain more important things you would need to know to do. but overall this is a good intro for people wanting to know more about computer files and how you can read them.watch if you will, I don't expect much but I hope it will give some insight[url]http://www.youtube.com/watch?v=1ORnfYnlXOw[/ulr] the PMD samples I got from the MikUMikuDance, some PMD were packed with the program.http://www.geocities.jp/higuchuu4/index_e.htmand here is the sample script I did in the videof = 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 3fileVersion=readfloat fmodelName=ReadFixedString f 20comments=ReadFixedString f 256count=readlong f #unsignedfor x = 1 to count do(vx=readfloat fvy=readfloat fvz=readfloat fp4=readfloat fp5=readfloat fp6=readfloat ftu=readfloat ftv=readfloat fp9=readshort fp10=readshort fp11=readshort fappend Vert_array[vx,vz,vy]append UV_array[tu,tv,0])count=readlong f #unsignedprint countfor x = 1 to count/3 do(fa=readshort f #unsigned+1fb=readshort f #unsigned+1fc=readshort f #unsigned+1append Face_array[fc,fb,fa])msh = mesh vertices:Vert_array faces:Face_arraymsh.numTVerts = UV_array.countbuildTVFaces mshmsh.name=modelName-- convertTo msh PolyMeshObjectfor 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 fFunctionsfunctions 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 laterexample: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 outso 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 filesreadBEshort, lets you read 2bytes in reversed order.. which is actually right to left.fn readBEshort fstream = (short = readshort fstream #unsignedshort = bit.swapBytes short 1 2return short) readBElong, lets you read 4bytes in big endian, aka reversed order (which is actually right to left)fn readBElong fstream = (long = readlong fstreamlong = bit.swapBytes long 1 4long = bit.swapBytes long 2 3return 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. readBEshotbut make sure the readBEshort function gets paste before this. otherwise how can you call something that doesnt exist yet.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 xbox360fn 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.fn ReadFixedString bstream fixedLen = ( local str = "" for i = 1 to fixedLen do ( str += bit.intAsChar (ReadByte bstream #unsigned) ) str) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now