コード例 #1
0
ファイル: Plane.cs プロジェクト: nico1207/CUDAtrace
 public Plane(Vector3 position, Vector3 normal, JsonMaterial material)
 {
     Position      = position;
     Scale         = new Vector3(1000f, 1000f, 1000f);
     this.normal   = Vector3.Normalize(normal);
     this.material = material;
 }
コード例 #2
0
 public Disc(Vector3 position, Vector3 normal, float radius, JsonMaterial material)
 {
     Position      = position;
     Scale         = new Vector3(radius);
     this.normal   = Vector3.Normalize(normal);
     this.material = material;
 }
コード例 #3
0
        public void LoadScene(JsonScene scene)
        {
            currentScene = scene;

            editorObjects.Clear();

            foreach (JsonGeometry geometry in scene.Geometry)
            {
                JsonMaterial material = scene.Materials.SingleOrDefault(m => m.ID == geometry.Material);
                switch (geometry.Type)
                {
                case "plane":
                {
                    editorObjects.Add(new Plane(geometry.Position, geometry.Normal, material));
                    break;
                }

                case "sphere":
                {
                    editorObjects.Add(new Sphere(geometry.Position, geometry.Radius, material));
                    break;
                }

                case "disc":
                {
                    editorObjects.Add(new Disc(geometry.Position, geometry.Normal, geometry.Radius, material));
                    break;
                }
                }
            }

            foreach (JsonLight light in scene.Lights)
            {
                switch (light.Type)
                {
                case "disc":
                {
                    editorObjects.Add(new Disc(light.Position, light.Normal, light.Radius, new JsonMaterial()
                        {
                            Emission = new JsonEmissionSettings()
                            {
                                Color      = light.Color,
                                Brightness = light.Brightness
                            }
                        }));
                    lightPosition  = new Vector4(light.Position.X, light.Position.Y, light.Position.Z, light.Radius);
                    lightDirection = Vector3.Normalize(light.Normal);
                    lightColor     = new Vector4(light.Color.X, light.Color.Y, light.Color.Z, light.Brightness);
                    break;
                }
                }
            }

            if (initialized)
            {
                editorObjects.ForEach(o => o.Initialize());
            }
        }
コード例 #4
0
 public Sphere(Vector3 position, float radius, JsonMaterial material)
 {
     Position      = position;
     Scale         = new Vector3(radius);
     this.material = material;
 }