Home Gallery Resources The Team Rules chat Login Register
Pages:  1 2 3 4 [5] 6 7 8 ... 25
Author Topic: Bone Tree Editor- development thread : Version 1.1 released  (Read 98865 times)
0 Members and 2 Guests are viewing this topic.
TheShyGuy
Holy Kitten
*
Offline Offline

Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #60 on: December 07, 2010, 08:17:46 PM »


    nice...i tried to make a 2d physics engine(when I was still very new to xna and c#...faiiil lool

    how far did you get on that engine and btw your code has errors
    Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #61 on: December 07, 2010, 08:30:21 PM »


    nice...i tried to make a 2d physics engine(when I was still very new to xna and c#...faiiil lool

    how far did you get on that engine and btw your code has errors

    I failed... (got caught up in this crap) Tongue

    and errors you say Shocked
    like what errors??

    also, don't forget, the code is unfinished Wink
    I guess yur kinda a beta tester Tongue
    Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    TheShyGuy
    Holy Kitten
    *
    Offline Offline

    Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #62 on: December 07, 2010, 08:31:40 PM »


    lemme put it back in c# ill edit this post in a sec
    Code:
    Error	1	Character '&', hexadecimal value 0x26 is illegal in an XML name.	C:\Users\\_mdl0.xml	283	35	Miscellaneous Files
    Error 4 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 301 35 Miscellaneous Files
    Error 7 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 319 35 Miscellaneous Files
    Error 10 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 337 35 Miscellaneous Files
    Error 13 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 355 35 Miscellaneous Files
    Error 16 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 373 35 Miscellaneous Files
    Error 19 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 391 35 Miscellaneous Files
    Error 22 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 409 35 Miscellaneous Files
    Error 25 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 427 35 Miscellaneous Files
    Error 28 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 445 35 Miscellaneous Files
    Error 31 Character '&', hexadecimal value 0x26 is illegal in an XML name. C:\Users\\_mdl0.xml 463 36 Miscellaneous Files
    Error 3 Entity '&' not defined. C:\Users\\_mdl0.xml 283 35 Miscellaneous Files
    Error 6 Entity '&' not defined. C:\Users\\_mdl0.xml 301 35 Miscellaneous Files
    Error 9 Entity '&' not defined. C:\Users\\_mdl0.xml 319 35 Miscellaneous Files
    Error 12 Entity '&' not defined. C:\Users\\_mdl0.xml 337 35 Miscellaneous Files
    Error 15 Entity '&' not defined. C:\Users\\_mdl0.xml 355 35 Miscellaneous Files
    Error 18 Entity '&' not defined. C:\Users\\_mdl0.xml 373 35 Miscellaneous Files
    Error 21 Entity '&' not defined. C:\Users\\_mdl0.xml 391 35 Miscellaneous Files
    Error 24 Entity '&' not defined. C:\Users\\_mdl0.xml 409 35 Miscellaneous Files
    Error 27 Entity '&' not defined. C:\Users\\_mdl0.xml 427 35 Miscellaneous Files
    Error 30 Entity '&' not defined. C:\Users\\_mdl0.xml 445 35 Miscellaneous Files
    Error 33 Entity '&' not defined. C:\Users\\_mdl0.xml 463 36 Miscellaneous Files
    Error 2 Expecting ';'. C:\Users\\_mdl0.xml 283 36 Miscellaneous Files
    Error 5 Expecting ';'. C:\Users\\_mdl0.xml 301 36 Miscellaneous Files
    Error 8 Expecting ';'. C:\Users\\_mdl0.xml 319 36 Miscellaneous Files
    Error 11 Expecting ';'. C:\Users\\_mdl0.xml 337 36 Miscellaneous Files
    Error 14 Expecting ';'. C:\Users\\_mdl0.xml 355 36 Miscellaneous Files
    Error 17 Expecting ';'. C:\Users\\_mdl0.xml 373 36 Miscellaneous Files
    Error 20 Expecting ';'. C:\Users\\_mdl0.xml 391 36 Miscellaneous Files
    Error 23 Expecting ';'. C:\Users\\_mdl0.xml 409 36 Miscellaneous Files
    Error 26 Expecting ';'. C:\Users\\_mdl0.xml 427 36 Miscellaneous Files
    Error 29 Expecting ';'. C:\Users\\_mdl0.xml 445 36 Miscellaneous Files
    Error 32 Expecting ';'. C:\Users\\_mdl0.xml 463 37 Miscellaneous Files


    it goes

    error/description/file/line/column/project

    edit: btw why is bounds relocation offset and relocation group all the same but you gave em different names?
    « Last Edit: December 07, 2010, 08:38:54 PM by theshyguy » Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #63 on: December 07, 2010, 08:46:56 PM »


    I don't see why you don't just edit the xml using notepad :/

    as for those 3 things:


    also, I'm gonna lose net in a few moments so don't be surprise if I don't reply for a while...

    EDIT: this is how those 3 things are used:
    « Last Edit: October 05, 2022, 08:42:46 PM by DarkPikachu » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #64 on: December 08, 2010, 02:08:10 PM »


    hey, a little something I figured out:

    the P3 offset is the textures used by the material

    the P4 offset is for IDK yet

    the data offset prbly contains the colors Cheesy
    (Green thunder, here I come) >:3
    Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    TheShyGuy
    Holy Kitten
    *
    Offline Offline

    Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #65 on: December 08, 2010, 03:04:57 PM »


    how do you figure out whats for what?...would help to know where or atleast how your figuring out the mdl0..btw im not working on the editor or looking at the mdl0 right now...just animating a bit for my psa
    Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #66 on: December 08, 2010, 03:36:16 PM »


    how do you figure out whats for what?
    ...would help to know where or atleast how your figuring out the mdl0...

    Pharrox (along with about 2 others) and scattered notes were a big help...
    I figured out the colors on my own

    I'm working on materials right now (the most complicated thing)
    ^I'm using only knowledge of what I know about dev-ing games to figure the out unknown stuff

    and the rest of the stuff I know just simply comes from working with other 3D formats such as .obj or .dae
    I think I may have found the ambient, diffuse, and specular colors AWESOME 2.0!


    I'm still trying to figure out the P4 and P5 offset stuff
    P4 is nonexistant '00 00 00 00' while P5 offsets to bare data (no defined header)

    also, all this data is mixed in with eachother due to it being called by the materials using it...
    so material extension data isn't lined up over-top of one another like the rest of the file data

    EDIT:
    materials2 (prbly shaders) will be a tough and painful one to figure out DX
    « Last Edit: October 05, 2022, 08:53:48 PM by DarkPikachu » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #67 on: December 08, 2010, 05:55:43 PM »


    here's what I know of materials so far:


    it's easier to explain with images Tongue
    « Last Edit: October 05, 2022, 08:52:14 PM by DarkPikachu » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    TheShyGuy
    Holy Kitten
    *
    Offline Offline

    Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #68 on: December 08, 2010, 06:07:02 PM »


    i wrote in a notepad...and it looks like my new idea might work =)... there wont be a need for move up/down or editing from txt boxes for the bone offset...just plain moving it within the (sortof) tree...
    Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #69 on: December 08, 2010, 06:13:50 PM »


    O.o
    you mean like a fully interactive index change?? (click/drag)

    I need to add bones to my char though
    ^(TopN, HipN, ThrowN, etc... (all the important bones))
    Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    TheShyGuy
    Holy Kitten
    *
    Offline Offline

    Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #70 on: December 08, 2010, 06:21:12 PM »


    yeah basically you can move your bone anywhere you want...ill work on figuring adding bones...but that would mean redoing the mdl0 right?->fortwaffles made a bone(fake) adder and it doubles the mdl0 size. I think i read that he just repointed some data around or something

    edit: lol new idea shouldnt take long to make
    « Last Edit: December 08, 2010, 06:25:19 PM by theshyguy » Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #71 on: December 08, 2010, 06:28:10 PM »


    yeah basically you can move your bone anywhere you want...ill work on figuring adding bones...but that would mean redoing the mdl0 right?->fortwaffles made a bone(fake) adder and it doubles the mdl0 size. I think i read that he just repointed some data around or something

    didn't you say you've added bones?? :/
    or did I mistake that for you just simply editing the existing ones??

    and I tried fortwaffles...
    I couldn't work with that...
    granted they did show up as editable bones:


    but when I checked the data, there was nothing there :/
    I think it may have just modded the number of bones without physically adding them...
    « Last Edit: October 05, 2022, 08:50:41 PM by DarkPikachu » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    TheShyGuy
    Holy Kitten
    *
    Offline Offline

    Posts: 1003


  • Awards Super Saiyan Topic KCMM Veteran Heart Container Dedicated Hacker

  • View Profile Awards
    « Reply #72 on: December 08, 2010, 06:30:57 PM »


    the bone tree that you see is farther down in the data. It looks like any other bone(i think..been a while since i looked at it)

    i don't think ive ever said i can add bones lol...you know the mdl0 so you should know what makes them real lol
    Logged

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #73 on: December 08, 2010, 06:42:34 PM »


    the bone tree that you see is farther down in the data. It looks like any other bone(i think..been a while since i looked at it)

    i don't think ive ever said i can add bones lol...you know the mdl0 so you should know what makes them real lol

    heh... yea Tongue

    I guess what I originally thought was right then Tongue
    *comes to realization* DERP!

    so you wern't talking about physically adding bones,
    which would be a good reason for you not understanding what the relocation table is...
    ...I have so derp'd... XDD

    so yea...
    with that understood Tongue
    you'd have to modify the following data offsets after the added bone...
    ...aw crap...
    (practically redoing the entire MDL0 (editing the offsets))... Sad

    none of us are that far yet... DX>
    dang...

    well...
    I say we learn then Tongue
    since I don't have a clue about C# and can't prog a GUI for crap,
    ^but understand most of the MDL0 format (still not everything though)
    while you don't get anything but bones, but can prog GUI's for crap Cheesy

    guess I'd better get busy =3=
    « Last Edit: December 08, 2010, 06:43:49 PM by Tcll » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    DarkPikachu
    Angel Kitten
    ***
    Offline Offline

    Posts: 3069


    complexity == fun

  • Awards Super Saiyan Topic Heart Container KCMM Veteran Tutorial Writer

  • View Profile Awards
    « Reply #74 on: December 08, 2010, 07:50:52 PM »


    hey, can you maybe help me out a little??
    (I'll be in bed or in skool before you can really do anything) Tongue

    I have some C# code, and I was wondering if you couldn't take a look at it...
    maybe add descriptive comments and what not and send it back...

    anyways:
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ComponentModel;
    using BrawlLib.SSBBTypes;
    using BrawlLib.OpenGL;
    using System.IO;
    using BrawlLib.IO;
    using BrawlLib.Imaging;
    using BrawlLib.Modeling;
    using BrawlLib.Wii.Models;

    namespace BrawlLib.SSBB.ResourceNodes
    {
        public unsafe class MDL0Node : BRESEntryNode
        {
            internal MDL0* Header { get { return (MDL0*)WorkingUncompressed.Address; } }

            public override ResourceType ResourceType { get { return ResourceType.MDL0; } }

            public override int DataAlign { get { return 0x20; } }

            private int _unk1, _unk2, _unk3, _unk4, _version;
            private int _numVertices, _numFaces, _numNodes;
            private Vector3 _min, _max;

            [Category("MDL0 Def")]
            public int Unknown1 { get { return _unk1; } set { _unk1 = value; } }
            [Category("MDL0 Def")]
            public int Unknown2 { get { return _unk2; } set { _unk2 = value; } }
            [Category("MDL0 Def")]
            public int NumVertices { get { return _numVertices; } set { _numVertices = value; } }
            [Category("MDL0 Def")]
            public int NumFaces { get { return _numFaces; } set { _numFaces = value; } }
            [Category("MDL0 Def")]
            public int Unknown3 { get { return _unk3; } set { _unk3 = value; } }
            [Category("MDL0 Def")]
            public int NumNodes { get { return _numNodes; } set { _numNodes = value; } }
            [Category("MDL0 Def")]
            public int Version { get { return _version; } set { _version = value; } }
            [Category("MDL0 Def")]
            public int Unknown4 { get { return _unk4; } set { _unk4 = value; } }
            [Category("MDL0 Def")]
            public BVec3 BoxMin { get { return _min; } set { _min = value; } }
            [Category("MDL0 Def")]
            public BVec3 BoxMax { get { return _max; } set { _max = value; } }

            //internal List<ResourceNode> _bones;
            //private List<MDL0PolygonNode> _polygons;
            public T FindResource<T>(int index) where T : ResourceNode
            {
                ResourceNode group = null;
                if (typeof(T) == typeof(MDL0PolygonNode))
                    group = FindChild("Polygons", false) as ResourceNode;
                else if (typeof(T) == typeof(MDL0VertexNode))
                    group = FindChild("Vertices", false) as ResourceNode;
                else if (typeof(T) == typeof(MDL0NormalNode))
                    group = FindChild("Normals", false) as ResourceNode;
                else if (typeof(T) == typeof(MDL0UVNode))
                    group = FindChild("UV Points", false) as ResourceNode;
                else if (typeof(T) == typeof(MDL0ColorNode))
                    group = FindChild("Colors", false) as ResourceNode;
                else if (typeof(T) == typeof(MDL0BoneNode))
                {
                    int count = -1;
                    if ((group = FindChild("Bones", false) as MDL0GroupNode) != null)
                        return FindBone(group, index, ref count) as T;
                }

                if (group == null)
                    return null;

                if (group.Children.Count <= index)
                    return null;

                return group.Children[index] as T;
            }
            private ResourceNode FindBone(ResourceNode node, int index, ref int count)
            {
                if (count++ >= index)
                    return node;

                foreach (ResourceNode n in node.Children)
                    if ((node = FindBone(n, index, ref count)) != null)
                        return node;

                return null;
            }

            protected override bool OnInitialize()
            {
                base.OnInitialize();

                if ((_name == null) && (Header->_stringOffset != 0))
                    _name = Header->ResourceString;

                _unk1 = Header->_modelDef._unk1;
                _unk2 = Header->_modelDef._unk2;
                _numVertices = Header->_modelDef._numVertices;
                _numFaces = Header->_modelDef._numFaces;
                _unk3 = Header->_modelDef._unk3;
                _numNodes = Header->_modelDef._numNodes;
                _version = Header->_modelDef._version;
                _unk4 = Header->_modelDef._unk4;
                _min = Header->_modelDef._minExtents;
                _max = Header->_modelDef._maxExtents;

                return true;
            }

            private List<IMatrixProvider> _nodes = new List<IMatrixProvider>();
            internal List<ResourceNode> _bones = new List<ResourceNode>();
            internal List<TextureRef> _texRefs = new List<TextureRef>();

            protected override void OnPopulate()
            {
                ResourceGroup* group;
                for (int i = 0; i < 11; i++)
                    if ((group = Header->GetEntry(i)) != null)
                        new MDL0GroupNode().Initialize(this, new DataSource(group, 0), i);

                MDL0GroupNode bNode = FindChild("Bones", false) as MDL0GroupNode;
                MDL0GroupNode pNode = FindChild("Polygons", false) as MDL0GroupNode;
                MDL0GroupNode mNode = FindChild("Materials1", false) as MDL0GroupNode;
                MDL0GroupNode t1Node = FindChild("Textures1", false) as MDL0GroupNode;
                MDL0GroupNode t2Node = FindChild("Textures2", false) as MDL0GroupNode;
                MDL0DefNode nodeMix = FindChild("Definitions/NodeMix", false) as MDL0DefNode;
                MDL0DefNode drawOpa = FindChild("Definitions/DrawOpa", false) as MDL0DefNode;
                MDL0DefNode drawXlu = FindChild("Definitions/DrawXlu", false) as MDL0DefNode;

                //IMatrixProvider[] nodeCache = new IMatrixProvider[NumNodes];
                _nodes = new List<IMatrixProvider>(new IMatrixProvider[NumNodes]);

                //Pull out bones
                //foreach (MDL0BoneNode bone in _boneCache)
                //    nodeCache[bone.NodeId] = bone;
                if (bNode != null)
                {
                    _bones = bNode.Children;
                    foreach (MDL0BoneNode b in bNode._nodeCache)
                        _nodes[b.NodeId] = new NodeRef(b);

                    //Pull out node groups
                    if (nodeMix != null)
                        foreach (object o in nodeMix.Items)
                            if (o is MDL0Node3Class)
                            {
                                MDL0Node3Class d = o as MDL0Node3Class;
                                NodeRef nref = new NodeRef();

                                foreach (MDL0NodeType3Entry e in d._entries)
                                    nref._entries.Add(new NodeWeight(_nodes[e._id], e._value));

                                _nodes[d._id] = nref;
                            }

                    //Attach opaque textures
                    if (drawOpa != null)
                    {
                        foreach (object o in drawOpa.Items)
                            if (o is MDL0NodeType4)
                            {
                                MDL0NodeType4 d = (MDL0NodeType4)o;
                                MDL0PolygonNode poly = pNode.Children[d._polygonIndex] as MDL0PolygonNode;
                                poly._material = mNode.Children[d._materialIndex] as MDL0MaterialNode;
                            }
                    }

                    //Attach transparent textures
                    //Parse entry 4?
                    if (drawXlu != null)
                    {
                        foreach (object o in drawXlu.Items)
                            if (o is MDL0NodeType4)
                            {
                                MDL0NodeType4 d = (MDL0NodeType4)o;
                                MDL0PolygonNode poly = pNode.Children[d._polygonIndex] as MDL0PolygonNode;
                                poly._material = mNode.Children[d._materialIndex] as MDL0MaterialNode;
                            }
                    }

                    bNode._nodeCache = null;
                }


                //Link polygons to nodes
                if (pNode != null)
                    foreach (MDL0PolygonNode n in pNode.Children)
                        if (n.NodeId >= 0)
                            n._singleBind = _nodes[n.NodeId];

                //Get texture references and attach them to texture nodes
                if (t1Node != null)
                    foreach (MDL0TextureNode t in t1Node.Children)
                        _texRefs.Add(t._textureReference = new TextureRef(t.Name));
                if (t2Node != null)
                    foreach (MDL0TextureNode t in t2Node.Children)
                    {
                        TextureRef tref = null;
                        foreach (TextureRef tr in _texRefs)
                            if (tr.Name == t.Name)
                            { tref = tr; break; }
                        if (tref == null)
                            _texRefs.Add(tref = new TextureRef(t.Name));
                        t._textureReference = tref;
                    }

                //Attach material refs to texture refs
                if (mNode != null)
                    foreach (MDL0MaterialNode mat in mNode.Children)
                        foreach (MDL0MaterialRefNode mref in mat.Children)
                            foreach (TextureRef tref in _texRefs)
                                if (tref.Name == mref.Name)
                                {
                                    mref._textureReference = tref;
                                    break;
                                }

                //Attach texture nodes to materials


                //Clear caches
                //_boneCache.Clear();

            }

            internal override void GetStrings(StringTable table)
            {
                table.Add(Name);
                foreach (MDL0GroupNode n in Children)
                    n.GetStrings(table);
            }

            public override unsafe void Export(string outPath)
            {
                if (outPath.EndsWith(".dae"))
                {
                    //Model model = GetModel();
                    //Collada.Serialize(new object[] { model }, outPath);
                }
                else
                    base.Export(outPath);
            }

            protected internal override void PostProcess(VoidPtr bresAddress, VoidPtr dataAddress, int dataLength, StringTable stringTable)
            {
                base.PostProcess(bresAddress, dataAddress, dataLength, stringTable);

                MDL0* header = (MDL0*)dataAddress;
                header->ResourceStringAddress = stringTable[Name] + 4;

                foreach (MDL0GroupNode node in Children)
                {
                    VoidPtr addr = dataAddress + header->Offsets[node._index];
                    node.PostProcess(addr, stringTable);
                }
            }

            #region Rendering

            internal bool _bound = false;
            internal bool _renderPolygons = true;
            internal bool _renderPolygonsWireframe = false;
            internal bool _renderBones = true;

            internal void Render(GLContext ctx)
            {
                if (!_bound)
                    Bind(ctx);

                ResourceNode group;

                if (_renderPolygons)
                {
                    ctx.glEnable(GLEnableCap.Lighting);
                    ctx.glEnable(GLEnableCap.DepthTest);
                    if (_renderPolygonsWireframe)
                        ctx.glPolygonMode(GLFace.FrontAndBack, GLPolygonMode.Line);
                    else
                        ctx.glPolygonMode(GLFace.FrontAndBack, GLPolygonMode.Fill);

                    if ((group = FindChild("Polygons", false)) != null)
                        foreach (MDL0PolygonNode poly in group.Children)
                            poly.Render(ctx);
                }

                if (_renderBones)
                {
                    ctx.glDisable((uint)GLEnableCap.Lighting);
                    ctx.glDisable((uint)GLEnableCap.DepthTest);
                    ctx.glPolygonMode(GLFace.FrontAndBack, GLPolygonMode.Line);

                    if ((group = FindChild("Bones", false)) != null)
                        foreach (MDL0BoneNode bone in group.Children)
                            bone.Render(ctx);
                }
            }

            internal void ApplyCHR(CHR0Node node, int index)
            {
                //Transform bones
                ResourceNode group = FindChild("Bones", false);
                if (group != null)
                {
                    foreach (MDL0BoneNode b in group.Children)
                        b.ApplyCHR0(node, index);
                }

                //Transform nodes
                foreach (NodeRef nr in _nodes)
                    nr.CalcBase();
                foreach (NodeRef nr in _nodes)
                    nr.CalcWeighted();

                //Weight vertices
                if ((group = FindChild("Polygons", false)) != null)
                    foreach (MDL0PolygonNode poly in group.Children)
                        poly.WeightVertices(_nodes);
            }

            private void Bind(GLContext ctx)
            {
                _bound = true;
                foreach (MDL0GroupNode g in Children)
                    g.Bind(ctx);
            }

            internal void Unbind(GLContext ctx)
            {
                _bound = false;
                foreach (MDL0GroupNode g in Children)
                    g.Unbind(ctx);
            }

            #endregion

            internal static ResourceNode TryParse(DataSource source) { return ((MDL0*)source.Address)->_entry._tag == MDL0.Tag ? new MDL0Node() : null; }

            internal void ResetTextures()
            {
                foreach (TextureRef tref in _texRefs)
                    tref.Reload();
            }
        }
    }

    do what you can Wink
    any help is good Cheesy
    (btw, this is another way I figure out stuff)

    note: I can't understand C... code
    so I kinda have to have someone translate it or comment it so I can read it...

    EDIT:
    hey, this'll prbly help with some stuff: (maybe not) :/
    http://www.mediafire.com/?61mtbcgqv3la19s (modset 4.0)
    « Last Edit: December 08, 2010, 08:10:10 PM by Tcll » Logged


    Quote: Friedslick6
    you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
    But the coolest part was that you didn't stop working on it despite that.

    Quote: Internet Explorer
    you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

    quote: Greg
    You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

    Pages:  1 2 3 4 [5] 6 7 8 ... 25
    Print
    Jump to: