• Welcome to Smashboards, the world's largest Super Smash Brothers community! Over 250,000 Smash Bros. fans from around the world have come to discuss these great games in over 19 million posts!

    You are currently viewing our boards as a visitor. Click here to sign up right now and start on your path in the Smash community!

[Modset4.2] Open BrawlBox/Lib Development Thread [PW's SSS support(PAT0 editing)]

SqLeon

Smash Journeyman
Joined
Nov 10, 2009
Messages
491
Location
The world that never was
I didn't think it was that easy..Cause Brawl has it's own folders for Snapshots, replays, and all that. I figured there was a reason for the "pf" folder, otherwise what's the point of making it? I could just make another folder with a different name that would have the same results. Or am I wrong?
the code uses the name pf
 

Altres

Smash Apprentice
Joined
Sep 15, 2010
Messages
79
Hey, i'm 12 and want to learn how to do this stuff, anybody willing to help? :(
 

NO@H

Smash Journeyman
Joined
Jul 11, 2009
Messages
279
wrong place, try here, perfect for 12 year olds

or, if you meant C# editing, see OP, there is good links on learning C#. I suggest learning the basics by making a hello world or something before attempting to edit brawlbox
 

libertyernie

Smash Ace
Joined
Oct 5, 2009
Messages
929
Location
Eau Claire, WI
I noticed the newest version uses .NET framework 4. Is there any way to compile it against an older version so it will run on Linux/Wine?
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
I'm very sorry... You have to rewrite all codes which is using .NET 4.0.

By the way, something is coming soon...
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
I'm sorry but I have to say no.
That thing is for animators.

AI can be understood only by you,I think.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
:laugh:
But I haven't studied vector and matrix,you have to wait for a while.
(in fact, I have tried this for 2 weeks.)
 

Ultraxwing

Smash Ace
Joined
Mar 4, 2010
Messages
615
Location
Peach Lover =3
if we could click and drag bones in the model previewer, i think most model import character's would be doen 3X faster than they originally are being done now.
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
:laugh:
But I haven't studied vector and matrix,you have to wait for a while.
(in fact, I have tried this for 2 weeks.)
Hit-detection can be done by translating the 2d viewport coordinates to 3d model coordinates. The mathematics for this has already been done, and is part of the GLPanel class. Take a look at System.Windows.Forms.CollisionEditor (MouseDown and PostRender events) and BrawlLib.OpenGL.GLPanel (GetDepth and UnProject methods).

What I did in this instance was perform rendering in two parts:
  1. Allow attached scene objects to be rendered normally by the GLPanel.
  2. Add a PostRender event to clear the depth buffer (not the color buffer!) and draw your interactive elements.

What this is essentially doing is splitting up the render sequence into two passes: the first for normal rendering; second for interactive rendering. The difference is in the depth buffer. Since it has been cleared, only interactive objects will have a depth > 1 in the viewport. How do we use this?

When the user clicks the mouse, we can transform that viewport coordinate into 3d space using the UnProject method. We can also get the recorded depth from within the depth buffer by using the GetDepth method. What you do is first get the depth value for the mouse point. If the depth is > 1 we know we've clicked on an interactive object. Then, pass that depth value along with the mouse position to UnProject, which will give you the world coordinates of that point at that depth.

Proceed to search through your objects and find one that most closely matches that point. Examples can't be given here since SSBB collision objects are all two-dimensional. However, there should be some useful functions in the Vector3 class.

You could combine this with colors to determine what types of objects were selected. OpenGL has a method for getting screen colors. Just make sure they are unique and opaque.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
Thanks for informations! I can now understand your way in collision editor.

At first, I tried to do the same way of Collision Editor. But because I didn't make sense of it, I decided to use "Selection Mode".
I managed to make selection system 10 days ago, but I have a trouble with "drag-and-drop" function.
Because each bones have different rotation and coordinates, I can't find a good way to rotate bones.

Would you do me a favor and tell me some hints to do that?
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
Thanks for informations! I can now understand your way in collision editor.

At first, I tried to do the same way of Collision Editor. But because I didn't make sense of it, I decided to use "Selection Mode".
I managed to make selection system 10 days ago, but I have a trouble with "drag-and-drop" function.
Because each bones have different rotation and coordinates, I can't find a good way to rotate bones.

Would you do me a favor and tell me some hints to do that?
Tips:

  • Remember that a bone segment consists of a line then a point.
  • Transformations occur in this order: translate, rotate, scale.
  • When you rotate a bone, you are making changes to the child bones. Even though the node rotates, translation has already been applied and doesn't affect the node's location.
  • To get the world position of a bone, use its bind/frame matrix. The values in the 4th column are the XYZ coordinates.

After hit-detection, highlight the bone node and render a sphere around it. You can use the bone's Frame Matrix to achieve a local coordinate system (just multiply this to the modelview matrix). Once in a local coordinate system, you can simply render the sphere. You don't need to apply any other changes to it, the matrix does all the work for you!

Once you have a bone chosen and a sphere to render, use the same two-pass depth buffer trick. This time, you're going to hit-detect the sphere first. To make tings easier, you may consider setting the depth buffer exclusively for the sphere. Any depth value < 1 means the user did not click the sphere, and you can cancel the selection.

Once you have the world-coordinates of the user-selected point, transform this to the bone's local coordinates using its Inverse Frame Matrix (just multiply the point by the matrix). Now that we have a local point, the rest is fairly easy. When the user FIRST clicks the sphere, do two things:

  1. Calculate the XYZ angles of the clicked point using trigonometry. (these will be your origin angles)
  2. Use these angles to determine axis-snapping. (If the x-axis is the only one with an angle, we can safely snap to it)

As the user moves the mouse around, repeat the point+depth -> local point process. Calculate the XYZ angles each time, and subtract the origin angles. This will give you an 'angle offset', for which you can apply to the FrameState or AnimationFrame (just add them together).
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
Thanks again!

I didn't notice that I have to multiply Inverse Frame Matrix of only selected bone.
I'll give it a try!
 

Shadic

Alakadoof?
Joined
Dec 18, 2003
Messages
5,695
Location
Olympia, WA
NNID
Shadoof
Bero - Is there any chance you could make two buttons that only copy/paste the bone translations for one frame?

It would make porting animations between characters incredibly simple, instead of 40 minutes of tedious copy/paste.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
@Shadic
BrawlBox will have that function in next update.

@Kryal
I'm not sure if you see this...

I tried to do what you said but things don't go well...
This is my code:
Code:
        /// <summary>
        /// Calculate angle of clicked position
        /// </summary>
        /// <param name="x">X coordinate of mouse</param>
        /// <param name="y">Y coordinate of mouse</param>
        /// <returns>Vector which contains xyz angle</returns>
        private Vector3 CalcAngle(int x, int y)
        {
            Vector3 vec = new Vector3();

            var depth = GetDepth(x, y);
            var point = UnProject(x, y, depth);

            point = ((MDL0BoneNode)SelectedBone.Parent)._frameState._iTransform * point;
            vec._x = (float)(Math.Atan(Math.Atan2(point._y, point._z)) * 180 / Math.PI);
            vec._y = (float)(Math.Atan(Math.Atan2(point._z, point._x)) * 180 / Math.PI);
            vec._z = (float)(Math.Atan(Math.Atan2(point._x, point._y)) * 180 / Math.PI);
            return vec;
        }
I think world->local translating isn't working well. Is iTransform is the thing which you called "Inverse Frame Matrix"?
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
Oops, you're right. There is no inverse frame matrix. Those FrameState structs are all relative, so you can't use those. You will need to create an inverse frame matrix. Look at RecalcBindState and ApplyCHR0. Suggestions:

  • Split ApplyCHR0 into two functions. One for actually retrieving the FrameState, and one for recalculating the matrices.
  • Any time you change the FrameState, you need to recalculate the Influence matrices and re-weight the vertices. (Look at ApplyCHR in MDL0Node)
  • When you get this working, test free-rotation without the z angle. When you have three axis of rotation, circular movement can cause the angles to progressively deviate. This is why cameras usually use two axis instead of three.

Your trig looks good. I would double-check the z angle.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
@Kryal
Thanks for all information, but I still failed to make this(I may be making mistakes)
Bones seem to follow mouse, but move is awkward and they goes everywhere...


Well, because I have little time to do this, it takes long time to achieve this function.
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
Yeah, it's harder in practice because something always goes awry. Sporadic and irregular movement is usually caused by a corrupt matrix. If the vertices act as expected then you're halfway there, because you know the vertices have been weighted properly.

If I get a chance I'll look at it this weekend and try getting some code together.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
That sounds great !
It seems that I have to fix my very dirty codes and commit them...
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
Okay, I got mouse-picking and angle calculations for bones. Of course, it is a little more involved than I originally thought. I will update the BrawlTools SVN when I finish and you can just cut-paste the changes. You don't have to worry about committing.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
HaHa! That's just what one would expect of Kryal!
I will be able to study a lot from your code.
 

Eternal Yoshi

I've covered ban wars, you know
Joined
Mar 3, 2007
Messages
5,450
Location
Playing different games
NNID
EternalYoshi
3DS FC
3394-4459-7089
How do you make something that was not editable in Brawlbox editable?

I'm talking mainly about the colors section of Mdl0s.

I'm trying to recolor Tabuu, but there are hundreds of Color values and editing them by hex is difficult since each entry is only 2 bytes.
 

Kryal

Smash Ace
Joined
May 28, 2009
Messages
560
Okay, almost done. I need to tweak a few more things and then I'll post the code. Probably in the next few days or so.
 

Bero

Smash Journeyman
Joined
Jan 10, 2010
Messages
409
Location
Japan
(I thought you had already done by 10-31-2010)

I'm looking forward to seeing your code! Well,I have to begin making other new functions...
 

Eternal Yoshi

I've covered ban wars, you know
Joined
Mar 3, 2007
Messages
5,450
Location
Playing different games
NNID
EternalYoshi
3DS FC
3394-4459-7089
Why not this one?

Code:
PAT0

Header:
char[4] PAT0
int Runtime Copy Range
int unk
int unk
int Pattern Table offset
int Texture File Table offset
int Palette File Table offset
int Runtime Texture Ptr Table offset
int Runtime Palette Ptr Table offset
int File Name Table offset
int pad
short unk //0x006F
short unk //0x0001
short Runtime Texture Ptr Table Count
short Runtime Palette Ptr Table Count
int pad

*Runtime Copy Range is the length of the Header, 
 Entry Table, both String Offset Tables and the Runtime Ptr Tables.
 This is usually the address of the String Table, but sometimes
 there's a bit discarded before it as well...
**The amount of available space in the Runtime Tables
  MUST reflect their Counts (in entries of 32-bit integers).


Pattern Table:
int Total Length
int Entry Index Count
int unk
int unk
int unk
Entry Indices

Pattern Index:
int unk
int unk
int Name Offset (base=this)
int Entry Offset (base=Entry Table)

Pattern:
int Name Offset (base=this)
bit[8][4] Flagsets
int Texture Table Offset(base=this)

Flags:
0x1 Use Flagset
0x2 Inline Texture
0x4 Has Texture
0x8 Has Palette

*There are 8 Flagsets (one  32-bit int) that will each be attempted
 if their first bit is set - usually the first one is only used.
**When InlineTexture is set, Texture Table Offset becomes:
  short Texture Name Index
  short Palette Name Index



Texture Table:
short Texture Count
short pad
int unk
Textures

Texture:
float Key
short Texture File Index
short Palette File Index



Texture File Table Entry:
int File Name offset(base=Texture File Table)

Palette File Table Entry:
int File Name offset(base=Palette File Table)
Taken from PW's post.
"Provide Brawlbox with support for the PAT0 files and you'll be able to add new stage icons in addition to the default ones using the Custom Stage Select Screen code."
 

pikazz

Smash Lord
Joined
Dec 6, 2009
Messages
1,868
Location
Sweden, Umeå (Currently in Seattle)
NNID
pikamaxi
Why not this one?

Code:
PAT0

Header:
char[4] PAT0
int Runtime Copy Range
int unk
int unk
int Pattern Table offset
int Texture File Table offset
int Palette File Table offset
int Runtime Texture Ptr Table offset
int Runtime Palette Ptr Table offset
int File Name Table offset
int pad
short unk //0x006F
short unk //0x0001
short Runtime Texture Ptr Table Count
short Runtime Palette Ptr Table Count
int pad

*Runtime Copy Range is the length of the Header, 
 Entry Table, both String Offset Tables and the Runtime Ptr Tables.
 This is usually the address of the String Table, but sometimes
 there's a bit discarded before it as well...
**The amount of available space in the Runtime Tables
  MUST reflect their Counts (in entries of 32-bit integers).


Pattern Table:
int Total Length
int Entry Index Count
int unk
int unk
int unk
Entry Indices

Pattern Index:
int unk
int unk
int Name Offset (base=this)
int Entry Offset (base=Entry Table)

Pattern:
int Name Offset (base=this)
bit[8][4] Flagsets
int Texture Table Offset(base=this)

Flags:
0x1 Use Flagset
0x2 Inline Texture
0x4 Has Texture
0x8 Has Palette

*There are 8 Flagsets (one  32-bit int) that will each be attempted
 if their first bit is set - usually the first one is only used.
**When InlineTexture is set, Texture Table Offset becomes:
  short Texture Name Index
  short Palette Name Index



Texture Table:
short Texture Count
short pad
int unk
Textures

Texture:
float Key
short Texture File Index
short Palette File Index



Texture File Table Entry:
int File Name offset(base=Texture File Table)

Palette File Table Entry:
int File Name offset(base=Palette File Table)
Taken from PW's post.
"Provide Brawlbox with support for the PAT0 files and you'll be able to add new stage icons in addition to the default ones using the Custom Stage Select Screen code."
this might be handy by looking for the rest in PAT0 hacking :D
 

Tiberious

Smash Journeyman
Joined
Jun 5, 2009
Messages
250
Umm, thread's gotten TL;DR, but what's the status on exporting in BrawlBox? I hadn't had much luck with anything, but for the most part, the converter Pharrox made usually works (with those 3 notable exceptions in the Alloys).

Also, has there been any thought given to showing weighting information for models? As in... well, think like the Weight Paint mode in Blender. It shows (and allows editing of) weighting for various bones. Being able to see that kind of detailed information will be very helpful in getting my rigging right in a virtual world.
 

Eternal Yoshi

I've covered ban wars, you know
Joined
Mar 3, 2007
Messages
5,450
Location
Playing different games
NNID
EternalYoshi
3DS FC
3394-4459-7089
It's going to be a long time before we get to that.
As of now, if you look at the previous posts, there are clues that soon we will be able to drag and drop bones with the mouse in the model viewer, making animation making much faster.

Also the PAT0 format.
 

AMKalmar

Smash Ace
Joined
Mar 10, 2009
Messages
887
Location
Hamilton ON CA
Any reason why I can't import a colour animation (CLR0) into a brres the same way I can import a model, animation, or texture?
 

Mewtwo_2000

Smash Lord
Joined
Nov 23, 2009
Messages
1,177
Location
Spain
NNID
Mewtwo2ooo
3DS FC
0877-0152-2009
Any reason why I can't import a colour animation (CLR0) into a brres the same way I can import a model, animation, or texture?
Yeah, that's something that needs to be fixed I guess, as well as renaming the CLR0s you have.

Anyway, if you need importing any colour animation into a brres file, send me both the brres and the CLR0 via PMand I will do it for ya. I have some tricks by hex editing, similar to what I used when the 'add model' option was glitchy.
 
Top Bottom