Example #1
0
        public Model Convert()
        {
            var mb = new ModelLoader.ModelBase();

            foreach (TCNModel x in Models)
            {
                foreach (TCNFolder y in x.Geometry)
                {
                    foreach (TCNShape z in y.Shapes)
                    {
                        mb.textureWidth  = (int)x.TextureSize.X;
                        mb.textureHeight = (int)x.TextureSize.Y;

                        if (z.RenderData == null)
                        {
                            continue;
                        }

                        if (z.RenderData is TCNRenderBox)
                        {
                            var box = (TCNRenderBox)z.RenderData;

                            var renderer = new ModelLoader.ModelRenderer(mb, (int)box.TextureOffset.X, (int)box.TextureOffset.Y);
                            renderer.part = box.Part;
                            renderer.addBox(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                            (int)box.Size.Z, box.IsMirrored, box.Scale, z.name);
                            renderer.setRotationPoint(box.Position.X, box.Position.Y, box.Position.Z);
                            renderer.rotateAngleX = MathHelper.DegreesToRadians(box.Rotation.X);
                            renderer.rotateAngleY = MathHelper.DegreesToRadians(box.Rotation.Y);
                            renderer.rotateAngleZ = MathHelper.DegreesToRadians(box.Rotation.Z);
                            renderer.isSolid      = box.IsSolid;
                            renderer.isArmor      = box.IsArmor;
                        }
                    }
                }
            }

            var model = mb.Compile(Name, 1, (int)Models[0].TextureSize.X, (int)Models[0].TextureSize.Y, Models[0].DefaultTexture);

            return(model);
        }
Example #2
0
        public Model Convert()
        {
            var mb = new ModelLoader.ModelBase();

            foreach (TCNModel x in Models)
            {
                foreach (TCNFolder y in x.Geometry)
                {
                    foreach (TCNShape z in y.Shapes)
                    {
                        mb.textureWidth = (int)x.TextureSize.X;
                        mb.textureHeight = (int)x.TextureSize.Y;

                        if (z.RenderData == null)
                            continue;

                        if (z.RenderData is TCNRenderBox)
                        {
                            var box = (TCNRenderBox)z.RenderData;

                            var renderer = new ModelLoader.ModelRenderer(mb, (int)box.TextureOffset.X, (int)box.TextureOffset.Y, box.Part);
                            renderer.mirror = box.IsMirrored;
                            renderer.addBox(z.name, box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                            (int)box.Size.Z, box.Scale);
                            renderer.setRotationPoint(box.Position.X, box.Position.Y, box.Position.Z);
                            renderer.rotateAngleX = MathHelper.DegreesToRadians(box.Rotation.X);
                            renderer.rotateAngleY = MathHelper.DegreesToRadians(box.Rotation.Y);
                            renderer.rotateAngleZ = MathHelper.DegreesToRadians(box.Rotation.Z);
                            renderer.isSolid = box.IsSolid;
                        }
                        else if (z.RenderData is TCNRenderPlane)
                        {
                            var box = (TCNRenderPlane)z.RenderData;

                            var renderer = new ModelLoader.PlaneRenderer(mb, z.name, (int)box.TextureOffset.X, (int)box.TextureOffset.Y,
                                                                         box.Part);
                            renderer.mirror = box.IsMirrored;
                            renderer.setRotationPoint(box.Position.X, box.Position.Y, box.Position.Z);
                            renderer.rotateAngleX = MathHelper.DegreesToRadians(box.Rotation.X);
                            renderer.rotateAngleY = MathHelper.DegreesToRadians(box.Rotation.Y);
                            renderer.rotateAngleZ = MathHelper.DegreesToRadians(box.Rotation.Z);

                            switch (box.Side)
                            {
                                case 0:
                                    renderer.addBackPlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                          (int)box.Size.Z, box.Scale);
                                    break;
                                case 1:
                                    renderer.addSidePlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                          (int)box.Size.Z, box.Scale);
                                    break;
                                case 2:
                                    renderer.addTopPlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                         (int)box.Size.Z, box.Scale);
                                    break;
                            }
                        }
                    }
                }
            }

            return mb.Compile(Name, 1, (int)Models[0].TextureSize.X, (int)Models[0].TextureSize.Y);
        }
Example #3
0
        public Model Convert()
        {
            var mb = new ModelLoader.ModelBase();

            foreach (TCNModel x in Models)
            {
                foreach (TCNFolder y in x.Geometry)
                {
                    foreach (TCNShape z in y.Shapes)
                    {
                        mb.textureWidth  = (int)x.TextureSize.X;
                        mb.textureHeight = (int)x.TextureSize.Y;

                        if (z.RenderData == null)
                        {
                            continue;
                        }

                        if (z.RenderData is TCNRenderBox)
                        {
                            var box = (TCNRenderBox)z.RenderData;

                            var renderer = new ModelLoader.ModelRenderer(mb, (int)box.TextureOffset.X, (int)box.TextureOffset.Y, box.Part);
                            renderer.mirror = box.IsMirrored;
                            renderer.addBox(z.name, box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                            (int)box.Size.Z, box.Scale);
                            renderer.setRotationPoint(box.Position.X, box.Position.Y, box.Position.Z);
                            renderer.rotateAngleX = MathHelper.DegreesToRadians(box.Rotation.X);
                            renderer.rotateAngleY = MathHelper.DegreesToRadians(box.Rotation.Y);
                            renderer.rotateAngleZ = MathHelper.DegreesToRadians(box.Rotation.Z);
                            renderer.isSolid      = box.IsSolid;
                        }
                        else if (z.RenderData is TCNRenderPlane)
                        {
                            var box = (TCNRenderPlane)z.RenderData;

                            var renderer = new ModelLoader.PlaneRenderer(mb, z.name, (int)box.TextureOffset.X, (int)box.TextureOffset.Y,
                                                                         box.Part);
                            renderer.mirror = box.IsMirrored;
                            renderer.setRotationPoint(box.Position.X, box.Position.Y, box.Position.Z);
                            renderer.rotateAngleX = MathHelper.DegreesToRadians(box.Rotation.X);
                            renderer.rotateAngleY = MathHelper.DegreesToRadians(box.Rotation.Y);
                            renderer.rotateAngleZ = MathHelper.DegreesToRadians(box.Rotation.Z);

                            switch (box.Side)
                            {
                            case 0:
                                renderer.addBackPlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                      (int)box.Size.Z, box.Scale);
                                break;

                            case 1:
                                renderer.addSidePlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                      (int)box.Size.Z, box.Scale);
                                break;

                            case 2:
                                renderer.addTopPlane(box.Offset.X, box.Offset.Y, box.Offset.Z, (int)box.Size.X, (int)box.Size.Y,
                                                     (int)box.Size.Z, box.Scale);
                                break;
                            }
                        }
                    }
                }
            }

            return(mb.Compile(Name, 1, (int)Models[0].TextureSize.X, (int)Models[0].TextureSize.Y));
        }