Ejemplo n.º 1
0
 public void Add(RenderableModel model, IEnumerable <Sphere3d> spheres)
 {
     foreach (Sphere3d sphere in spheres)
     {
         Add(model, sphere);
     }
 }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color4.CadetBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Texture2D);

            VertexObjectGroupDefinition vertexGroupDefinition = new VertexObjectGroupDefinition(Properties.Resources.VertexShader, Properties.Resources.FragmentShader);

            vertexGroup = new VertexObjectGroup(vertexGroupDefinition);
            this.disposables.Add(vertexGroup);

            #region Models

            WavefrontModel  model       = new WavefrontModelLoader().Load(new FileInfo(@"C:\Users\pstepnowski\Documents\untitled.obj"));
            RenderableModel modelSphere = vertexGroup.Add(model);

            #endregion
            #region Scene Objects

            race = new Race(200);
            vertexGroup.Add(modelSphere, race.Spheres);
            playerSceneSphere = vertexGroup.Renderables.OfType <SceneSphere>().First(s => s.Sphere == race.PlayerSphere);

            #endregion

            Camera camera1 = new Camera(Width, Height);
            camera1.position = new Vector3(5, 2, 5);
            CameraFollow camera2 = new CameraFollow(Width, Height, playerSceneSphere);
            camera2.position = new Vector3(5, 2, 5);
            this.cameras.Add(camera2);

            TexturedObjectGroupDefinition texturedGroupDefinition = new TexturedObjectGroupDefinition(Properties.Resources.VertexShaderTextured, Properties.Resources.FragmentShaderTextured);
            texturedGroup = new TexturedObjectGroup(texturedGroupDefinition);
            this.disposables.Add(texturedGroup);

            FileInfo textureFile = new FileInfo(@"C:\Users\pstepnowski\Source\Repos\fdafadf\basics\Basics.Physics.Test.UI\Textures\concrete.png");
            Texture  texture     = texturedGroup.LoadTexture(textureFile);

            TestModelLoader modelLoader = new TestModelLoader();
            modelLoader.LoadTrack(texturedGroup, texture);

            //TexturedModel triangleModel = texturedGroup.Add(race.Ground);
            //texturedGroup.Add(triangleModel, texture.Handle, new Vector3());
        }
Ejemplo n.º 3
0
        public RenderableModel Add(WavefrontModel model)
        {
            List <Vertex> vertices = new List <Vertex>();
            List <uint>   indices  = new List <uint>();

            foreach (var face in model.Faces)
            {
                indices.Add((uint)indices.Count);
                Vector3 color = new Vector3(model.Normals[face.a.n - 1]);
                color.X = Math.Abs(color.X);
                color.Y = Math.Abs(color.Y);
                color.Z = Math.Abs(color.Z);
                vertices.Add(new Vertex(model.Vertices[face.a.v - 1], color, model.Normals[face.a.n - 1]));
            }

            RenderableModel renderableModel = new RenderableModel(vertices.ToArray(), indices.ToArray(), ShaderLayout_Position, ShaderLayout_Color, ShaderLayout_Normal);

            this.Disposables.Add(renderableModel);
            return(renderableModel);
        }
Ejemplo n.º 4
0
        public void Add(RenderableModel model, Sphere3d sphere)
        {
            SceneSphere sceneSphere = new SceneSphere(model, sphere);

            Renderables.Add(sceneSphere);
        }