HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Extracting Animations from Models

03-28-2006, 02:13 PM#1
Ralle
Hello!
I am making a php script like the one they have at wc3s, a script to see what animations are in a map. I figured that
PHP Code:
substr(strstr($model_contents,"SEQS"),8); 
would give me the direct path to the first animation, but after that, there is no real system of where the next name of the animation comes.. I was just wondering if you knew any system?
03-28-2006, 02:55 PM#2
Whitehorn
You said models in the thread and map in the post, which are you after?
03-28-2006, 04:31 PM#3
Ralle
sry I mean model..
I want to be able to locate animations, particles and somehow count particles.. Does anybody know exactley what "tags" are at the start of stuff? Like the animations is "SEQS", "SEQS" is always there 4 letters before the first animation
03-28-2006, 04:39 PM#4
Jacek
Hmmm... I think it is in MDX specification.
03-28-2006, 06:17 PM#5
Ralle
where is that? I have searched google many times for stuff like that.. MDX specs
03-28-2006, 06:51 PM#6
Tim.
http://magos.thejefffiles.com/War3ModelEditor/

All the way down at the bottom of the page.
03-29-2006, 02:21 PM#7
Guesst
PHP Code:
<html>
<body>

<form name="upload" method="post" action="mdxanims.php" 
    enctype="multipart/form-data"> 
    <input type="file" name="mdx"><br> 
    <input type="submit" value="Upload MDX"> 
</form>

<?php

/*
 * Converts the four bytes of data in which integers are
 * stored in MDXs into an actual integer.
 */
function S2I($s) {
    return ( 
        
ord(substr($s,0,1)) | 
        (
ord(substr($s,1,1))<<8) | 
        (
ord(substr($s,2,1))<<16) | 
        (
ord(substr($s,3,1))<<24
    );
}

/*
 * Read an MDX-style integer
 */
function readInt($fp) {
    return 
S2I(fread($fp4));
}

/*
 * Moves the pointer to the given chunk. If the chunk is
 * not found, it will move it to the end and return false.
 */
function jumpToChunk($fp$chunk) {
    
// Get the length
    
fseek($fp0SEEK_END); 
    
$fileLen ftell($fp);
    
    
// Skip 'MDLX'
    
fseek($fp4SEEK_SET);
    
// Read a chunk title. Leave if it is right.
    
while(fread($fp4)!=$chunk) { 
        
// Read the chunk length and skip that many bytes.
        
fseek($fpreadInt($fp), SEEK_CUR);
        
// Fail if it hits the end of the file.
        
if (ftell($fp)==$fileLen) {
            return 
false;
        }
    }
    return 
true;
}

/*
 * Find out how many of a type of item exist. The
 * item type MUST be one of them with inclusive 
 * byte counts spanning the whole thing. That means
 * ATCH CAMS GEOA HELP LITE MTLS PREM PRE2 RIBB TXAN
 */
function getChunkItemCount($fp$chunk) {
    if (
jumpToChunk($fp$chunk)==false) return 0;
    
$chunkLen readInt($fp);
    
$readLen 0;
    
$subchunkCount=0;
    while (
$readLen<$chunkLen) {
        
$subchunkLen readInt($fp);
        
$readLen+=$subchunkLen;
        
$subchunkCount++;
        
fseek($fp$subchunkLen-4SEEK_CUR);
    }
    return 
$subchunkCount;
}

// First make sure that they chose an MDX file
$fileName $_FILES['mdx']['name'];
if (isset(
$fileName) && $fileName!="") {
    
// Open the uploaded file for binary reading
    
$fp fopen($_FILES['mdx']['tmp_name'], "rb");
    
    
// MDXs always start with 'MDLX'. Make sure this file does.
    
if (fread($fp4)=="MDLX") {
    
        
// This will store the sequences in the end
        
$seqList = array();
        
        
// Get to the SEQS chunk
        
jumpToChunk($fp"SEQS");
        
        
// Each sequence takes up 132 bytes, so this gives a count
        
$seqCount readInt($fp)/132;
        
        
// Go through and read each actual sequence. The names are
        // stored in the first 80 bytes if each.
        
for ($currSeq=0$currSeq<$seqCount$currSeq++) {
            
$seqList[$currSeq] = fread($fp80);
            
fseek($fp52SEEK_CUR);
        }
        
        
// Print it out. You could save it somewhere instead of 
        // doing this.
        
foreach ($seqList as $seq) {
            print 
"$seq<br>";
        }
        
        print 
getChunkItemCount($fp"PRE2") . " particle emitters<br>";
        print 
getChunkItemCount($fp"RIBB") . " ribbon emitters<br>";
        
    } else {
        print 
"Not an MDX</p>";
    }
    
fclose($fp);
}

?></body>
</html>
03-29-2006, 05:14 PM#8
Vexorian
hmnn should hack the php tag so it handles stuff outside like html tag does