Example #1
0
        public void Render(SceneEntity entity)
        {
            entity.DrawAll(this);

            foreach (var light in lights)
            {
                MainLight = light;
                entity.DrawAll(light.Shader, this);
            }
        }
Example #2
0
        public List<SceneEntity> ToSceneEntities()
        {
            List<SceneEntity> entitites = new List<SceneEntity>();

            foreach (var res in Meshes)
            {
                var mat = Materials[res.Key];
                var entity = new SceneEntity(res.Value, new Transform(), mat);
                entitites.Add(entity);
            }

            return entitites;
        }
Example #3
0
 public void AddEntity(SceneEntity newEntity)
 {
     entities.Add(newEntity);
 }
Example #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            this.VSync = VSyncMode.Adaptive;

            scene = new Scene.Scene(new TargetCamera(new Vector3(5), 2*Vector3.UnitY, (float)MathHelper.DegreesToRadians(45.0), (float)this.Width / (float)this.Height, .1f, 100.0f));

            var buffer = new EntityBuffer();
            float side = 0.4f;

            buffer.SetVertices(
                new Vertex[]{
                    new Vertex(new Position3(0, (float)(side*Math.Sqrt(2)), 0), new Position2(), new Position3()),
                    new Vertex(new Position3(side, -side, 0), new Position2(), new Position3()),
                    new Vertex(new Position3(-side, -side, 0), new Position2(), new Position3())
                },
                new ushort[]{
                   1,0,2
                });

            Mesh mesh = new Mesh(buffer);
            triangle = new SceneEntity(mesh, new Transform(-0.5f * Vector3.One, Vector3.Zero, Vector3.One), new ColoredMaterial(Color.Green));

            scene.AddEntity(triangle);
            var resource = MeshResource.Load("Resources/Models/generic_male_01/generic_male_01.obj");
            var entities = resource.ToSceneEntities();
            foreach (var entity in entities)
            {
                scene.AddEntity(entity);
            }
        }