Kitty Corp Meow Mix Forums

Super Smash Bros. Brawl Hacking => Programming => Topic started by: DarkPikachu on January 08, 2012, 12:20:49 PM



Title: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 08, 2012, 12:20:49 PM
I'll only be working on the importer for now...

I'm not getting any help from 5 forums in the matter of generating the Group, Next, and Prev ID's in the relocation offsets...


anyways...
I'd like to do this because IK this converter's gonna take a few years just to get the basic GUI structure working... >_>

but...
you can import the model into blender 2.49 (the version I'm working on),
save a blend file and open it with 2.60 to export a 3DS.
(blender 2.60's exporter is fully functional) ;)


Title: Re: blender mdl0 importer (reboot)
Post by: Hubert Oswell on January 08, 2012, 02:06:55 PM
I support this fully!


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 08, 2012, 02:34:31 PM
thanx :)

now if I can get my compy to stop freezing >:O

uugh...

EDIT:
AAAAAWWWWWWW T_T
the freezing was caused by my video card...

this is such a big deal because
I'm use to using multiple monitors... (3 monitors on 2 cards)

my other card only supports 1 monitor ;_;
and doesn't allow the use of the MBD port
(could at least get away with that)
I can't even play Minecraft now :srs:


here's a tip:
NEVER get a Sparkle Nvidia GE-Force 8400GS
(they don't last long)

this is my 2nd one and it only lasted ~7 months...
(the first one broke upon insertion)


DANGIT!!!
PCI cards are hard to find ;_;
(let alone AGP)

*sigh* this sux... T.T

EDIT2:
well...
I'm relieved... it wasn't my video card...

although now I know it was my MBD -.-*
(it froze again)

so it looks like I need to switch MBD's again :(
DANGIT

the current MBD I have will be hung in a frame and be left to die peacefully...
(yes, it was that good)

luckily I have a decent replacement
(a crappy intel replacement)


Title: Re: blender mdl0 importer (reboot)
Post by: Tabuu Forte Akugun on January 08, 2012, 06:13:45 PM
You totally should start work on it. 3DS Max falls short in many areas.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 08, 2012, 06:56:32 PM
Engineer: alrighty then

as soon as I get my other compy set up ;)

too bad my best one had to blow -.-*


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 07:56:06 AM
just thought I'd notify on what's happening...

sry I'm taking so long to do anything...
I just got my compy running.

sadly though, I can't seem to get it to recognize the sound card >_>

since my Turtle Beach Rivera needs drivers downloaded from the net,
I've decided to install my Creative Sound Blaster...

sadly though it doesn't seem to be recognizing the drivers that come with windows...

so I guess I'm at a (http://i0.kym-cdn.com/photos/images/newsfeed/000/143/193/cad-20080602-358b1.jpg?1309710446) for now until I get net >_>
(I do have my w/less card installed)

I'll notify later if I get anywhere :)
heh... least I can play dolphin again XDD

EDIT:
alright! :D

it's now recognizing the driver ^_^

all that's left to do is finish transferring settings,
and switch my 1st and 4th HDD
(so I don't have to use the boot menu anymore)
^I get tired of having to press Escape to boot my 4th HDD instead of my 1st
(since it bluescreens when trying to boot that OS)


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 09:59:15 AM
info:

well I'm up and running again at more than 95% ;)
I just wish I could get net -.-*

but I can promise you, my next post will be about the script ;)


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 12:53:53 PM
Howdy. So uh.... why are we importing mdl0's to blender anyways?


Title: Re: blender mdl0 importer (reboot)
Post by: Hubert Oswell on January 10, 2012, 12:59:09 PM
I thought this was the alternative to DAE importing. What does this do exactly? (Yes, I read the OP, but it still confuses me)


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 01:08:21 PM
I have quite a few reasons actually...

1 - Blender doesn't blue-screen my compy... >_>
2 - blender scripts are in Python
3 - blender's alot more flexible than 3DS (excluding NURBS),
and I believe it supports more >_>
^don't quote me on that last part though >_>

beside that being the fact,
I'm using 249 only cause I have docs on it...
(I don't have anything for 260, which can I/O 3DS and DAE files quite well)

Brbx exports still don't work in blender though...
(I blame the schema for not being very descriptive)

anyways...
let's get this on shall we ;)
(excuse me... I get hyped over my own ideas) XDD


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 01:13:19 PM
All right then. Which part are you stuck on?


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 01:18:36 PM
All right then. Which part are you stuck on?
well...
doesn't the loader (as it should be) use the Next and Prev ID's??
and IDK but doesn't it also use the GID??

I just need to know how to structure it...

I try to follow the ID's and end up running into an improper loop with the bones >_>
the others loop back to GID: 'FFFF' perfectly (of course) :P

you can prbly tell I'm easily confused here XDD

so yea...
that's what I'm stuck on


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 01:34:49 PM
I'm afraid I don't know many of these terms.... What I do know is how to read Brawlbox's source code. Are you referring to the mdl0 model previewer loader?


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 01:37:53 PM
I'm afraid I don't know many of these terms.... What I do know is how to read Brawlbox's source code. Are you referring to the mdl0 model previewer loader?
oh... sry XDD

I'm talking about the Resource groups.

Brlib/SSBB/Types/common.cs


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 01:57:34 PM
oh... sry XDD

I'm talking about the Resource groups.

Brlib/SSBB/Types/common.cs

I'm surprised you know the Brawlbox source code structure but not how to read it. And yes, it looks like it records the ID and the previous and next values.  Also, what if the error is in your python coding?


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 02:19:50 PM
I'm surprised you know the Brawlbox source code structure but not how to read it.
there's only a handful of things I don't understand with C-types

the main one being pointers >_>

Quote
And yes, it looks like it records the ID and the previous and next values. 
yes, but how is it used??
(that's exactly where I'm confused)


Quote
Also, what if the error is in your python coding?
do you mean my coding style or what I've coded??

the way I've been doing it is using a FOR and keeping an index of everything...


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 02:49:36 PM
there's only a handful of things I don't understand with C-types

the main one being pointers >_>
yes, but how is it used??
(that's exactly where I'm confused)

do you mean my coding style or what I've coded??

the way I've been doing it is using a FOR and keeping an index of everything...

I need to learn these definitions if I want to help program Brawlbox.... by pointers, do you mean the "pointing to the right offset"?

As for how their used, I think that would be best for BJ to explain. I can guess, but my guess isn't any better than BlackJax's explanation. Previous and Entry seem to be used for building the index, while current is used for the if/then arguements.

I meant your coding: We often overlook simple programming errors and look elsewhere for the answer. Perhaps your supposed to detect the loop back and stop, and the rest of your program is still fine?


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 03:43:32 PM
I need to learn these definitions if I want to help program Brawlbox.... by pointers, do you mean the "pointing to the right offset"?

IDK...
all I know is they're called pointers

a pointer (for what I know) is somewhat like a var...

List = *group
or
if List -> group

* is the pointer definition (I think)
and -> means 'points to'

again... all C-type codes confuse me DX

Quote
As for how their used, I think that would be best for BJ to explain. I can guess, but my guess isn't any better than BlackJax's explanation. Previous and Entry seem to be used for building the index, while current is used for the if/then arguements.
I think I understand,
but most of this still goes over my head >_>

I take it the "Entry" is the 'FFFF' GID??
Quote
I meant your coding: We often overlook simple programming errors and look elsewhere for the answer. Perhaps your supposed to detect the loop back and stop, and the rest of your program is still fine?
oh...
I havn't started programming yet XDD

I'm asking just to make sure I can get it right,
instead of having to do it, and then go back and change it like I do with my other 2 things >_>

no there's no errors...
just immature code...
that's all :)

and I think I get what you mean...
instead of the index being:
1
2
3
4
(like how I'm currently reading it)

the right way is:
1
3
4
2


Title: Re: blender mdl0 importer (reboot)
Post by: TheShyGuy on January 10, 2012, 04:10:35 PM
i know a little bit about the bone tree of mdl0s but i can help if you need. Im not sure 100% about what your talking about when you say that you run into an improper loop of bones.

Also, pointers just point to the same data in memory. The only way to have multiple reference of a value is to have pointers(im not 100% since i dont usually use pointers). So :

int val_1 = 5;
int val_2 = val_1;//val_2 == 5

val_2 = 2;
//val_1's value is still 5, val_2's value is 2;

int val_1 = 5;
int* val_2 = val_1;// not sure if its : int*val_2 = &val_1, but thats not really the point
val_2 = 10;

//val_1 also is 10 now. Since val_2 points to the same value in memory as val_1. Simply doing val_2 = val_1 will just copy val_1's value, but not the same place in memory.


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 04:45:45 PM
Im on mobile, so no looking at code for me. The pointer data youre talking about points to the index array. In terms of python coding, instead of previous->array, you might use array[previous].


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 04:50:25 PM
i know a little bit about the bone tree of mdl0s but i can help if you need. Im not sure 100% about what your talking about when you say that you run into an improper loop of bones.

Also, pointers just point to the same data in memory. The only way to have multiple reference of a value is to have pointers(im not 100% since i dont usually use pointers). So :

int val_1 = 5;
int val_2 = val_1;//val_2 == 5

val_2 = 2;
//val_1's value is still 5, val_2's value is 2;

int val_1 = 5;
int* val_2 = val_1;// not sure if its : int*val_2 = &val_1, but thats not really the point
val_2 = 10;

//val_1 also is 10 now. Since val_2 points to the same value in memory as val_1. Simply doing val_2 = val_1 will just copy val_1's value, but not the same place in memory.

hmm, so it's basically the same as:

val3 = 10
val1,val2 = [val3]*2 #[val3,val3]

and about the bone thing...

take a look at Pika's resource group for bones >_>
and just try to follow the prev and next ID's,

tell me what happens when you get to the first GID group of '04'
just try not to get lost XDD

and KK, I'll try that...

EDIT:
wait...
use the previous as an array index??

I thought 'previous' was an array >_>

w/e...
what I'm learning now bamf's my test code...

back to the drawing board for me DX


if I was to paste bits of the code here,
could I get some help on converting it??


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 05:08:52 PM
hey TSG...

int *val2 = &val1

that would make sense
(basically you're saying int(val2 and val1) so when val2 is set, val1 also gets set)

that would be incorrect in python terms but of course...

you underment what I stood :P


Title: Re: blender mdl0 importer (reboot)
Post by: BlackJax96 on January 10, 2012, 05:38:32 PM
Was I called?

Think of * as like a reference to an offset in a hex editor.
Let's say you have

struct Data
{
   int whatever1;
   int whatever2;
}

Data* exampleVar;

Think of * as like an array (Data[]) but with no absolute end.
The size of the Data struct is 8 bytes (two 4-byte ints. Int is a struct of 4 bytes), so when you use "exampleVar++" then the offset will progress 8 bytes forward.

If you want to assign "exampleVar" to a variable that isn't a pointer, you need to say
Data exampleVar2 = *exampleVar;

because exampleVar is simply an offset, not an actual variable. Adding * changes it into a variable.

You can also read the current value and progress forward afterwards with *exampleVar++;

If you want to assign a value within exampleVar, you need to use "exampleVar->whatever1" because you're assigning directly into the memory with a pointer.

Now let's say you have
Data exampleVar3;

In order to set the variables inside exampleVar3, you can just use "exampleVar3.whatever1" because it's not being accessed through a pointer.

But what if you're using a loop?
int[] variables = new int[2];
for (int i = 0; i < 2; i++)
{
   if (i == 0)
      variables[i ] = exampleVar3.whatever1;
   else
      variables[i ] = exampleVar3.whatever2;
}

It works, but it's not as efficient as
int[] variables = new int[2];
for (int i = 0; i < 2; i++)
{
   variables[i ] = ((int*)&exampleVar3)[i ];
}

Which does the exact same thing. (I put a space in [i ] or else it made the text italic lol)

&exampleVar3 is the "offset" of exampleVar3 in the memory.
(int*) changes that offset into an "array" of 4-byte integer values.
[i ] is the indexer that accesses the integers in that array in memory (it progresses every 4 bytes, the size of int).

If you already have Data* exampleVar, then you can use the indexer without getting the address.
exampleVar[i ]


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 10, 2012, 05:49:29 PM
In short.... it just says which byte to look at to decipher.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 10, 2012, 06:20:32 PM
thanx BJ :)

this'll help a bit :P

I'll get a better look at it tomorrow

EDIT:
lol
I feel exactly like I did when Pharrox was trying to teach me about the links XDD


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 11, 2012, 05:52:02 AM
KK...
so I know of a few tricks now with that,
but mind if I ask for small code conversions here and there??

or more like, just explain what it does... >_>
(not conversions) :P


all I need right now is 1 line:
ResourceEntry* list = &group->_first

is there a simpler way to write that??
(not sure what does what first with this way of being written)


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 11, 2012, 03:49:21 PM
I forgot to say that I can convert code well, as long as it can be explained. Now if I'm reading BJ's code snippet correctly, ResourceEntry* list = &group->_first looks like a basic array setup. ResourceEntry list is an array/list with an offset pointing towards group, and the value of group is the value of _first.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 11, 2012, 04:08:23 PM
I forgot to say that I can convert code well, as long as it can be explained. Now if I'm reading BJ's code snippet correctly, ResourceEntry* list = &group->_first looks like a basic array setup. ResourceEntry list is an array/list with an offset pointing towards group, and the value of group is the value of _first.
UUGH I hate not being able to copy/paste
(really wish I had a laptop) >_<

anyways...
look at 'struct ResourceGroup' in Brlib/SSBB/Types/common.cs

sry I took so long to reply...
was looking at YT vids for matrix inversion without a determinant
(it can only be a square matrix sadly) -.-*


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 11, 2012, 05:19:17 PM
You mean this...?

public ResourceEntry* First { get { return (ResourceEntry*)(Address + 0x18); } }

It looks like First is an array containing the value of Address (Void Array of an offset pointing to THIS?) and 0x18. I can't tell if I read the whole code properly.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 11, 2012, 05:37:56 PM
You mean this...?

public ResourceEntry* First { get { return (ResourceEntry*)(Address + 0x18); } }

It looks like First is an array containing the value of Address (Void Array of an offset pointing to THIS?) and 0x18. I can't tell if I read the whole code properly.
oh IK what that does... :P
it gets the list values while skipping the resource group header (0x08) and the null offset (0x10)
(had it explained to me once or twice) :P

I'm still confused as to how it works though XDD

>_>
<_<
I've prbly got that wrong don't I??


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 11, 2012, 05:50:20 PM
No, it sounds like you got it right. The main point is to set up the array to contain/or skip the header data that remains the same throughout every file before reading the relevant data: or if it contains an offset relying on the size of the file or a certain offset location, then it would get the offset or filesize and add it to the array before adding the actual data: in the same fashion as the original file format.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 11, 2012, 07:40:15 PM
No, it sounds like you got it right. The main point is to set up the array to contain/or skip the header data that remains the same throughout every file before reading the relevant data: or if it contains an offset relying on the size of the file or a certain offset location, then it would get the offset or filesize and add it to the array before adding the actual data: in the same fashion as the original file format.
wha??

you know I'm talking about these:
http://forums.kc-mm.com/index.php?topic=34404.msg801215
right??

all I know is _first is the 'FFFF000000010000000000000000' part >_>

I just need to know how to build and read those properly >_>

also...
if I figure these out, I'll be able to start an export plugin ;)
(then people will be able to do anything they want) ;D


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 11, 2012, 09:43:22 PM
wha??

you know I'm talking about these:
[url]http://forums.kc-mm.com/index.php?topic=34404.msg801215[/url]
right??

all I know is _first is the 'FFFF000000010000000000000000' part >_>

I just need to know how to build and read those properly >_>

also...
if I figure these out, I'll be able to start an export plugin ;)
(then people will be able to do anything they want) ;D


Sorry for being late... I just have a hard time understanding which part of the data structure you've been talking about >.<


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 12, 2012, 03:05:34 AM
Sorry for being late... I just have a hard time understanding which part of the data structure you've been talking about >.<
1yeh...
I think that might be my fault >_>

sry bout that :P
(has been misunderstood by many people)


Title: Re: blender mdl0 importer (reboot)
Post by: Xiggah on January 12, 2012, 12:28:51 PM
It's the data structure that you're looking into: data structures that we have fully defined. Perhaps after you and BlackJax's file format threads are done, we can easily relate to the specific parts.


Title: Re: blender mdl0 importer (reboot)
Post by: DarkPikachu on January 12, 2012, 05:51:43 PM
It's the data structure that you're looking into: data structures that we have fully defined. Perhaps after you and BlackJax's file format threads are done, we can easily relate to the specific parts.
yeh... fully defined in code that I can't read, and no notes on it :srs:

yeh, I actually root for BJ on his thread...
he's taking more of the descriptive side where as I'm on more of the coder's side
(helping out programmers)

my methos of approach is useless to most hackers though >_>

anyways...
I just need to know how to list those :/
was I right on guessing the structure??
(I have no idea) XDD

also...
what exactly is the GID used for??
(is it just for generating the index??)