public void Render(SceneProperties sceneProperties)
        {
            carMaterial.SetVariable("DecalTexture", 1);
            carMaterial.SetVariable("ReflectionTexture", 2);
            carMaterial.SetVariable("MainLightPos", new Vector3(0, 4, 0));
            carMaterial.SetVariable("MainLightTint", Color4.White);
            carMaterial.SetVariable("MainLightConstant", 0.5f);
            carMaterial.SetVariable("MainLightLinear", 0.001f);
            carMaterial.SetVariable("MainLightQuadratic", 0.1f);
            carMaterial.SetVariable("Rotation", currentEuler);
            carMaterial.SetVariable("AmbientLightStrength", sceneProperties.AmbientLightStrength);
            var renderRotation = Quaternion.FromEulerAngles(new Vector3(currentEuler)
            {
                Y = -currentEuler.Y
            });
            var wheelRenderRotation = Quaternion.FromEulerAngles(new Vector3(currentEuler)
            {
                Y = -currentEuler.Y
            });

            decalTexture?.Bind();
            for (int i = 0; i < data.wheelPositions.Length; ++i)
            {
                Render3D.DrawMesh(wheelMesh,
                                  data.wheelPositions[i] + position * -1.0f,
                                  new Vector3(0.19f, 0.19f, 0.19f) * ((i % 2 == 0) ? -1 : 1),
                                  wheelRenderRotation,
                                  Quaternion.Identity,
                                  testTexture);
            }

            Render3D.DrawMesh(testMesh, position * -1.0f, new Vector3(0.2f, 0.2f, 0.2f), renderRotation, Quaternion.Identity, testTexture, carMaterial);
        }
Beispiel #2
0
 public void Create()
 {
     map                   = new Map();
     hero                  = new Hero();
     render2D              = new Render2D(map, hero);
     render3D              = new Render3D(map, hero);
     Console.WindowHeight  = SCREEN_HEIGHT;
     Console.CursorVisible = false;
 }
Beispiel #3
0
        public Form1()
        {
            DoubleBuffered = true;
            InitializeComponent();

            FormClosing += Form1_FormClosing;
            KeyDown     += Form1_KeyDown;
            KeyUp       += Form1_KeyUp;
            Timer t = new Timer();

            t.Tick    += T_Tick;
            t.Interval = 1;
            t.Start();

            // init model
            mesh = new Mesh();
            mesh = MeshGenerator.CreateCube();

            grid          = new Grid3();
            grid.SrcVerts = mesh.Verts;
            grid.Scale    = new Vector3(50 * 1, 50, 50);


            renderer = new Render3D(this, 1920 / 1, 1080 / 1);
            renderer.StartRender();

            renderer.AddToRender(grid, mesh);
            for (int i = 0; i < 10; i++)
            {
                Mesh m = MeshGenerator.CreateCube();

                Grid3 g = new Grid3();
                g.SrcVerts = m.Verts;
                g.Scale    = new Vector3(25, 25, 25);
                g.Pos      = new Vector3((i - 5) * 40, 0, i * 10);
                grids.Add(g);

                renderer.AddToRender(g, m);
            }
        }
Beispiel #4
0
        public void Render(SceneProperties sceneProperties)
        {
            Vector3[] wheelPositions = new Vector3[4]
            {
                new Vector3(-1.65f, 0.2f, 1.0f),
                new Vector3(-1.65f, 0.2f, -1.0f),
                new Vector3(1.65f, 0.2f, 1.0f),
                new Vector3(1.65f, 0.2f, -1.0f)
            };
            carMaterial.SetVariable("DecalTexture", 1);
            carMaterial.SetVariable("ReflectionTexture", 2);
            carMaterial.SetVariable("MainLightPos", new Vector3(0, 4, 0));
            carMaterial.SetVariable("MainLightTint", Color4.White);
            carMaterial.SetVariable("MainLightConstant", 0.5f);
            carMaterial.SetVariable("MainLightLinear", 0.001f);
            carMaterial.SetVariable("MainLightQuadratic", 0.1f);
            carMaterial.SetVariable("Rotation", currentEuler);
            carMaterial.SetVariable("AmbientLightStrength", sceneProperties.AmbientLightStrength);
            var renderRotation = Quaternion.FromEulerAngles(new Vector3(currentEuler)
            {
                Y = -currentEuler.Y
            });
            var wheelRenderRotation = Quaternion.FromEulerAngles(new Vector3(currentEuler)
            {
                Y = -currentEuler.Y
            });

            decalTexture?.Bind();
            for (int w = 0; w < wheelPositions.Length; ++w)
            {
                Render3D.DrawMesh(wheelMesh,
                                  (wheelPositions[w] + position + new Vector3(0, -0.35f, 0)) * -1.0f,
                                  new Vector3(0.19f, 0.19f, 0.19f) * ((w % 2 == 1) ? -1 : 1),
                                  wheelRenderRotation,
                                  Quaternion.FromEulerAngles(new Vector3(-currentAccel * Time.currentTime * 10.0f, 0, 0)) * Quaternion.FromEulerAngles(new Vector3(0, ((w >= 2) ? -turningWeight / 180.0f : 0), 0)),
                                  testTexture);
            }
            Render3D.DrawMesh(testMesh, position * -1.0f, new Vector3(0.2f, 0.2f, 0.2f), renderRotation, Quaternion.FromEulerAngles(new Vector3(-currentAccel / 100.0f, 0, turningWeight / 1080.0f)), testTexture, carMaterial);
        }
Beispiel #5
0
        public override void Render()
        {
            Render2D.DrawQuad(new Vector2(0, -120), new Vector2(320, 480), textures["sky"]);
            GL.Clear(ClearBufferMask.DepthBufferBit);
            foreach (Material m in materials)
            {
                m.SetVariable("AmbientLightStrength", sceneProperties.AmbientLightStrength);
            }

            //reflectionTexture.Bind();
            standardMat.SetVariables(new Dictionary <string, Any>()
            {
                { "ReflectionTexture", 2 },
                { "LightPositions", new Any(lights) },
                { "LightTints", new Any(lightTints) },
                { "LightCount", lights.Length },
                { "AmbientLightTint", sceneProperties.AmbientLightTint },
                { "MainLightPos", sceneProperties.MainLightPos },
                { "MainLightTint", sceneProperties.MainLightTint },
                { "MainLightConstant", sceneProperties.MainLightConstant },
                { "MainLightLinear", sceneProperties.MainLightLinear },
                { "MainLightQuadratic", sceneProperties.MainLightQuadratic }
            });
            carController.Update(sceneProperties);

            foreach (var obj in sceneObjects)
            {
                Render3D.DrawMesh(obj.mesh, obj.position, obj.scale, obj.rotation, Quaternion.Identity, obj.texture, obj.material);
            }
            //Render3D.DrawMesh(skyMesh, carController.position * -1.0f, new Vector3(50, 50, 50), Quaternion.Identity, Quaternion.Identity, skyTexture, unlitMat,
            //new Dictionary<string, Whirlpool.Core.Type.Any>()
            //{
            //    { "Model", Matrix4.Identity },
            //    { "MVP", Render3D.sceneCamera.view * Render3D.sceneCamera.projection }
            //});
            carController.Render(sceneProperties);
        }
Beispiel #6
0
 public GameObject(Transform transform, string modelName) : this(transform)
 {
     Transform = transform;
     Model     = new Render3D(modelName, this);
 }
Beispiel #7
0
 public virtual void Render()
 {
     Render3D.DrawMesh(mesh, position, scale, rotation, localRotation, texture, material);
     onRender?.Invoke(this, null);
 }