Exemplo n.º 1
0
        private NJS_OBJECT(byte[] file, int address, uint imageBase, ModelFormat format, NJS_OBJECT parent, Dictionary <int, string> labels, Dictionary <int, Attach> attaches)
        {
            if (labels.ContainsKey(address))
            {
                Name = labels[address];
            }
            else
            {
                Name = "object_" + address.ToString("X8");
            }
            ObjectFlags flags = (ObjectFlags)ByteConverter.ToInt32(file, address);

            RotateZYX = (flags & ObjectFlags.RotateZYX) == ObjectFlags.RotateZYX;
            Animate   = (flags & ObjectFlags.NoAnimate) == 0;
            Morph     = (flags & ObjectFlags.NoMorph) == 0;
            int tmpaddr = ByteConverter.ToInt32(file, address + 4);

            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                if (attaches != null && attaches.ContainsKey(tmpaddr))
                {
                    Attach = attaches[tmpaddr];
                }
                else
                {
                    Attach = Attach.Load(file, tmpaddr, imageBase, format, labels);
                    attaches.Add(tmpaddr, Attach);
                }
            }
            Position = new Vertex(file, address + 8);
            Rotation = new Rotation(file, address + 0x14);
            Scale    = new Vertex(file, address + 0x20);
            Parent   = parent;
            children = new List <NJS_OBJECT>();
            Children = new ReadOnlyCollection <NJS_OBJECT>(children);
            NJS_OBJECT child = null;

            tmpaddr = ByteConverter.ToInt32(file, address + 0x2C);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                child   = new NJS_OBJECT(file, tmpaddr, imageBase, format, this, labels, attaches);
            }
            while (child != null)
            {
                children.Add(child);
                child = child.Sibling;
            }
            tmpaddr = ByteConverter.ToInt32(file, address + 0x30);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                Sibling = new NJS_OBJECT(file, tmpaddr, imageBase, format, parent, labels, attaches);
            }

            //Assimp.AssimpContext context = new AssimpContext();
            //Scene scene = context.ImportFile("F:\\untitled.obj", PostProcessSteps.Triangulate);
            //AssimpLoad(scene, scene.RootNode);
        }
Exemplo n.º 2
0
        public NJS_OBJECT(byte[] file, int address, uint imageBase, ModelFormat format, Dictionary <int, string> labels)
        {
            if (labels.ContainsKey(address))
            {
                Name = labels[address];
            }
            else
            {
                Name = "object_" + address.ToString("X8");
            }
            ObjectFlags flags = (ObjectFlags)ByteConverter.ToInt32(file, address);

            RotateZYX = (flags & ObjectFlags.RotateZYX) == ObjectFlags.RotateZYX;
            Animate   = (flags & ObjectFlags.NoAnimate) == 0;
            Morph     = (flags & ObjectFlags.NoMorph) == 0;
            int tmpaddr = ByteConverter.ToInt32(file, address + 4);

            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                Attach  = Attach.Load(file, tmpaddr, imageBase, format, labels);
            }
            Position = new Vertex(file, address + 8);
            Rotation = new Rotation(file, address + 0x14);
            Scale    = new Vertex(file, address + 0x20);
            Children = new List <NJS_OBJECT>();
            NJS_OBJECT child = null;

            tmpaddr = ByteConverter.ToInt32(file, address + 0x2C);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                child   = new NJS_OBJECT(file, tmpaddr, imageBase, format, labels);
            }
            while (child != null)
            {
                Children.Add(child);
                child = child.Sibling;
            }
            tmpaddr = ByteConverter.ToInt32(file, address + 0x30);
            if (tmpaddr != 0)
            {
                tmpaddr = (int)unchecked ((uint)tmpaddr - imageBase);
                Sibling = new NJS_OBJECT(file, tmpaddr, imageBase, format, labels);
            }
        }