public LightingManager(IGameContext gameContext,
                               IGameProperties gameProperties,
                               IMeshManager meshManager,
                               IMaterialManager materialManager,
                               ITextureManager textureManager,
                               IRenderManager renderManager,
                               CameraManager cameraManager,
                               LightStore lightStore,
                               ILightManager lightManager,
                               TimeManager timeManager)
        {
            this.gameContext    = gameContext;
            this.gameProperties = gameProperties;
            this.meshManager    = meshManager;
            this.textureManager = textureManager;
            this.renderManager  = renderManager;
            this.cameraManager  = cameraManager;
            this.lightStore     = lightStore;
            this.lightManager   = lightManager;
            this.timeManager    = timeManager;
            skySphereMesh       = meshManager.CreateMesh(ObjParser.LoadObj("meshes/skysphere.obj").MeshData);
            skyMaterial         = materialManager.CreateMaterial("data/skybox.json");
            noiseTexture        = textureManager.LoadTexture("textures/noise_512.png");

            skyMaterial.SetTexture("cloudsTex", noiseTexture);
        }
        public AreaTriggerManager(IGameContext gameContext)
        {
            this.gameContext = gameContext;
            boxMesh          = gameContext.Engine.MeshManager.CreateMesh(ObjParser.LoadObj("meshes/box.obj").MeshData);
            sphereMesh       = gameContext.Engine.MeshManager.CreateMesh(ObjParser.LoadObj("meshes/sphere.obj").MeshData);

            wireframe = gameContext.Engine.MaterialManager.CreateMaterial("data/wireframe.json");
            wireframe.SetUniform("Width", 1);
            wireframe.SetUniform("Color", Vector4.One);
            wireframe.ZWrite       = false;
            wireframe.DepthTesting = DepthCompare.Lequal;

            wireframeBehind = gameContext.Engine.MaterialManager.CreateMaterial("data/wireframe.json");
            wireframeBehind.SetUniform("Width", 0.5f);
            wireframeBehind.SetUniform("Color", new Vector4(1, 1, 1, 0.1f));
            wireframeBehind.ZWrite              = false;
            wireframeBehind.DepthTesting        = DepthCompare.Greater;
            wireframeBehind.BlendingEnabled     = true;
            wireframeBehind.SourceBlending      = Blending.SrcAlpha;
            wireframeBehind.DestinationBlending = Blending.OneMinusSrcAlpha;

            transcluentMaterial = gameContext.Engine.MaterialManager.CreateMaterial("data/gizmo.json");
            transcluentMaterial.BlendingEnabled     = true;
            transcluentMaterial.SourceBlending      = Blending.SrcAlpha;
            transcluentMaterial.DestinationBlending = Blending.OneMinusSrcAlpha;
            transcluentMaterial.DepthTesting        = DepthCompare.Lequal;
            transcluentMaterial.ZWrite = false;
            transcluentMaterial.SetUniform("objectColor", new Vector4(0.2f, 0.4f, 1f, 0.3f));
        }
Ejemplo n.º 3
0
        public LightingManager(IGameContext gameContext)
        {
            this.gameContext = gameContext;
            skySphereMesh    = gameContext.Engine.MeshManager.CreateMesh(ObjParser.LoadObj("meshes/skysphere.obj").MeshData);
            skyMaterial      = gameContext.Engine.MaterialManager.CreateMaterial("data/skybox.json");
            noiseTexture     = gameContext.Engine.TextureManager.LoadTexture("textures/noise_512.png");

            skyMaterial.SetTexture("cloudsTex", noiseTexture);
        }
Ejemplo n.º 4
0
        public AreaTriggerManager(IGameContext gameContext,
                                  IGameProperties gameProperties,
                                  IMeshManager meshManager,
                                  IMaterialManager materialManager,
                                  AreaTriggerStore areaTriggerStore,
                                  IRenderManager renderManager,
                                  IUIManager uiManager,
                                  CameraManager cameraManager)
        {
            this.gameContext      = gameContext;
            this.gameProperties   = gameProperties;
            this.meshManager      = meshManager;
            this.areaTriggerStore = areaTriggerStore;
            this.renderManager    = renderManager;
            this.uiManager        = uiManager;
            this.cameraManager    = cameraManager;
            boxMesh    = meshManager.CreateMesh(ObjParser.LoadObj("meshes/box.obj").MeshData);
            sphereMesh = meshManager.CreateMesh(ObjParser.LoadObj("meshes/sphere.obj").MeshData);

            wireframe = materialManager.CreateMaterial("data/wireframe.json");
            wireframe.SetUniform("Width", 1);
            wireframe.SetUniform("Color", Vector4.One);
            wireframe.ZWrite       = false;
            wireframe.DepthTesting = DepthCompare.Lequal;

            wireframeBehind = materialManager.CreateMaterial("data/wireframe.json");
            wireframeBehind.SetUniform("Width", 0.5f);
            wireframeBehind.SetUniform("Color", new Vector4(1, 1, 1, 0.1f));
            wireframeBehind.ZWrite              = false;
            wireframeBehind.DepthTesting        = DepthCompare.Greater;
            wireframeBehind.BlendingEnabled     = true;
            wireframeBehind.SourceBlending      = Blending.SrcAlpha;
            wireframeBehind.DestinationBlending = Blending.OneMinusSrcAlpha;

            transcluentMaterial = materialManager.CreateMaterial("data/gizmo.json");
            transcluentMaterial.BlendingEnabled     = true;
            transcluentMaterial.SourceBlending      = Blending.SrcAlpha;
            transcluentMaterial.DestinationBlending = Blending.OneMinusSrcAlpha;
            transcluentMaterial.DepthTesting        = DepthCompare.Lequal;
            transcluentMaterial.ZWrite = false;
            transcluentMaterial.SetUniform("objectColor", new Vector4(0.2f, 0.4f, 1f, 0.3f));
        }
        private void LoadFile(string fileName)
        {
            var objPath             = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}.{FileExtensions.Object}"));
            var normalsPath         = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Normal}.{FileExtensions.ImgType}"));
            var diffuseTexturePath  = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Diffuse}.{FileExtensions.ImgType}"));
            var specularTexturePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\", "examples", $"{fileName}_{FileExtensions.Specular}.{FileExtensions.ImgType}"));

            var parser = new ObjParser();

            parser.LoadObj(objPath);

            camera.Position = new Vector3(vm.XCameraPos, vm.YCameraPos, vm.ZCameraPos);
            camera.Target   = Vector3.Zero;

            mesh = new RenderObj(parser.VertexList.Count, parser.FaceList.Count, parser.NormalList.Count, parser.TextureList.Count);
            mesh.NormalTexture   = parser.LoadTexture(normalsPath);
            mesh.DiffuseTexture  = parser.LoadTexture(diffuseTexturePath);
            mesh.SpecularTexture = parser.LoadTexture(specularTexturePath);
            mesh.Position        = new Vector3(vm.XObjectPos, vm.YObjectPos, vm.ZObjectPos);

            for (var i = 0; i < parser.VertexList.Count; i++)
            {
                mesh.Vertices[i] = parser.VertexList[i].ToVector4();
            }

            mesh.Faces = parser.FaceList.ToArray();

            for (var i = 0; i < parser.NormalList.Count; i++)
            {
                mesh.Normals[i] = parser.NormalList[i].ToVector();
            }

            for (var i = 0; i < parser.TextureList.Count; i++)
            {
                mesh.TextureCoordinates[i] = parser.TextureList[i].ToVector();
            }

            UpdateAnimation();
        }
Ejemplo n.º 6
0
 public void AddFrameFromObj(string fileName)
 {
     this.fames.Add(ObjParser.LoadObj(fileName));
 }