Example #1
0
        GroupSceneNode CreateFrames(double width, double height, double deep, double radius)
        {
            var baseSketch = CreateSketch(radius, deep);

            //TopLeft
            var s11 = Project(baseSketch, new GPnt(0, 0, height), new GDir(-1, 0, -1), GP.DZ());
            //BottomLeft
            var s20 = Project(baseSketch, GP.Origin(), new GDir(-1, 0, 1), GP.DZ());
            //BottomRight
            var s12 = Project(s20, new GPnt(width, 0, 0), new GDir(1, 0, 1), GP.DX());
            //TopRight
            var s21 = Project(s11, new GPnt(width, 0, height), new GDir(-1, 0, 1), GP.DX());

            var frame1 = FeatureTool.Loft(s11, s20, false);
            var frame2 = FeatureTool.Loft(s20, s12, false);
            var frame3 = FeatureTool.Loft(s12, s21, false);
            var frame4 = FeatureTool.Loft(s21, s11, false);

            var frameMaterial = MeshStandardMaterial.Create("window-frame");

            frameMaterial.SetColor(Vector3.LightGray);
            frameMaterial.SetMetalness(0.5f);
            frameMaterial.SetFaceSide(EnumFaceSide.DoubleSide);

            var group = new GroupSceneNode();

            group.AddNode(BrepSceneNode.Create(frame1, frameMaterial, null));
            group.AddNode(BrepSceneNode.Create(frame2, frameMaterial, null));
            group.AddNode(BrepSceneNode.Create(frame3, frameMaterial, null));
            group.AddNode(BrepSceneNode.Create(frame4, frameMaterial, null));

            return(group);
        }
Example #2
0
        SceneNode CreateAnnotation(Vector3 start, Vector3 end, Vector3 offset, String text)
        {
            var line = GeometryBuilder.CreateLine(start + offset, end + offset);

            var mesh     = FontManager.Instance().CreateMesh(text);
            var textNode = new PrimitiveSceneNode(mesh, null);

            float scale = 0.015f;

            textNode.SetTransform(Matrix4.makeRotationAxis(Vector3.UNIT_X, 3.14159f * 0.5f) * Matrix4.makeScale(scale, scale, 1));
            textNode.ComputeBoundingBox(Matrix4.Identity);
            float halfW = textNode.GetWorldBBox().getHalfSize().x;
            var   dist  = end.distanceTo(start);
            float ratio = (dist * 0.5f - halfW) / dist;

            textNode.SetTransform(Matrix4.makeTranslation((start + end) * ratio + offset) * textNode.GetTransform());


            var line2 = GeometryBuilder.CreateLine(start, start + offset + new Vector3(0, 0, -2));
            var line3 = GeometryBuilder.CreateLine(end, end + offset + new Vector3(0, 0, -2));

            GroupSceneNode group = new GroupSceneNode();

            group.AddNode(new PrimitiveSceneNode(line, null));
            group.AddNode(new PrimitiveSceneNode(line2, null));
            group.AddNode(new PrimitiveSceneNode(line3, null));
            group.AddNode(textNode);

            return(group);
        }
Example #3
0
        public void UpdateGeometry()
        {
            if (_VisibleNode == null)
            {
                _VisibleNode = new GroupSceneNode();
                FaceStyle fs = new FaceStyle();
                fs.SetColor(new ColorValue(0, 0, 1.0f, 0.5f));
                fs.SetTransparent(true);
                _VisibleNode.SetFaceStyle(fs);
            }

            _VisibleNode.ClearAll();

            Path.BuildGeometry();

            TopoShape start = GlobalInstance.BrepTools.Extrude(Path.Section, Tool.ZStart, Vector3.UNIT_Z);
            TopoShape end   = GlobalInstance.BrepTools.Extrude(Path.Section, Tool.ZEnd, Vector3.UNIT_Z);

            _VisibleNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(start, 0.1f));
            _VisibleNode.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(end, 0.1f));

            Matrix4 trf = GlobalInstance.MatrixBuilder.MakeTranslate(Tool.Position);

            _VisibleNode.SetTransform(trf);
        }
Example #4
0
        private void pickGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            renderView.View3d.SetPickMode((int)(EnumPickMode.RF_GroupSceneNode | EnumPickMode.RF_Face));

            // Test Group
            TopoShape cylinder = GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO, Vector3.UNIT_Z, 50, 100, 0);
            TopoShape sphere   = GlobalInstance.BrepTools.MakeSphere(new Vector3(0, 0, 150), 50);

            GroupSceneNode group = new GroupSceneNode();

            group.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(cylinder, 0.1f));
            group.AddNode(GlobalInstance.TopoShapeConvert.ToEntityNode(sphere, 0.1f));

            renderView.SceneManager.AddNode(group);
        }
Example #5
0
 private void ShowAnyRobot()
 {
     //this.treeViewStp.Nodes.Clear();
     //this.renderView.ClearScene();
     for (int part_i = 0; part_i < any_robot.partList.Count; part_i++)
     {
         GroupSceneNode onePartNode = new GroupSceneNode();
         //Console.Write(onePartNode.GetTransform().GetTranslation().ToString());
         for (int geo_i = 0; geo_i < any_robot.partList[part_i].geometryPathList.Count; geo_i++)
         {
             string relPath = any_robot.partList[part_i].geometryPathList[geo_i];
             string absPath = relPath;
             if (relPath.Contains(":"))
             {
                 absPath = relPath;
             }
             else
             {
                 absPath = path + relPath;
             }
             TopoShape geo        = GlobalInstance.BrepTools.LoadFile(new AnyCAD.Platform.Path(absPath));
             SceneNode oneGeoNode = renderView.ShowGeometry(geo, part_i);
             float[]   oneGeoPq   = new float[7];
             for (int i = 0; i < 7; i++)
             {
                 oneGeoPq[i] = any_robot.partList[part_i].geometryPQ_List[i + geo_i * 7];
                 // oneGeoPq[i] = any_robot.partList[part_i].partPQ_initial[i];
             }
             oneGeoNode.SetTransform(QuaternionToTransform(oneGeoPq));
             renderView.RequestDraw();
             geoNodeList.Add(oneGeoNode);
             onePartNode.AddNode(oneGeoNode);
             renderView.SceneManager.RemoveNode(oneGeoNode);
         }
         float[] onePartPq = new float[7];
         for (int j = 0; j < 7; j++)
         {
             onePartPq[j] = any_robot.partList[part_i].partPQ_initial[j];
         }
         onePartNode.SetTransform(QuaternionToTransform(onePartPq));
         renderView.SceneManager.AddNode(onePartNode);
         partNodeList.Add(onePartNode);
     }
     renderView.SceneManager.AddNode(robot_node);
     robot_node.SetPickable(false);
     renderView.RequestDraw();
     robotLoadCompleted = true;
     for (int k = 0; k < partNodeList.Count; k++)
     {
         Console.WriteLine("part" + k + partNodeList[k].GetTransform().GetTranslation().ToString());
     }
     for (int k = 0; k < geoNodeList.Count; k++)
     {
         Console.WriteLine("geo" + k + geoNodeList[k].GetTransform().GetTranslation().ToString());
     }
 }
        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);
        }
Example #7
0
        public override void UpdateGeometry()
        {
            VisualNode.ClearAll();

            Coordinate3 coord = new Coordinate3();

            coord.X = -Vector3.UNIT_Y;
            coord.Y = Vector3.UNIT_Z;
            coord.Z = Vector3.UNIT_X;

            Matrix4 trf = GlobalInstance.MatrixBuilder.ToWorldMatrix(coord);

            foreach (TopoShape edge in Section)
            {
                TopoShape shape = GlobalInstance.BrepTools.Extrude(edge, Length, -Vector3.UNIT_Z);
                shape = GlobalInstance.BrepTools.Transform(shape, trf);

                VisualNode.AddNode(GlobalInstance.TopoShapeConvert.ToSceneNode(shape, 0.01f));
            }
        }