Пример #1
0
        public void SetUp()
        {
            _materialCache = new MaterialCache();
            _parentMtl     = _materialCache.Add("testmtl1");
            _childMtl      = _materialCache.Add("testmtl2");

            _epicModel = new EpicModel();

            _parentCuboid            = Cuboid.CreateCuboid();
            _parentCuboid.Size       = new Vector3(2, 2, 2);
            _parentCuboid.Rotation   = new Vector3(0, 0, -(float)Math.PI / 4.0f);
            _parentCuboid.MaterialId = _parentMtl.Id;

            _connector          = _parentCuboid.AddAnchor("Connector");
            _connector.Position = new Vector3(1, 1, 0);

            _childCuboid            = Cuboid.CreateCuboid();
            _childCuboid.Position   = new Vector3(-1, -1, 0);
            _childCuboid.Rotation   = new Vector3(0, 0, -(float)Math.PI / 2.0f);
            _childCuboid.MaterialId = _childMtl.Id;


            _epicModel.ModelParts.Add(_parentCuboid);
            _childCuboid.Pivot.SetParent(_connector);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();

            _modelInstance = new ModelInstance(_compiledModel, _materialCache);

            _modelInstance.Update(1 / 24.0f);
        }
Пример #2
0
        private ModelInstance CreateModel(Material material)
        {
            var model  = new EpicModel();
            var parent = Cuboid.CreateCuboid();

            parent.Position   = new Vector3(0.25f, 0.25f, -0.25f);
            parent.MaterialId = material.Id;
            model.ModelParts.Add(parent);
            parent.Size = new Vector3(2, 2, 2);

            model.ModelParts.Add(parent);

            parent.MaterialId = material.Id;

            for (int i = 0; i < ChildCount; i++)
            {
                var child = Cuboid.CreateCuboid();

                child.Position = new Vector3(i, i, -i);
                child.Pivot.SetParent(parent.Pivot, true);
                child.MaterialId = material.Id;

                model.ModelParts.Add(child);
            }

            var emc           = new EpicModelCompiler(model);
            var compiledModel = emc.Compile();

            var modelInstance = new ModelInstance(compiledModel, _materialCache);

            _vertexCount = modelInstance.MeshInstances[0].VertexBuffer.Length;

            return(modelInstance);
        }
Пример #3
0
        public void SaveAndLoad()
        {
            Logger.Add(new TraceLogger {
                LoggerLevel = LoggerLevel.Trace
            });

            _model = new EpicModel();
            var cuboid = Cuboid.CreateCuboid();

            cuboid.MaterialId = 1;
            cuboid.Name       = "Cuboid1";
            cuboid.AddAnchor("a1");
            cuboid.AddAnchor("a2");

            var cuboid2 = Cuboid.CreateCuboid();

            cuboid2.MaterialId = 1;
            cuboid2.Name       = "Cuboid2";
            var a3 = cuboid2.AddAnchor("a3");

            var a4 = cuboid2.AddAnchor("a4");

            a4.Position = new Vector3(0.5f, 0.0f, 0.0f);

            cuboid.Pivot.SetParent(a3);

            _model.ModelParts.Add(cuboid);
            _model.ModelParts.Add(cuboid2);

            var cuboid3 = Cuboid.CreateCuboid();

            cuboid3.MaterialId = 0;
            _model.ModelParts.Add(cuboid3);

            var animation = _model.GetAnimation(AnimationType.Drop, true);

            animation.AddFrame().Time = 0.0f;
            animation.AddFrame().Time = 0.265f;
            animation.AddFrame().Time = 0.384f;

            var animation2 = _model.GetAnimation(AnimationType.Death3, true);

            animation2.AddFrame().Time = 0.0f;

            cuboid2.Rotation = new Vector3(0.0f, 0.0f, (float)(Math.PI / 2.0f));
            cuboid2.Position = new Vector3(-1f, -1f, 0);

            var frame2 = animation2.AddFrame();

            frame2.LoadFromCurrentModelState(_model);
            frame2.Time = 0.519f;

            cuboid2.Rotation = new Vector3();
            cuboid2.Position = new Vector3();

            _compiler      = new EpicModelCompiler(_model);
            _compiledModel = _compiler.Compile();
        }
Пример #4
0
        public void SaveAndLoad()
        {
            _model = new EpicModel("test");
            var cuboid = Cuboid.CreateCuboid();

            cuboid.Name = "Cuboid1";
            cuboid.AddAnchor("a1");
            cuboid.AddAnchor("a2");
            cuboid.Position = new Vector3(1, 1, 0);

            var cuboid2 = Cuboid.CreateCuboid();

            cuboid2.Name = "Cuboid2";
            var a3 = cuboid2.AddAnchor("a3");

            cuboid2.AddAnchor("a4");
            a3.Position = new Vector3(1, 1, 0);

            a3.Rotation = new Vector3(1.0f, 2.0f, 3.0f);

            cuboid.Pivot.SetParent(a3);

            _model.ModelParts.Add(cuboid);
            _model.ModelParts.Add(cuboid2);
            _model.ModelParts.Add(cuboid.Clone());

            var animation = _model.GetAnimation(AnimationType.Drop, true);

            animation.AddFrame().Time = 0.123f;
            animation.AddFrame().Time = 0.265f;
            animation.AddFrame().Time = 0.384f;

            var animation2 = _model.GetAnimation(AnimationType.Death3, true);

            animation2.AddFrame().Time = 0.464f;
            animation2.AddFrame().Time = 0.519f;
            animation2.AddFrame().Time = 0.694f;

            var materialTranslator = new TestMaterialTranslator();

            var memoryStream = new MemoryStream(4096);

            var binaryWriter = new BinaryWriter(memoryStream);
            var writer       = new EpicModelWriter(materialTranslator);

            writer.Write(binaryWriter, _model);

            memoryStream.Position = 0;

            var binaryReader = new BinaryReader(memoryStream);
            var reader       = new EpicModelReader(materialTranslator, binaryReader);

            _readModel = reader.Read("test");
        }
Пример #5
0
        public void Compile()
        {
            _epicModel = new Psy.Core.EpicModel.EpicModel();

            var cuboid = Cuboid.CreateCuboid();

            cuboid.Size = new Vector3(1.0f, 1.0f, 1.0f);

            _epicModel.ModelParts.Add(cuboid);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();
        }
Пример #6
0
        public void SetUp()
        {
            _model = new EpicModel();

            _parent          = Cuboid.CreateCuboid();
            _parent.Position = new Vector3(0.25f, 0.25f, -0.25f);
            _model.ModelParts.Add(_parent);
            _parent.Size = new Vector3(2, 2, 2);

            _connectingAnchor          = _parent.AddAnchor("Connecting_Anchor");
            _connectingAnchor.Position = new Vector3(1, 1, -1);

            _child = Cuboid.CreateCuboid();
            _model.ModelParts.Add(_child);
            _child.Position = new Vector3(2, 2, 0);
            _child.Pivot.SetParent(_connectingAnchor);
        }
Пример #7
0
        public void SetUp()
        {
            _materialCache = new MaterialCache();
            var testmtl = _materialCache.Add("testmtl");

            _epicModel = new Psy.Core.EpicModel.EpicModel();

            var cuboid = Cuboid.CreateCuboid();

            cuboid.Size       = new Vector3(1.0f, 1.0f, 1.0f);
            cuboid.MaterialId = testmtl.Id;

            _epicModel.ModelParts.Add(cuboid);

            _compiler      = new EpicModelCompiler(_epicModel);
            _compiledModel = _compiler.Compile();

            _modelInstance = new ModelInstance(_compiledModel, _materialCache);

            _modelInstance.Update(1 / 24.0f);
        }
Пример #8
0
        public void AddCubeToModel()
        {
            var cuboid = Cuboid.CreateCuboid("cube", 1);

            Model.ModelParts.Add(cuboid);
        }