What's new

Melee Arcive Viewer (MAV) in development project.

revel8n

New member
Yes, as you have found out, the relocation table is a list of offsets to all the actual offsets present within the file. If there is a value present in the file that looks like it is an offset value, or would have been an offset value had it not been zero; if it is not linked to by the relocation table it is NOT a valid file offset. The other helpful thing is that following the valid offsets after the relocation table gets you the the beginning of every structure in the file as offsets do not jump into the middle of a struct. This is the purpose of the relocated data array. It shows the data addressed by all the relocated file offsets. Remember as i mentioned before all file offsets that are not within the file header are relative to the beginning of the data block, which is just after the 32-byte header, so all file offsets need 32 added to them to be correct.

You should also be able to find a number of the structures i outlined earlier in the thread as well. To find structures start from teh beginning and work until you hit the beginning of another structure. Structures are light grey, offsets are light red if i remember correctly.

I should hopefully be posting more information on the structures i have already found soon.

Would really be interested to know if this is helpful to other Melee hackers.
 
OP
Tcll

Tcll

Complexity == Fun >:3
this would be helpful to other hackers DEFINATLY :)

would you mind if (when you finish this)... if I posted this for download on my site??
This would be a great help to everybody :)
 
Last edited:

revel8n

New member
I don't mind if you post it for download, even in its current state, if you wanted. The more people going over the values the better. The more questions asked on things, the more details of the format are discussed, the quicker things can be validated, and so on.
 
OP
Tcll

Tcll

Complexity == Fun >:3
K...

my site will be undergoing some major updating...
I may even have to restrict access a few times just to update
JSYK :)

Don't think I'll need to though...
things should go pretty smoothly.

EDIT: I redid your code a tad:
changed:

#include "common-types.bt"

to:

#include "include\common-types.bt"
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
Well...
after a countless number of searches...
I've finally managed to find something I can use as a model viewer.

it only works on obj files, but I'm sure I can mod it to work on the dat format.
(it's written in python)

and with my skills in Tkinter, I can add advanced features to the program like:
redraw (used when rotating the model)
face filling (instead of wireframe rendering)

you can try this if you wan't...
I know you guys are bad with py...
http://www.3dartist.com/WP/python/code/objwire2.py
I just create a txt, rename it to py, and paste the code into it...
 

Milun

New member
..........uh... I guess I understood most of that (sorry, I'm not that fluent in the terminology). It's OK though, and thanks. It helps my aproach a lot. I'm going to see if I can directly (and predictably) change a bone animation, and see if I can find a pattern to it (Tcll, your code is intriguing, I'll have to look in on it). Thanks for the help all!
 
OP
Tcll

Tcll

Complexity == Fun >:3
ok...

since all of us here are pretty much used to blender,
I gave the program more of a blender feel.

here is the code:
Code has been deleted due to updates

heh.., not really much done to it though...
I'm working on simply making it zoom.
Tkinter does have it's confusing moments when you're playing with someone elses code...

it still does obj files...
I'll get it working with dat after I get it working with obj.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
well.., I've managed to get a working 3D version...

here is the code:
Code has been deleted due to updates

you have to set the scale and the views manually...
but at least it works... pretty well...

it still works on obj... but I'll work on the dat version later...
(verts and faces)
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I know I'm a few days late on posting this...
but anyways...

here's what I should've posted about 2-3 days ago:
----------------------------------------------------------------------------------------------
I know what this code is:

I did manage to find 1 thing:
not sure what it is though... but
Code:
[FONT=Lucida Console]43 34 00 00 00 00 1B [/FONT]
[FONT=Lucida Console]A8 00 00 16 [/FONT]
[FONT=Lucida Console]A4 00 00 16 [/FONT]
[FONT=Lucida Console]AC 00 00 16 [/FONT]
[FONT=Lucida Console]B8 00 00 16 [/FONT]
[FONT=Lucida Console]C4 00 00 16 [/FONT]
[FONT=Lucida Console]D0 00 00 16 [/FONT]
[FONT=Lucida Console]DC 00 00 16 [/FONT]
[FONT=Lucida Console]E8 00 00 16 [/FONT]
[FONT=Lucida Console]F4 00 00 17 [/FONT]
[FONT=Lucida Console]00 00 00 17 [/FONT]
[FONT=Lucida Console]0C 00 00 17 [/FONT]
[FONT=Lucida Console]18 00 00 17 [/FONT]
[FONT=Lucida Console]24 00 00 17 [/FONT]
[FONT=Lucida Console]30 00 00 17 [/FONT]
[FONT=Lucida Console]3C 00 00 17 [/FONT]
[FONT=Lucida Console]48 00 00 17 [/FONT]
[FONT=Lucida Console]54 00 00 17 [/FONT]
[FONT=Lucida Console]60 00 00 17 [/FONT]
[FONT=Lucida Console]6C 00 00 17 [/FONT]
[FONT=Lucida Console]78 00 00 17 [/FONT]
[FONT=Lucida Console]84 00 00 17 [/FONT]
[FONT=Lucida Console]90 00 00 17 [/FONT]
[FONT=Lucida Console]9C 00 00 17 [/FONT]
[FONT=Lucida Console]A8 00 00 17 [/FONT]
[FONT=Lucida Console]B4 00 00 17 [/FONT]
[FONT=Lucida Console]C0 00 00 17 [/FONT]
[FONT=Lucida Console]CC 00 00 17 [/FONT]
[FONT=Lucida Console]D8 00 00 17 [/FONT]
[FONT=Lucida Console]E4 00 00 17 [/FONT]
[FONT=Lucida Console]F0 00 00 17 [/FONT]
[FONT=Lucida Console]FC 00 00 18 [/FONT]
[FONT=Lucida Console]08 00 00 18 [/FONT]
[FONT=Lucida Console]14 00 00 18 [/FONT]
[FONT=Lucida Console]20 00 00 18 [/FONT]
[FONT=Lucida Console]2C 00 00 18 [/FONT]
[FONT=Lucida Console]38 00 00 18 [/FONT]
[FONT=Lucida Console]44 00 00 18 [/FONT]
[FONT=Lucida Console]50 00 00 18 [/FONT]
[FONT=Lucida Console]5C 00 00 18 [/FONT]
[FONT=Lucida Console]68 00 00 18 [/FONT]
[FONT=Lucida Console]74 00 00 18 [/FONT]
[FONT=Lucida Console]80 00 00 18 [/FONT]
[FONT=Lucida Console]8C 00 00 18 [/FONT]
[FONT=Lucida Console]98 00 00 18 [/FONT]
[FONT=Lucida Console]A4 00 00 18 [/FONT]
[FONT=Lucida Console]B0 00 00 18 [/FONT]
[FONT=Lucida Console]BC 00 00 18 [/FONT]
[FONT=Lucida Console]C8 00 00 18 [/FONT]
[FONT=Lucida Console]D4 00 00 18 [/FONT]
[FONT=Lucida Console]E0 00 00 18 [/FONT]
[FONT=Lucida Console]EC 00 00 18 [/FONT]
[FONT=Lucida Console]F8 00 00 19 [/FONT]
[FONT=Lucida Console]04 00 00 19 [/FONT]
[FONT=Lucida Console]10 00 00 19 [/FONT]
[FONT=Lucida Console]1C 00 00 19 [/FONT]
[FONT=Lucida Console]28 00 00 19 [/FONT]
[FONT=Lucida Console]34 00 00 19 [/FONT]
[FONT=Lucida Console]40 00 00 19 [/FONT]
[FONT=Lucida Console]4C 00 00 19 [/FONT]
[FONT=Lucida Console]58 00 00 19 [/FONT]
[FONT=Lucida Console]64 00 00 19 [/FONT]
[FONT=Lucida Console]70 00 00 19 [/FONT]
[FONT=Lucida Console]7C 00 00 19 [/FONT]
[FONT=Lucida Console]88 00 00 19 [/FONT]
[FONT=Lucida Console]94 00 00 19 [/FONT]
[FONT=Lucida Console]A0 00 00 19 [/FONT]
[FONT=Lucida Console]AC 00 00 19 [/FONT]
[FONT=Lucida Console]B8 00 00 19 [/FONT]
[FONT=Lucida Console]C4 00 00 19 [/FONT]
[FONT=Lucida Console]D0 00 00 19 [/FONT]
[FONT=Lucida Console]DC 00 00 19 [/FONT]
[FONT=Lucida Console]E8 00 00 19 [/FONT]
[FONT=Lucida Console]F4 00 00 1A [/FONT]
[FONT=Lucida Console]00 00 00 1A [/FONT]
[FONT=Lucida Console]0C 00 00 1A [/FONT]
[FONT=Lucida Console]18 00 00 1A [/FONT]
[FONT=Lucida Console]24 00 00 1A [/FONT]
[FONT=Lucida Console]30 00 00 1A [/FONT]
[FONT=Lucida Console]3C 00 00 1A [/FONT]
[FONT=Lucida Console]48 00 00 1A [/FONT]
[FONT=Lucida Console]54 00 00 1A [/FONT]
[FONT=Lucida Console]60 00 00 1A [/FONT]
[FONT=Lucida Console]6C 00 00 1A [/FONT]
[FONT=Lucida Console]78 00 00 1A [/FONT]
[FONT=Lucida Console]84 00 00 1A [/FONT]
[FONT=Lucida Console]90 00 00 1A [/FONT]
[FONT=Lucida Console]9C 00 00 1A [/FONT]
[FONT=Lucida Console]A8 00 00 1A [/FONT]
[FONT=Lucida Console]B4 00 00 1A [/FONT]
[FONT=Lucida Console]C0 00 00 1A [/FONT]
[FONT=Lucida Console]CC 00 00 1A [/FONT]
[FONT=Lucida Console]D8 00 00 1A [/FONT]
[FONT=Lucida Console]E4 00 00 1A [/FONT]
[FONT=Lucida Console]F0 00 00 1A [/FONT]
[FONT=Lucida Console]FC 00 00 1B [/FONT]
[FONT=Lucida Console]08 00 00 1B [/FONT]
[FONT=Lucida Console]14 00 00 1B [/FONT]
[FONT=Lucida Console]20 00 00 1B [/FONT]
[FONT=Lucida Console]2C 00 00 1B [/FONT]
[FONT=Lucida Console]38 00 00 1B [/FONT]
[FONT=Lucida Console]44 00 00 1B [/FONT]
[FONT=Lucida Console]50 00 00 1B [/FONT]
[FONT=Lucida Console]5C 00 00 1B [/FONT]
[FONT=Lucida Console]68 00 00 1B [/FONT]
[FONT=Lucida Console]74 00 00 1B [/FONT]
[FONT=Lucida Console]80 00 00 1B [/FONT]
[FONT=Lucida Console]8C 00 00 1B [/FONT]
[FONT=Lucida Console]98 00 00 1B [/FONT]
[FONT=Lucida Console]A4 00 00 1B [/FONT]
[FONT=Lucida Console]E4 00 00 1B [/FONT]
[FONT=Lucida Console]E8 00 00 1B [/FONT]
[FONT=Lucida Console]D8 00 00 00 00[/FONT]

it may not be in the right format..., but it's just a find.

it's a data table and I did format it wrong...

thanx to revel for the template
 
OP
Tcll

Tcll

Complexity == Fun >:3
UPDATE:
verts are now displayed

Code has been deleted due to updates

get this....
I don't even know WTF I'm doing, or HTF I'm doing this... D:!

I don't even fully get the code...
I havn't even taken geometry for cryin out loud...

and yet I have a working program
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
hey revel...

do you know anything further about 3D programming that could help me out here??
I'm still looking for resources that could help me...
but no luck on what I need so far... :(

if you have any advice or tips or anything at all for me...
it would be much appreciated

EDIT: never mind...
I figured it out.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
well...
I did manage to think of a way to get it in between the views...

I havn't been posting because I've been working out a bug that streched the model.
I finally figured it out...

( ( vector[1](point#)+vector[2](point#) ) - ( vector[3](point#)/2 ) )/4,




here is the code for it:
Code:
import os.path, sys
import Tkinter as tk
from tkFileDialog import askopenfilename as tkFileGet
from string import rstrip, split
 
view = 10
#=1 for front, =3 for side, =7 for top
scale = 5
vertsize = 1
hideLines = 1
#=0 for don't hide, =1 for hide, =-1 for show hidden as gray
 
#colors:
if hideLines==1:
    BG = '#909090'      #Background
    fcol = '#99AfE0'    #Face color
    flin = '#000000'    #Line color
    fcola = '#D08FEF'   #active Face color
    flina = '#FFF000'   #active Line color
    vcol = '#D08FEF'    #Vert color
    vcola = '#FFF000'   #active Vert color
    lshad = ''
 
elif hideLines==0:
    BG = '#909090'      #Background
    fcol = ''     #Face color
    flin = '#000000'    #Line color
    fcola = ''    #active Face color
    flina = '#FFFF2F'   #active Line color
    vcol = '#D08FEF'    #Vert color
    vcola = '#FFF000'   #active Vert color
    lshad = ''
 
elif hideLines==-1:
    BG = '#909090'      #Background
    fcol = ''           #Face color
    flin = '#000000'    #Line color
    fcola = ''          #active Face color
    flina = '#FFF000'   #active Line color
    vcol = '#D08FEF'    #Vert color
    vcola = '#FFF000'   #active Vert color
    lshad = '#404040'
 
 
def drawWireframe(cv,cvSize,fn):
    try: fin = open(fn, 'r')
    except IOError,(eNum,eStr):
        return fn+'\n  I/O Error ('+str(eNum)+'): '+eStr
 
    txList = map(rstrip,fin.readlines())  #strip trailing white space
    fin.close()
    vDat = []                           #vertex (point) list
    fDat = []                           #face (polygon) list
    ex = infoClass()                    #extents info collector
    ex.minX = None
    complex = None
    for i in range(len(txList)):        #initialize extents
        if txList[i]:                   #not an empty line
            tx = split(txList[i])
 
            if ex.minX == None and tx[0] == 'v':  #find first vertex
                ex.minX,ex.maxX = float(tx[1]),float(tx[1])
                ex.minY,ex.maxY = float(tx[2]),float(tx[2])
                ex.minZ,ex.maxZ = float(tx[3]),float(tx[3])
 
            if tx[0] == 'f' and complex == None: #find first polygon
                complex = (tx[1].find('/') > -1) #are faces in v/vt/vn form?
                break                       #finished with inits
    if ex.minX == None or complex == None:  #vertex or poly data not found
        return fn+' is not a valid OBJ-format file'
 
    for i in range(len(txList)):
        if txList[i]:                   #not an empty line
            tx = split(txList[i])
            if tx[0] == 'v':            #read vertices & find extents
                x,y,z = float(tx[1]),float(tx[2]),float(tx[3])
                if x < ex.minX:   ex.minX = x
                elif x > ex.maxX: ex.maxX = x
                if y < ex.minY:   ex.minY = y
                elif y > ex.maxY: ex.maxY = y
                if z < ex.minZ:   ex.minZ = z
                elif z > ex.maxZ: ex.maxZ = z
                vDat.append([x,y,z])
 
            elif tx[0] == 'f':          #read faces
                if complex:
                    p1,p2,p3 = int(split(tx[1],'/')[0]) - 1, int(split(tx[2],'/')[0]) - 1, int(split(tx[3],'/')[0]) - 1  #-1 to be 0-based
                else:
                    p1,p2,p3 = int(tx[1])-1, int(tx[2])-1, int(tx[3])-1
 
                if len(tx) == 5:        #quad
                    if complex: p4 = int(split(tx[4],'/')[0]) - 1
                    else: p4 = int(tx[4]) - 1
                    fDat.append([p1,p2,p3,p4])
 
                else:                   #triangle
                    fDat.append([p1,p2,p3])
 
 
 
    for i in range(len(vDat)):  #center & scale XYZ coords to raster integers
        vDat[i][0] = ((cvSize[0]/2) + 1000) + int((vDat[i][0]+(-(((ex.maxX-ex.minX)/2)+ex.minX)))*scale)
        vDat[i][1] = ((cvSize[1]/2) + 10) + int((vDat[i][1]+(-(((ex.maxY-ex.minY)/2)+ex.minY)))*scale)
        vDat[i][2] = ((cvSize[2]/2) + 10) + int((vDat[i][2]+(-(((ex.maxZ-ex.minZ)/2)+ex.minZ)))*scale)
 
    vs = vertsize
    for i in range(len(fDat)):
        flag = 0
        if view == 10:
            if hideLines:           #do vector check
                if ((((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][1]-(vDat[fDat[i][0]][2]/2))/4)-((vDat[fDat[i][1]][0]+vDat[fDat[i][1]][1]-(vDat[fDat[i][1]][2]/2))/4)) \
                  * (((vDat[fDat[i][2]][0]+vDat[fDat[i][2]][2]-(vDat[fDat[i][2]][1]/2))/4)-((vDat[fDat[i][1]][0]+vDat[fDat[i][1]][2]-(vDat[fDat[i][1]][1]/2))/4)))\
                  -((((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][2]-(vDat[fDat[i][0]][1]/2))/4)-((vDat[fDat[i][1]][0]+vDat[fDat[i][1]][2]-(vDat[fDat[i][1]][1]/2))/4)) \
                  * (((vDat[fDat[i][2]][0]+vDat[fDat[i][2]][1]-(vDat[fDat[i][2]][2]/2))/4)-((vDat[fDat[i][1]][0]+vDat[fDat[i][1]][1]-(vDat[fDat[i][1]][2]/2))/4))) < 0:
                    if hideLines == -1: flag = 1  #do grayed outline
                    else: continue                #don't draw
            if len(fDat) == 4:      #draw quad 
                f = cv.create_polygon(
                    (vDat[fDat[i][0]][0]+vDat[fDat[i][0]][1]-(vDat[fDat[i][0]][2]/2))/4,(vDat[fDat[i][0]][0]+vDat[fDat[i][0]][2]-(vDat[fDat[i][0]][1]/2))/4,
                    (vDat[fDat[i][1]][0]+vDat[fDat[i][1]][1]-(vDat[fDat[i][1]][2]/2))/4,(vDat[fDat[i][1]][0]+vDat[fDat[i][1]][2]-(vDat[fDat[i][1]][1]/2))/4,
                    (vDat[fDat[i][2]][0]+vDat[fDat[i][2]][1]-(vDat[fDat[i][2]][2]/2))/4,(vDat[fDat[i][2]][0]+vDat[fDat[i][2]][2]-(vDat[fDat[i][2]][1]/2))/4,
                    (vDat[fDat[i][3]][0]+vDat[fDat[i][3]][1]-(vDat[fDat[i][2]][3]/2))/4,(vDat[fDat[i][3]][0]+vDat[fDat[i][3]][2]-(vDat[fDat[i][3]][1]/2))/4,
                                    fill=fcol, outline=flin, activefill=fcola, activeoutline=flina,)
 
                v = cv.create_oval(((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][1]-(vDat[fDat[i][0]][2]/2))/4)+vertsize,((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][2]-(vDat[fDat[i][0]][1]/2))/4)-vertsize,
                                   ((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][1]-(vDat[fDat[i][0]][2]/2))/4)-vertsize,((vDat[fDat[i][0]][0]+vDat[fDat[i][0]][2]-(vDat[fDat[i][0]][1]/2))/4)+vertsize,
                                    fill=vcol, outline=vcol, activefill=vcola, activeoutline=vcola,)
 
            else:                   #draw tri
                f = cv.create_polygon(
                    (vDat[fDat[i][0]][1]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][2]/2))/4,(vDat[fDat[i][0]][2]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][1]/2))/4,
                    (vDat[fDat[i][1]][1]+vDat[fDat[i][1]][0]-(vDat[fDat[i][1]][2]/2))/4,(vDat[fDat[i][1]][2]+vDat[fDat[i][1]][0]-(vDat[fDat[i][1]][1]/2))/4,
                    (vDat[fDat[i][2]][1]+vDat[fDat[i][2]][0]-(vDat[fDat[i][2]][2]/2))/4,(vDat[fDat[i][2]][2]+vDat[fDat[i][2]][0]-(vDat[fDat[i][2]][1]/2))/4,
                                    fill=fcol, outline=flin, activefill=fcola, activeoutline=flina,)
 
                v = cv.create_oval(
                    ((vDat[fDat[i][0]][1]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][2]/2))/4)-vertsize,((vDat[fDat[i][0]][2]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][1]/2))/4)+vertsize,
                    ((vDat[fDat[i][0]][1]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][2]/2))/4)+vertsize,((vDat[fDat[i][0]][2]+vDat[fDat[i][0]][0]-(vDat[fDat[i][0]][1]/2))/4)-vertsize,
                                    fill=vcol, outline=vcol, activefill=vcola, activeoutline=vcola,)
 
        #front
        elif view == 1:
            if hideLines:           #do vector check
                if ((vDat[fDat[i][0]][0]-vDat[fDat[i][1]][0]) * (vDat[fDat[i][2]][1]-vDat[fDat[i][1]][1]))\
                  -((vDat[fDat[i][0]][1]-vDat[fDat[i][1]][1]) * (vDat[fDat[i][2]][0]-vDat[fDat[i][1]][0])) < 0:
                    if hideLines == -1: flag = 1  #do grayed outline
                    else: continue                #don't draw
            if len(fDat) == 4:      #draw quad 
                f = cv.create_polygon(vDat[fDat[i][0]][0],vDat[fDat[i][0]][1],
                                      vDat[fDat[i][1]][0],vDat[fDat[i][1]][1],
                                      vDat[fDat[i][2]][0],vDat[fDat[i][2]][1],
                                      vDat[fDat[i][3]][0],vDat[fDat[i][3]][1],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][0]+vertsize,vDat[fDat[i][0]][1]-vertsize,
                                   vDat[fDat[i][0]][0]-vertsize,vDat[fDat[i][0]][1]+vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
 
            else:                   #draw tri
                f = cv.create_polygon(vDat[fDat[i][0]][0],vDat[fDat[i][0]][1],
                                      vDat[fDat[i][1]][0],vDat[fDat[i][1]][1],
                                      vDat[fDat[i][2]][0],vDat[fDat[i][2]][1],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][0]+vertsize,vDat[fDat[i][0]][1]+vertsize,
                                   vDat[fDat[i][0]][0]-vertsize,vDat[fDat[i][0]][1]-vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
        #side
        elif view == 3:
            if hideLines:           #do vector check
                if ((vDat[fDat[i][0]][1]-vDat[fDat[i][1]][1]) \
                  * (vDat[fDat[i][2]][2]-vDat[fDat[i][1]][2]))\
                  -((vDat[fDat[i][0]][2]-vDat[fDat[i][1]][2]) \
                  * (vDat[fDat[i][2]][1]-vDat[fDat[i][1]][1])) < 0:
                    if hideLines == -1: flag = 1  #do grayed outline
                    else: continue                #don't draw
            if len(fDat) == 4:      #draw quad 
                f = cv.create_polygon(vDat[fDat[i][0]][2],vDat[fDat[i][0]][1],
                                      vDat[fDat[i][1]][2],vDat[fDat[i][1]][1],
                                      vDat[fDat[i][2]][2],vDat[fDat[i][2]][1],
                                      vDat[fDat[i][3]][2],vDat[fDat[i][3]][1],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][2]+vertsize,vDat[fDat[i][0]][1]-vertsize,
                                   vDat[fDat[i][0]][2]-vertsize,vDat[fDat[i][0]][1]+vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
 
            else:                   #draw tri
                f = cv.create_polygon(vDat[fDat[i][0]][2],vDat[fDat[i][0]][1],
                                      vDat[fDat[i][1]][2],vDat[fDat[i][1]][1],
                                      vDat[fDat[i][2]][2],vDat[fDat[i][2]][1],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][2]+vertsize,vDat[fDat[i][0]][1]-vertsize,
                                   vDat[fDat[i][0]][2]-vertsize,vDat[fDat[i][0]][1]+vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
        #top
        elif view == 7:
            if hideLines:           #do vector check
                if ((vDat[fDat[i][0]][0]-vDat[fDat[i][1]][0]) \
                  * (vDat[fDat[i][2]][2]-vDat[fDat[i][1]][2]))\
                  -((vDat[fDat[i][0]][2]-vDat[fDat[i][1]][2]) \
                  * (vDat[fDat[i][2]][0]-vDat[fDat[i][1]][0])) < 0:
                    if hideLines == -1: flag = 1  #do grayed outline
                    else: continue                #don't draw
            if len(fDat) == 4:      #draw quad 
                f = cv.create_polygon(vDat[fDat[i][0]][0],vDat[fDat[i][0]][2],
                                      vDat[fDat[i][1]][0],vDat[fDat[i][1]][2],
                                      vDat[fDat[i][2]][0],vDat[fDat[i][2]][2],
                                      vDat[fDat[i][3]][0],vDat[fDat[i][3]][2],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][0]+vertsize,vDat[fDat[i][0]][2]-vertsize,
                                   vDat[fDat[i][0]][0]-vertsize,vDat[fDat[i][0]][2]+vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
            else:                   #draw tri
                f = cv.create_polygon(vDat[fDat[i][0]][0],vDat[fDat[i][0]][2],
                                      vDat[fDat[i][1]][0],vDat[fDat[i][1]][2],
                                      vDat[fDat[i][2]][0],vDat[fDat[i][2]][2],
                                    fill=fcol, outline=flin,
                                    activefill=fcola, activeoutline=flina,
                                    )
                v = cv.create_oval(vDat[fDat[i][0]][0]+vertsize,vDat[fDat[i][0]][2]-vertsize,
                                   vDat[fDat[i][0]][0]-vertsize,vDat[fDat[i][0]][2]+vertsize,
                                    fill=vcol, outline=vcol,
                                    activefill=vcola, activeoutline=vcola,
                                    )
 
 
 
 
        if flag:
            cv.itemconfig(f,outline=lshad)
            cv.lower(f)
 
    return fn+' - '+str(len(vDat))+' points & '+str(len(fDat))+' faces\n'+'scale = '+(scale).__str__()
    #end def drawWireframe
class infoClass:                        #empty class to hold temporary info
    def __init__(self):
        pass
    #end class infoClass
 
scX = 1024
scY = 768
scZ = 4
class mainWindowClass:
    def __init__(self,master):
        self.frame = tk.Toplevel(master)
        self.frame.title('Tkinter 3D OBJ Hidden-Line Wireframe 0.0d')
        self.frame.geometry((scX).__str__()+'x'+(scY).__str__()+'+0+0')
        self.frame.resizable(0,0)
        self.canvas = tk.Canvas(self.frame, bg=BG, bd=3, relief='sunken', cursor='crosshair')
        self.canvas.pack(side='top',anchor='nw',fill='both',expand=1)
        self.frame.protocol('WM_DELETE_WINDOW',self.quit)   #close button
 
 
    def getFile(self):
        fn = tkFileGet(title='Select a file',parent=self.frame,
                       initialdir=os.path.split(sys.argv[0])[0],
                       filetypes=[('OBJ','*.obj *.tab'),('All Files','*.*')])
        self.frame.update_idletasks()
        if fn:
            if fn[-4:].lower() in ['.obj','.tab']:
                return drawWireframe(self.canvas,(scX,scY,scZ),fn)
            else:
                return fn+' selected\n\nNeed .obj or .tab file in OBJ format'
        else: return 'No file selected'
    def quit(self):
        self.frame.destroy()
    #end class mainWindowClass
#--- go to work ---
 
 
root = tk.Tk()
root.withdraw()
mainWin = mainWindowClass(root)
mainWin.canvas.create_text(10,10,anchor='nw',font=('Helvetica',10),
                           text=mainWin.getFile())
#root.update_window(mainWin.frame)
root.mainloop()
### end script ###

you still have to set everything manually...
and that's the only in-between view for now...

I'm sure anything further would be in revel's catagory...
I'm not good at collage level 3D programming yet

btw. the view in that image is from below...
don't be fooled by it. =]
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
it seems I was wrong yet again... :(

the header of the file is actually 16 bytes,
separated by a 16 byte data spacer.

this spacer separates the vert data from the header...
after the vert data, you will find another 16 byte data spacer separating the verts from the normals.

then you'll find another spacer separating the normals from the uv's.

and another spacer separating the uv's from the ~texture header offsets (I believe)~.

and another one separating the faces.

this was my mistake when I mistook the normal data for the uv data.


it wasn't until I noticed the spacers that I realized my mistake...

so I'm working on rewriting the code right now.

this find would probably help you out revel... :)
 
Last edited:

revel8n

New member
Certain data within the file must start at a 32-byte offset. particularly data that is going to be sent to the gamecube/wii hardware for processing. It is not guaranteed that it will be necessary for there to be extra space between the data section if they so happen to fall on an offset that is evenly divisible by 32. The structures i outlined earlier in the thread show you some of the locations that the offsets to the vertex, normals, and/or uv data is present, as well as how to determine the data types from them. Using the template i provided you should be able to see the vertex declaration structures i mentioned.

Sorry i got a little preoccupied finishing my reversal of data from Final Fantasy XIII, heh. Will be back on creating some more useful things for Melee soon. If you are looking for some things to traverse, the rootNode structures in the script are, in particular, the starting point for properly traversing the various .dat files. i'll see if i can provide a more useful structure layout for anyone not accustomed to following things in a hex editor.

Catch me up on the progress of things, and i can possibly answer any more questions you may have. i also posted about the results over on smashboards, but doesn't seem most were too interested in the information, or its just hard to guage the response. Oh well, should have something a bit more visually useful for everyone soon, hopefully.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
thanx for the extra info. :0

and don't worry bout getting preoccupied :p
I got a little preoccupied with my anime and my site

it only took me about an hour to find my mistake in the last post. :D

using my method for the normals and the uv's...
this is what I've managed to do so far: (images not linked)
QmV5FzWVTw4gVvyHd6NvtCjADv6UQjfh9JZgopnYu8wHFw

QmVkLajUYACeErPMQjuTLnriwUyQoXLU6BJKGp5ZUeBTKa

I love the smell of progress...
smells like burning cpu with the stench of BO. XD

anyways...
my original file kept returning errors when imported into blender...
so these were the other 2...

as you can see..., the first is better than the second...
once I separate the objects...
it should come out a little better..., if not perfect.




EDIT: never mind...
I managed to split the objects up...
externally of course...
-----
the objects are separated by 2 new lines.
just add 'g object_#' to the beginning of every object.
note: you must change the '#' to 0 and count +1 for each object.
-----
anyways...
I got the same results
of course..., they're split up..., but nothing has changed position wise.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
It is not guaranteed that it will be necessary for there to be extra space between the data section

it's not so much extra space as it is for data type offsetting...
each spacer is 16 bytes

the data will be read and divided evenly before the spacer...

in my opinion... the spacer isn't really nessessary...
you could pretty much delete the spacers and still get the required data converted...
with the right method of course...

mine would not work in this case,
mine reads the file downward until it hits a spacer, and then changes the conversion method for that particular data type...

you could pretty much say I'm putting some use to the spacers...
 
OP
Tcll

Tcll

Complexity == Fun >:3
UUUGH... DX<

it seems my first run was my best...
I am unable to think of any better ideas. :(

here's my current code:
Code:
import struct as S
dat = open("import.dat", 'rb')
obj = open("export.obj", 'w')
#mtl = open("export.mtl", 'w')
def HexToDec(h):
    return float(S.unpack("<h", S.pack("<H", int((h.encode('hex')), 16)))[0])
def vert(v): 
    return (HexToDec(v)* 0.01).__str__()
def uv(vt): 
    return (HexToDec(vt)* 0.01).__str__()
def f():
    f = int(HexToDec(dat.read(2))+1).__str__()
    uv = int(HexToDec(dat.read(2))+1).__str__()
    nor = int(HexToDec(dat.read(2))).__str__()
 
    if (int(f, 10) >= 0):
        return f+"/"+uv+"/"+nor
t0 = dat.read(32)#header
g = 0
a = 0
while (a == 0):
    v = "v "+vert(dat.read(2))+" "+vert(dat.read(2))+" "+vert(dat.read(2))
    if (v == 'v 0.0 0.0 0.0'):
        a = 1#main loop
        while (a == 1):
          s = dat.read(6)
          s = dat.read(1).encode('hex')
          if (s == '00'):
            a = 2
            s = dat.seek(1,1)
            obj.write("\n")
            while (a == 2):#normals
              vn = "vn "+vert(dat.read(2))+" "+vert(dat.read(2))+" "+vert(dat.read(2))
              if (vn == 'vn 0.0 0.0 0.0'):
                a = 3
                while (a == 3):
                  s = dat.read(6)
                  s = dat.read(1).encode('hex')
                  if (s == '00'):
                    a = 3.1
                    s = dat.seek(1,1)
                    obj.write("\n")
                    while (a == 3.1):#UV's
                      vt  = "vt "+uv(dat.read(2))+" "+uv(dat.read(2))
                      #vt2 = "vt "+vert(dat.read(2))+" "+vert(dat.read(2))
                      if (vt == 'vt 0.0 0.0'):# and vt2 == 'vt 0.0 0.0'):
                        a = 3.5
 
                        obj.write("\n"+'o object'+g.__str__()+"\n")
                        while (a == 3.5):
                            g = g+1
 
                            # attempt to ensure processing starts at the beginning of a data section
                            #h = dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')
                            #if (h == '0000B8' or h == '0000A8' or h == '0000B0' or h == '000090' or h == '000098' or h == '0000A0' or h == '000080'):  #this may also work and find even more matches, need to update backtrack offset if used
                            h = dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')+dat.read(1).encode('hex')
                            if (h == '0000B800' or h == '0000A800' or h == '0000B000' or h == '00009000' or h == '00009800' or h == '0000A000' or h == '00008000'):
                                a = 4
                                s = dat.seek(-2,1)
                                pos = dat.tell()
                                #print pos.__str__()+": "+h
                                while (a == 4):
                                    pos = dat.tell()
                                    h = dat.read(1).encode('hex') #+dat.read(1).encode('hex')
                                    #print pos.__str__()+": "+h
                                    if (h == 'B8' or h == 'A8' or h == 'B0' or h == '90' or h == '98' or h == 'A0' or h == '80'):
                                        #s = dat.seek(-1,1)
                                        index = HexToDec(dat.read(2))#index count
                                        if (h == 'B8'): #point
                                            while (index > 0):
                                                f0 = f()
                                                index = index - 1
                                                print "f "+f0
                                                obj.write("f "+f0+"\n")
 
                                        elif (h == 'A8'): #line
                                            while (index > 1):
                                                f0 = f()
                                                f1 = f()
 
                                                index = index - 2
                                                print "f "+f0+' '+f1
                                                obj.write("f "+f0+' '+f1+"\n")
 
                                        elif (h == 'B0'): #line strip
                                            while (index > 1):
                                                f0 = f()
                                                f1 = f()
 
                                                index = index - 1
                                                if (index > 1):
                                                    seek = dat.seek(-6,1)
                                                if (f0 != f1):
                                                    print "f "+f0+' '+f1
                                                    obj.write("f "+f0+' '+f1+"\n")
 
 
                                        elif (h == '90'): #triangle
                                            while (index > 2):
                                                f0 = f()
                                                f1 = f()
                                                f2 = f()
 
                                                index = index - 3
                                                print "f "+f0+' '+f1+' '+f2
                                                obj.write("f "+f0+' '+f1+' '+f2+"\n")
 
                                        elif (h == '98'): #triangle strip
                                            flip = 1
                                            while (index > 2):
                                                f0 = f()
                                                f1 = f()
                                                f2 = f()
 
                                                index = index - 1
                                                if (index > 2):
                                                    seek = dat.seek(-12,1)
                                                if (f0 != f1 and f1 != f2 and f2 != f0):
                                                    if (flip):
                                                        print "f "+f0+' '+f2+' '+f1
                                                        obj.write("f "+f0+' '+f2+' '+f1+"\n")
                                                    else:
                                                        print "f "+f0+' '+f1+' '+f2
                                                        obj.write("f "+f0+' '+f1+' '+f2+"\n")
                                                flip = 1 - flip
 
                                        elif (h == 'A0'): #triangle fan
                                            f0 = f()
                                            index = index - 1
 
                                            while (index > 1):
                                                f1 = f()
                                                f2 = f()
 
                                                index = index - 1
                                                if (index > 1):
                                                    seek = dat.seek(-6,1)
 
                                                if (f0 != f1 and f1 != f2 and f2 != f0):
                                                    print "f "+f0+' '+f1+' '+f2
                                                    obj.write("f "+f0+' '+f1+' '+f2+"\n")
 
                                        elif (h == '80'): #quad
                                            while (index > 3):
                                                f0 = f()
                                                f1 = f()
                                                f2 = f()
                                                f3 = f()
 
                                                index = index - 4
                                                print "f "+f0+' '+f1+' '+f2+' '+f3
                                                obj.write("f "+f0+' '+f1+' '+f2+' '+f3+"\n")
                                        else:
                                            a = 3 # should no longer get here, but just in case...
                                    else:
                                        # backtrack over invalid primitive type bytes
                                        a = 3
                                        s = dat.seek(-1,1)
                            else:        
                                 #backtrack over trailing bytes so that
                                 #the entire file is scanned a byte at a time
                                 s = dat.seek(-3,1)
                      else:
                        print vt
                        #print vt2
                        obj.write(vt+"\n")#+vt2+"\n")
 
              else:
                print vn
                obj.write(vn+"\n")
 
    else:
        print v
        obj.write(v+"\n")

if you would like to try to work on it, well...
I wish you the best of luck...

I'll be trying to find new ways on my end as well.
 
Last edited:
OP
Tcll

Tcll

Complexity == Fun >:3
I would like to go about working on the Pl files...

And I have 1 Q:
how would I go about applying the joint matricies??

I've got someone who would like to work with Dr Mario...

so I really need your help... :( please.
 

Milun

New member
Hey, sorry about my inactivity. I still really want to help, I'm just taking a personal trip to improve my C++ skills. Also, after versing my friend on my unfinished hack of MK1, I felt I should finish that too. Sorry I'm of no help in this category.
 
OP
Tcll

Tcll

Complexity == Fun >:3
heh... =]

even if revel sends me that info right now...
I probably won't even look at it...

I just got Gecko on my Wii... :drool:
and I'm working on my own version of Brawl+ :drool:

so.., yea I might not be working on this very much...
maybe a little here and there..., but still not very much... :(

Ima be havin 2 much fun on B+.:king:
 

Top