public Scene3D TestConv(VRMLScene vrml)
 {
     Scene3D scene = new Scene3D();
     foreach (BaseNode node in vrml.root) {
         List<Object3D> objs = TestConvNode(node);
         foreach (Object3D obj in objs) {
             if (obj != null) {
                 if (obj is Shape3D) {
                     scene.Objects.Add((Shape3D)obj);
                 }
             }
         }
     }
     return scene;
 }
 public Scene3D Convert(VrmlScene vrml)
 {
     Scene3D scene = new Scene3D();
     float[,] transformation = VrmlMath.GetUnitMatrix();
     foreach (Node node in vrml.root.children) {
         List<Object3D> objs = ConvertNode(node, transformation);
         foreach (Object3D obj in objs) {
             if (obj != null) {
                 if (obj is Shape3D) {
                     scene.Shapes.Add((Shape3D)obj);
                 }
             }
         }
     }
     return scene;
 }
Exemple #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            _scene = new Scene3D();
            _scene = new VrmlToG3DConverter().Convert(@"D:\dev\graph3d\Graph3D.Vrml.Test\Ant.wrl");
            _scene.Shapes.First().CoordinateSystem.Translate(new Vector3D(-0.2f, 0.3f, 0.2f)).Scale(2, 2, 2).RotateV(0.2f).RotateU(0.1f).Translate(new Vector3D(0, 0, -0.2f));
            PreciseColor color = new PreciseColor(0.6f, 0.3f, 0.3f) * 0.8f;
            const float shininess = 0;
            var b = new Box3D {
                Material = { DiffuseColor = color, Shininess = shininess },
                Width = 40,
                Height = 40,
                Depth = 120
            };
            _scene.Shapes.Add(b);

            _scene.Shapes.Add(new Sphere3D {
                CoordinateSystem = { Position = new Vector3D(0, 14, -2) },
                Radius = 6.0f,
                Material = {
                    DiffuseColor = new PreciseColor(0.0f, 0.1f, 0.0f) * 2.99f,
                    AmbientIntensity = 0.9f,
                    Shininess = 0.1f
                }
            });

            _scene.Shapes.Add(new Sphere3D {
                CoordinateSystem = { Position = new Vector3D(9, 14, -2) },
                Radius = 6.0f,
                Material = {
                    DiffuseColor = new PreciseColor(0.0f, 0.0f, 1.0f) * 0.19f,
                    AmbientIntensity = 0.95f,
                    Shininess = 0.05f
                }
            });

            //_scene.Shapes.Add(new Box3D {
            //    CoordinateSystem = { Position = new Vector3D(3, 14, -6) },
            //    Width = 4,
            //    Height = 4,
            //    Depth = 4,
            //    Material = {
            //        DiffuseColor = new PreciseColor(0.0f, 0.0f, 1.0f) * 0.50f,
            //        AmbientIntensity = 0.2f,
            //        Shininess = 0.1f
            //    }
            //});

            const int omniCount = 5;
            for (int i = 0; i < omniCount; i++) {
                float angle = 2 * (float)System.Math.PI * i / omniCount;
                const float radius = 16;
                float x = 0 + radius * (float)System.Math.Cos(angle);
                float y = -19.5f;
                float z = -7 + radius * (float)System.Math.Sin(angle);
                _scene.Lights.Add(new OmniLight3D {
                    Position = new Vector3D(x, y, z),
                    Color = new PreciseColor(1.0f, 1.0f, 1.0f),
                    Power = 1500.0f / omniCount
                });
            }
        }