Example #1
0
        public MainViewModel()
        {
            Title = "ImageViewDemo";
            SubTitle = "WPF & SharpDX";

            this.OpenCommand = new RelayCommand((x) => OnOpenClick());

            // camera setup
            this.defaultPerspectiveCamera = new PerspectiveCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0.5, FarPlaneDistance = 150 };
            this.defaultOrthographicCamera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0), NearPlaneDistance = 0, FarPlaneDistance = 100 };
            this.Camera = defaultPerspectiveCamera;

            // setup lighting            
            this.AmbientLightColor = new Color4(0f, 0f, 0f, 0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-0, -0, -10);

            // floor plane grid
            this.Grid = LineBuilder.GenerateGrid(Vector3.UnitZ, -5, 5, -5, 5);           
            this.GridColor = SharpDX.Color.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(0, 0, 0);

            // plane
            var b2 = new MeshBuilder();
            b2.AddBox(new Vector3(0, 0, 0), 10, 10, 0, BoxFaces.PositiveZ);
            this.Plane = b2.ToMeshGeometry3D();
            this.PlaneMaterial = PhongMaterials.Blue;
            this.PlaneTransform = new Media3D.TranslateTransform3D(-0, -0, -0);            
            //this.PlaneMaterial.ReflectiveColor = Color.Black;
            this.PlaneTransform = new Media3D.TranslateTransform3D(0, 0, 0);

            this.RenderTechnique = Techniques.RenderBlinn;
        }
 /// <summary>
 /// Called when geometry has been changed.
 /// </summary>
 protected override void OnModelChanged()
 {            
     var mb = new MeshBuilder();
     var p0 = this.Offset;// new Vector3(0, 0, 0);
     var d = this.Direction;
     d.Normalize();
     var p1 = p0 + (d * (float)this.Length);
     mb.AddArrow(p0, p1, this.Diameter, 2, 64);
     this.Geometry = mb.ToMeshGeometry3D();            
 }
Example #3
0
        public MainViewModel()
        {
            // titles
            this.Title = "Deferred Shading Demo";    
        
            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) };

            // clear color 
            this.BackgroundColor = (Color4)Color.White;

            // default render technique
            this.RenderTechnique = Techniques.RenderDeferred;

            // setup lighting            
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            this.DirectionalLightColor2 = Color.Red;
            this.DirectionalLightColor1 = Color.Green;
            this.DirectionalLightColor3 = Color.Blue;
            this.DirectionalLightDirection1 = new Vector3(-0,  -50, -0);
            this.DirectionalLightDirection2 = new Vector3(-0,  -50,  -50);
            this.DirectionalLightDirection3 = new Vector3(-50, -50,  -0);

            // floor plane grid
            this.Grid = LineBuilder.GenerateGrid();
            this.GridColor = SharpDX.Color.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5);

            // scene model3d
            var b1 = new MeshBuilder(true,true,true);
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All);
            var meshGeometry = b1.ToMeshGeometry3D();
            meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray();
            this.Model = meshGeometry;

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2);
            this.Lines = e1.ToLineGeometry3D();

            // model trafos
            this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);

            // model materials
            this.RedMaterial = PhongMaterials.White;
            this.RedMaterial.DiffuseMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute));
            this.RedMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute));
            this.GreenMaterial = PhongMaterials.DefaultVRML;
            //this.GreenMaterial.TextureMap = this.RedMaterial.TextureMap;
            this.BlueMaterial = PhongMaterials.Silver;
            //this.BlueMaterial.TextureMap = this.RedMaterial.TextureMap;
        }
Example #4
0
        public MainViewModel()
        {
            Title = "Shadow Map Demo";
            SubTitle = "WPF & SharpDX";

            // setup lighting            
            this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-0, -1, -1);
            this.LightDirectionTransform = CreateAnimatedTransform(-DirectionalLightDirection.ToVector3D(), new Vector3D(0, 1, -1), 24);
            this.ShadowMapResolution = new Vector2(2048, 2048);

            // camera setup
            this.Camera = new PerspectiveCamera { Position = (Point3D)(-DirectionalLightDirection.ToVector3D()), LookDirection = DirectionalLightDirection.ToVector3D(), UpDirection = new Vector3D(0, 1, 0) };

            // floor plane grid
            //Grid = LineBuilder.GenerateGrid();
            //GridColor = SharpDX.Color.Black;
            //GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5);

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.25, 2, BoxFaces.All);
            Model = b1.ToMeshGeometry3D();
            //Instances = new[] { Matrix.Translation(0, 0, -1.5f), Matrix.Translation(0, 0, 1.5f) };

            var b2 = new MeshBuilder();
            b2.AddBox(new Vector3(0, 0, 0), 10, 0, 10, BoxFaces.PositiveY);
            Plane = b2.ToMeshGeometry3D();
            PlaneTransform = new Media3D.TranslateTransform3D(-0, -2, -0);
            GrayMaterial = PhongMaterials.LightGray;
            //GrayMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)); 

            // lines model3d            
            Lines = LineBuilder.GenerateBoundingBox(Model);

            // model trafos
            Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);            

            // model materials
            RedMaterial = PhongMaterials.Glass;
            GreenMaterial = PhongMaterials.Green;
            BlueMaterial = PhongMaterials.Blue;
        }
Example #5
0
        public MainViewModel()
        {
            // titles
            this.Title = "Simple Demo";
            this.SubTitle = "WPF & SharpDX";

            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) };

            // default render technique
            this.RenderTechnique = Techniques.RenderBlinn;

            // setup lighting            
            this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-2, -5, -2);

            // floor plane grid
            this.Grid = LineBuilder.GenerateGrid();
            this.GridColor = SharpDX.Color.Black;
            this.GridTransform = new Media3D.TranslateTransform3D(-5, -1, -5);

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2, BoxFaces.All);
            var meshGeometry = b1.ToMeshGeometry3D();
            meshGeometry.Colors = meshGeometry.TextureCoordinates.Select(x => x.ToColor4()).ToArray();
            this.Model = meshGeometry;

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 2);
            this.Lines = e1.ToLineGeometry3D();

            // model trafos
            this.Model1Transform = new Media3D.TranslateTransform3D(0, 0, 0);
            this.Model2Transform = new Media3D.TranslateTransform3D(-2, 0, 0);
            this.Model3Transform = new Media3D.TranslateTransform3D(+2, 0, 0);
            
            // model materials
            this.RedMaterial = PhongMaterials.Red;
            this.GreenMaterial = PhongMaterials.Green;
            this.BlueMaterial = PhongMaterials.Blue;
        }
Example #6
0
        public MainViewModel()
        {
            this.Title = "Manipulator Demo";
            this.SubTitle = null;
            
            // camera setup
            this.Camera = new OrthographicCamera { Position = new Point3D(0, 0, 5), LookDirection = new Vector3D(0, 0, -5), UpDirection = new Vector3D(0, 1, 0) };

            // setup lighting            
            this.AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-2, -5, -2);

            // floor plane grid
            this.Grid = LineBuilder.GenerateGrid();
            this.GridColor = SharpDX.Color.Black;
            this.GridTransform = new TranslateTransform3D(-5, -1, -5);

            // scene model3d
            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 0.5);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5, BoxFaces.All);
            this.Model = b1.ToMeshGeometry3D();

            // lines model3d
            var e1 = new LineBuilder();
            e1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 1.5);
            this.Lines = e1.ToLineGeometry3D();
            
            // model trafos
            this.Model1Transform = CreateAnimatedTransform(new Vector3D(0, 0, 0), new Vector3D(1, 1, 1), 20);
            this.Model2Transform = new TranslateTransform3D(-3, 0, 0);
            this.Model3Transform = new TranslateTransform3D(+3, 0, 0);

            // model materials
            this.Material1 = PhongMaterials.Orange;
            this.Material2 = PhongMaterials.Orange;
            this.Material3 = PhongMaterials.Red;

            var dr = Color.DarkRed;
            Console.WriteLine(dr);
        }
Example #7
0
        public MainViewModel()
        {
            Title = "Instancing Demo";            

            // camera setup
            Camera = new PerspectiveCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) };

            // setup lighting            
            this.AmbientLightColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            this.DirectionalLightColor = (Color4)Color.White;
            this.DirectionalLightDirection = new Vector3(-2, -5, -2);

            // scene model3d
            var b1 = new MeshBuilder(); 
            b1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5, BoxFaces.All);
            Model = b1.ToMeshGeometry3D();

            var l1 = new LineBuilder();
            l1.AddBox(new Vector3(0, 0, 0), 0.8, 0.8, 0.5);
            Lines = l1.ToLineGeometry3D();   

            int num = 10;
            var instances = new List<Matrix>();
            for (int i = -num; i < num; i++)
            {
                for (int j = -num; j < num; j++)
                {
                    instances.Add(Matrix.Translation(new Vector3(i / 1.0f, j / 1.0f, 0f)));
                }
            }
            ModelInstances = instances;
            SubTitle = "Number of Instances: " + instances.Count.ToString();

            // model trafo
            ModelTransform = Media3D.Transform3D.Identity;// new Media3D.RotateTransform3D(new Media3D.AxisAngleRotation3D(new Vector3D(0, 0, 1), 45));

            // model material
            ModelMaterial = PhongMaterials.Glass;
        }
Example #8
0
        public MainViewModel()
        {
            this.Title = "Environment Mapping Demo";
            this.SubTitle = "HelixToolkitDX";                        

            // camera setup
            this.Camera = new PerspectiveCamera { Position = new Point3D(10, 0, 0), LookDirection = new Vector3D(-10, 0, 0), UpDirection = new Vector3D(0, 1, 0) };
            //this.Camera = new OrthographicCamera { Position = new Point3D(3, 3, 5), LookDirection = new Vector3D(-3, -3, -5), UpDirection = new Vector3D(0, 1, 0) };

            // lighting setup            
            this.AmbientLightColor = new Color4(0.5f, 0.5f, 0.5f, 1.0f);
            this.DirectionalLightColor = Color.White;
            this.DirectionalLightDirection = new Vector3(-2, -1, 1);

            // scene model3d
            var b1 = new MeshBuilder(true);
            b1.AddSphere(new Vector3(0, 0, 0), 1.0, 64, 64);
            b1.AddBox(new Vector3(0, 0, 0), 1, 0.5, 3, BoxFaces.All);

            this.Model = b1.ToMeshGeometry3D();
            this.ModelTransform = new Media3D.TranslateTransform3D();
            this.ModelMaterial = PhongMaterials.Copper;            
        }
Example #9
0
        /// <summary>
        /// Create the geometry and the VBO (vertex and index buffers) 
        /// for light-geoemtry 
        /// Call it once in the scene initialization 
        /// </summary>
        private void CreateSphereBuffer()
        {
            this.deferredLightingVariables = new DeferredLightingVariables(this.renderHost.Effects);

#if EXERCISE


            // TODO 2:
            //  - generate a sphere mesh using the MeshBuilder()
            //  - fill the screenSphere struct


#else


            var b1 = new MeshBuilder();
            b1.AddSphere(new Vector3(0, 0, 0), 1.0);
            MeshGeometry3D meshGeometry = b1.ToMeshGeometry3D();

            var vertices = meshGeometry.Positions.Select(p => new Vector4(p, 1.0f)).ToArray();
            int[] indices = meshGeometry.Indices;

            this.screenSphere = new LightGeometryData()
            {
                IndexBuffer = this.device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), indices),
                VertexBuffer = this.device.CreateBuffer(BindFlags.VertexBuffer, Vector4.SizeInBytes, vertices),
                IndexCount = meshGeometry.Indices.Length,
            };


#endif

        }
        public override void Attach(IRenderHost host)
        {
            /// --- attach
            this.effectName = Techniques.RenderCubeMap;
            base.Attach(host);

            /// --- get variables               
            this.vertexLayout = host.Effects.GetLayout(this.effectName);
            this.technique = effect.GetTechniqueByName(this.effectName);
            this.effectTransforms = new EffectTransformVariables(this.effect);

            /// -- attach cube map 
            if (this.Filename != null)
            {
                /// -- attach texture
                using (var texture = Texture2D.FromFile<Texture2D>(this.device, this.Filename))
                {
                    this.texCubeMapView = new ShaderResourceView(this.device, texture);
                }
                this.texCubeMap = effect.GetVariableByName("texCubeMap").AsShaderResource();
                this.texCubeMap.SetResource(this.texCubeMapView);
                this.bHasCubeMap = effect.GetVariableByName("bHasCubeMap").AsScalar();
                this.bHasCubeMap.Set(true);

                /// --- set up geometry
                var sphere = new MeshBuilder(false,true,false);
                sphere.AddSphere(new Vector3(0, 0, 0));
                this.geometry = sphere.ToMeshGeometry3D();

                /// --- set up vertex buffer
                this.vertexBuffer = device.CreateBuffer(BindFlags.VertexBuffer, CubeVertex.SizeInBytes, this.geometry.Positions.Select((x, ii) => new CubeVertex() { Position = new Vector4(x, 1f) }).ToArray());

                /// --- set up index buffer
                this.indexBuffer = device.CreateBuffer(BindFlags.IndexBuffer, sizeof(int), geometry.Indices);

                /// --- set up rasterizer states
                var rasterStateDesc = new RasterizerStateDescription()
                {
                    FillMode = FillMode.Solid,
                    CullMode = CullMode.Back,
                    IsMultisampleEnabled = true,
                    IsAntialiasedLineEnabled = true,
                    IsFrontCounterClockwise = false,
                };
                this.rasterState = new RasterizerState(this.device, rasterStateDesc);

                /// --- set up depth stencil state
                var depthStencilDesc = new DepthStencilStateDescription()
                {
                    DepthComparison = Comparison.LessEqual,
                    DepthWriteMask = global::SharpDX.Direct3D11.DepthWriteMask.All,
                    IsDepthEnabled = true,
                };
                this.depthStencilState = new DepthStencilState(this.device, depthStencilDesc);
            }

            /// --- flush
            this.device.ImmediateContext.Flush();
        }
Example #11
0
 static Sphere()
 {
     var b1 = new MeshBuilder();
     b1.AddSphere(new Vector3(0, 0, 0), 0.5);
     geometry = b1.ToMeshGeometry3D();
 }
        /// <summary>
        /// Called when geometry has been changed.
        /// </summary>
        protected override void OnModelChanged()
        {
            var mb = new MeshBuilder();
            var p0 = this.Offset; //new Vector3(0, 0, 0);
            if (this.InnerDiameter >= this.OuterDiameter)
                this.OuterDiameter = this.InnerDiameter + 0.3;

            var d = this.Axis;
            d.Normalize();
            var p1 = p0 - (d * (float)this.Length * 0.5f);
            var p2 = p0 + (d * (float)this.Length * 0.5f);
            mb.AddPipe(p1, p2, this.InnerDiameter, this.OuterDiameter, 64);
            this.Geometry = mb.ToMeshGeometry3D();
        }
Example #13
0
        public MainViewModel(Viewport3DX view)
        {
            this.view = view;            

            // ----------------------------------------------
            // set windows text
            Title = "Lighting Demo (WPF & SharpDX)";
            SubTitle = string.Format("Model: {0}, Number Lights: {1}", RenderTechnique, Light3D.LightCount);

            // ----------------------------------------------
            // camera setup
            Camera = new PerspectiveCamera { Position = new Point3D(8, 9, 7), LookDirection = new Vector3D(-5, -12, -5), UpDirection = new Vector3D(0, 1, 0) };

            // ----------------------------------------------
            // setup scene
            AmbientLightColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);

            Light1Color = (Color4)Color.White;
            Light2Color = (Color4)Color.Red;
            Light3Color = (Color4)Color.LightYellow;
            Light4Color = (Color4)Color.LightBlue;

            Light2Attenuation = new Vector3(1.0f, 0.5f, 0.10f);
            Light3Attenuation = new Vector3(1.0f, 0.1f, 0.05f);
            Light4Attenuation = new Vector3(1.0f, 0.2f, 0.0f);

            Light1Direction = new Vector3(0, -10, -10);
            Light1Transform = new Media3D.TranslateTransform3D(-Light1Direction.ToVector3D());
            Light1DirectionTransform = CreateAnimatedTransform2(-Light1Direction.ToVector3D(), new Vector3D(0, 1, -1), 24);
            //Light1DirectionTransform = Media3D.Transform3D.Identity;// CreateAnimatedTransform(new Vector3D(0, 1, 0), new Vector3D(1, 0, 1), 8);
            
            Light2Transform = CreateAnimatedTransform1(new Vector3D(-4, 0, 0), new Vector3D(0, 0, 1), 3);
            Light3Transform = CreateAnimatedTransform1(new Vector3D(0, 0, 4), new Vector3D(0, 1, 0), 5);
            Light4Transform = new Media3D.TranslateTransform3D(new Vector3D(0, 5, 0));
            Light4DirectionTransform = CreateAnimatedTransform1(new Vector3D(0, 1, 0), new Vector3D(1, 0, 1), 4);

            // ----------------------------------------------
            // light model3d
            var sphere = new MeshBuilder();
            sphere.AddSphere(new Vector3(0, 0, 0), 0.2);
            Sphere = sphere.ToMeshGeometry3D();
            LightModelMaterial = new PhongMaterial
            {
                AmbientColor = Color.Gray,
                DiffuseColor = Color.Gray,
                EmissiveColor = Color.Yellow,
                SpecularColor = Color.Black,
            };

            // ----------------------------------------------
            // scene model3d
            var b1 = new MeshBuilder(true, true, true);
            b1.AddSphere(new Vector3(0.25f, 0.25f, 0.25f), 0.75, 64, 64);
            b1.AddBox(-new Vector3(0.25f, 0.25f, 0.25f), 1, 1, 1, BoxFaces.All);
            b1.AddBox(-new Vector3(5.0f, 0.0f, 0.0f), 1, 1, 1, BoxFaces.All);
            b1.AddSphere(new Vector3(5f, 0f, 0f), 0.75, 64, 64);
            b1.AddCylinder(new Vector3(0f, -3f, -5f), new Vector3(0f, 3f, -5f), 1.2, 64);

            Model = b1.ToMeshGeometry3D();
            ModelTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            ModelMaterial = PhongMaterials.Chrome;
            //ModelMaterial.TextureMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute));
            ModelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute));
            //odelMaterial.NormalMap = new BitmapImage(new System.Uri(@"TextureNoise1_dot3.jpg", System.UriKind.RelativeOrAbsolute));


            // ----------------------------------------------
            // floor model3d
            var b2 = new MeshBuilder(true, true, true);
            b2.AddBox(new Vector3(0.0f, -5.0f, 0.0f), 15, 0.1, 15, BoxFaces.All);
            b2.AddSphere(new Vector3(-5.0f, -5.0f, 5.0f), 4, 64, 64);
            b2.AddCone(new Vector3(6f, -9f, -6f), new Vector3(6f, -1f, -6f), 4f, true, 64);
            Floor = b2.ToMeshGeometry3D();
            FloorTransform = new Media3D.TranslateTransform3D(0, 0, 0);
            FloorMaterial = new PhongMaterial
            {
                AmbientColor = Color.Gray,
                DiffuseColor = new Color4(0.75f, 0.75f, 0.75f, 1.0f), // Colors.LightGray,
                SpecularColor = Color.White,
                SpecularShininess = 100f,
                DiffuseMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2.jpg", System.UriKind.RelativeOrAbsolute)),
                NormalMap = new BitmapImage(new System.Uri(@"TextureCheckerboard2_dot3.jpg", System.UriKind.RelativeOrAbsolute)),
            };
        }
Example #14
0
        /// <summary>
        /// Gets a unit sphere from the cache.
        /// </summary>
        /// <param name="subdivisions">
        /// The number of subdivisions.
        /// </param>
        /// <returns>
        /// A unit sphere mesh.
        /// </returns>
        private static MeshGeometry3D GetUnitSphere(int subdivisions)
        {
            if (UnitSphereCache.ContainsKey(subdivisions))
            {
                return UnitSphereCache[subdivisions];
            }

            var mb = new MeshBuilder(false, false);
            mb.AddRegularIcosahedron(new Point3D(), 1, false);
            for (int i = 0; i < subdivisions; i++)
            {
                mb.SubdivideLinear();
            }

            for (int i = 0; i < mb.positions.Count; i++)
            {
                var v = mb.positions[i];
                v.Normalize();
                mb.positions[i] = v;
            }

            var mesh = mb.ToMeshGeometry3D();
            UnitSphereCache[subdivisions] = mesh;
            return mesh;
        }
Example #15
0
        /// <summary>
        /// Appends the specified mesh.
        /// </summary>
        /// <param name="mesh">
        /// The mesh.
        /// </param>
        public void Append(MeshBuilder mesh)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }

            this.Append(mesh.positions, mesh.triangleIndices, mesh.normals, mesh.textureCoordinates);
        }
Example #16
0
 static Cube()
 {
     var b1 = new MeshBuilder();
     b1.AddBox(new Vector3(0, 0, 0), 1, 1, 1);
     geometry = b1.ToMeshGeometry3D();
 }