Exemplo n.º 1
0
        GroupSceneNode CreateGeometry()
        {
            var shapeNode = new GroupSceneNode();

            shapeNode.SetPickable(false);

            PhongMaterial material = GlobalInstance.Application.FindSystemMaterial("obsidian");
            FaceStyle     fs       = new FaceStyle();

            fs.SetMaterial(material);
            shapeNode.SetFaceStyle(fs);

            float     bottomHeight = 10;
            TopoShape bottom       = GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO, Vector3.UNIT_Z, 5, bottomHeight, 0);
            TopoShape top          = GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 0, bottomHeight), Vector3.UNIT_Z, 10, 15, 0);

            shapeNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(bottom, 0.1f));
            shapeNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(top, 0.1f));



            return(shapeNode);
        }
Exemplo n.º 2
0
        private void sTLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Filter = "STL (*.stl)|*.stl|IGES (*.igs;*.iges)|*.igs;*.iges|STEP (*.stp;*.step)|*.stp;*.step|All Files(*.*)|*.*";

            if (DialogResult.OK == dlg.ShowDialog())
            {
                TopoShape shape = GlobalInstance.BrepTools.LoadFile(dlg.FileName);
                renderView.RenderTimer.Enabled = false;
                if (shape != null)
                {
                    PhongMaterial material = new PhongMaterial();
                    material.SetAmbient(new ColorValue(0.24725f, 0.2245f, 0.0645f));
                    material.SetDiffuse(new ColorValue(0.84615f, 0.8143f, 0.2903f));
                    material.SetSpecular(new ColorValue(0.797357f, 0.723991f, 0.208006f));
                    material.SetShininess(83.2f);
                    FaceStyle faceStyle = new FaceStyle();
                    faceStyle.SetMaterial(material);
                    SceneManager   sceneMgr = renderView.SceneManager;
                    TopoShapeGroup subGroup = GlobalInstance.TopoExplor.ExplorSubShapes(shape);
                    int            nSize    = subGroup.Size();
                    for (int ii = 0; ii < nSize; ++ii)
                    {
                        SceneNode node = GlobalInstance.TopoShapeConvert.ToEntityNode(subGroup.GetTopoShape(ii), 10f);
                        node.SetId(++shapeId);
                        node.SetFaceStyle(faceStyle);

                        sceneMgr.AddNode(node);
                    }
                }
                renderView.RenderTimer.Enabled = true;
            }

            renderView.View3d.FitAll();
            renderView.RequestDraw(EnumRenderHint.RH_LoadScene);
        }