Example #1
0
        public static Texture CreateFromFile(string path, bool isLinear)
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(path);
            if (fileInfo.Exists == false)
            {
                return(null);
            }
            int textureID = CreateTextureFromFile(path, isLinear);

            if (textureID >= 0)
            {
                Texture texture = new Texture(textureID);
                texture.filterMode = FilterMode.Bilinear;
                MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, texture);
                return(texture);
            }
            ;
            return(null);
        }
Example #2
0
        public static PBR_StandardShader Create()
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int shaderID = CreatePBRStandardShader();

            if (shaderID >= 0)
            {
                var shader = new PBR_StandardShader(shaderID);
                MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, shader);
                return(shader);
            }
            return(null);
        }
Example #3
0
        public static Mesh Create(uint vertexCount, uint indexCount)
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int meshID = CreateMesh(vertexCount, indexCount);

            if (meshID >= 0)
            {
                Mesh mesh = new Mesh(meshID);
                MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, mesh);
                return(mesh);
            }
            ;
            return(null);
        }
Example #4
0
        public static Texture Create(uint width, uint height)
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int textureID = CreateTexture(width, height);

            if (textureID >= 0)
            {
                Texture texture = new Texture(textureID);
                texture.filterMode = FilterMode.Bilinear;
                MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, texture);
                return(texture);
            }
            ;
            return(null);
        }
Example #5
0
        internal static Camera Create()
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int cameraID = CreateCamera();

            if (cameraID < 0)
            {
                return(null);
            }

            Camera camera = new Camera(cameraID);

            MessageHandler.Broadcast <RayTracerObject>(MessageName.AddNewSceneObject, camera);

            return(camera);
        }
Example #6
0
        public static MeshPrimitive Create()
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int primitiveID = CreateMeshPrimitive();

            if (primitiveID < 0)
            {
                return(null);
            }

            MeshPrimitive meshPrimitive = new MeshPrimitive(primitiveID);

            MessageHandler.Broadcast <RayTracerObject>(MessageName.AddNewSceneObject, meshPrimitive);

            return(meshPrimitive);
        }
Example #7
0
        public static EnvironmentMapSkyLight Create()
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int skyLightID = CreateEnvironmentMapSkyLight();

            if (skyLightID < 0)
            {
                return(null);
            }

            EnvironmentMapSkyLight skylight = new EnvironmentMapSkyLight(skyLightID);

            MessageHandler.Broadcast <RayTracerObject>(MessageName.AddNewSceneObject, skylight);

            return(skylight);
        }
Example #8
0
        public static Mesh[] CreateFromFile(string path)
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            System.IO.FileInfo fileInfo = new System.IO.FileInfo(path);
            if (fileInfo.Exists == false)
            {
                return(null);
            }
            if (fileInfo.Extension.ToLower().EndsWith(".mesh") == true)
            {
                Mesh mesh = LoadFromMesh(path);
                if (mesh != null)
                {
                    MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, mesh);
                }
                return(new Mesh[] { mesh });
            }
            int startMeshID = -1;
            int endMeshID   = -1;

            CreateMeshesFromFile(path, ref startMeshID, ref endMeshID);
            if (startMeshID >= 0 && endMeshID >= 0)
            {
                Mesh[] results = new Mesh[endMeshID - startMeshID + 1];
                for (int i = startMeshID; i <= endMeshID; i++)
                {
                    Mesh mesh = new Mesh(i);
                    mesh.m_path = path;
                    MessageHandler.Broadcast <ResourceObject>(MessageName.AddNewResource, mesh);
                    results[i - startMeshID] = mesh;
                }
                return(results);
            }
            return(null);
        }
Example #9
0
        public static SunLight Create()
        {
            RayTracer instance = RayTracer.GetInstance();

            if (!instance.IsInitialized())
            {
                return(null);
            }
            int sunLightID = CreateSunLight();

            if (sunLightID < 0)
            {
                return(null);
            }

            SunLight sunLight = new SunLight(sunLightID);

            sunLight.euler = new Vector3(50, -30, 0);

            MessageHandler.Broadcast <RayTracerObject>(MessageName.AddNewSceneObject, sunLight);

            return(sunLight);
        }