コード例 #1
0
        public override void Run(RenderControl render)
        {
            TopoShapeList auxCurves = new TopoShapeList();

            for (int ii = 0; ii < 4; ++ii)
            {
                char   name     = (char)((int)('A') + ii);
                string fileName = String.Format("data/complex/{0}.sldcrv", name);
                var    curve    = CreateSpline(GetResourcePath(fileName));
                if (curve != null)
                {
                    render.ShowShape(curve, ColorTable.Hex(0xFF0000));
                    auxCurves.Add(curve);
                }
            }

            for (int ii = 0; ii < 12; ++ii)
            {
                string fileName = String.Format("data/complex/{0}.sldcrv", ii);
                var    curve    = CreateSpline(GetResourcePath(fileName));
                if (curve != null)
                {
                    render.ShowShape(curve, ColorTable.Hex(0xFF00FF));
                    auxCurves.Add(curve);
                }
            }
        }
コード例 #2
0
        public override void Run(RenderControl render)
        {
            var paramCurve = Sketch2dBuilder.MakeLine(new GPnt2d(0, 0), new GPnt2d(Math.PI * 20, 20));

            // curve one cone
            {
                var cone               = ShapeBuilder.MakeCone(GP.XOY(), 1, 10, 20, 0);
                var coneFace           = cone.FindChild(EnumTopoShapeType.Topo_FACE, 0);
                var curveOnConeSurface = SketchBuilder.MakeCurveOnSurface(paramCurve, coneFace);

                var material = LineDashedMaterial.Create("my.dashed.material");
                material.SetColor(ColorTable.Hex(0x0FFAA));
                var node = BrepSceneNode.Create(curveOnConeSurface, null, material);
                node.ComputeLineDistances(); // Enable dashed line style.

                render.ShowSceneNode(node);
            }
            // curve one cylinder
            {
                var cylinder     = ShapeBuilder.MakeCylinder(GP.XOY(), 2, 20, 0);
                var cylinderFace = cylinder.FindChild(EnumTopoShapeType.Topo_FACE, 0);

                var curveOnCylinderSurface = SketchBuilder.MakeCurveOnSurface(paramCurve, cylinderFace);

                var node2 = BrepSceneNode.Create(curveOnCylinderSurface, null, null);
                render.ShowSceneNode(node2);
            }
        }
コード例 #3
0
        public void Create(RenderControl render)
        {
            // 随便构造些点
            float offset = 10.0f;

            for (int ii = 0; ii < 10; ++ii)
            {
                for (int jj = 0; jj < ii; ++jj)
                {
                    mPoints.Add(new Vector3(jj * offset, 100, ii * offset));
                }
            }


            mMotionTrail = new ParticleSceneNode((uint)mPoints.Count, ColorTable.Green, 3.0f);

            mCurrentIdx = 0;

            render.ShowSceneNode(mMotionTrail);

            var lineMaterial = BasicMaterial.Create("myline");

            lineMaterial.SetColor(ColorTable.Hex(0xFF0000));
            var line = GeometryBuilder.CreateLine(Vector3.Zero, new Vector3(1, 0, 0));

            mLineNode = new PrimitiveSceneNode(line, lineMaterial);
            mLineNode.SetTransform(MakeTransform(mStart, mPoints[0]));
            mLineNode.RequstUpdate();
            render.ShowSceneNode(mLineNode);
        }
コード例 #4
0
        BrepSceneNode CreateGlass(GAx2 ax, double width, double height, double thickness)
        {
            var shape = ShapeBuilder.MakeBox(ax, width, thickness, height);

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

            frameMaterial.SetColor(ColorTable.Hex(0xAAAAAA));
            frameMaterial.SetFaceSide(EnumFaceSide.DoubleSide);
            frameMaterial.SetTransparent(true);
            frameMaterial.SetOpacity(0.5f);

            return(BrepSceneNode.Create(shape, frameMaterial, null));
        }
コード例 #5
0
        void PrepareMaterials()
        {
            if (mRobotMaterial != null)
            {
                return;
            }

            mRobotMaterial = MeshStandardMaterial.Create("robot");
            mRobotMaterial.SetColor(ColorTable.Hex(0xEEFF22));
            mRobotMaterial.SetFaceSide(EnumFaceSide.DoubleSide);
            // mRobotMaterial.SetOpacity(0.5f);
            //mRobotMaterial.SetTransparent(true);

            mMaterial = MeshStandardMaterial.Create("hilight-robot");
            mMaterial.SetColor(ColorTable.Hex(0xFF0000));
            mMaterial.SetFaceSide(EnumFaceSide.DoubleSide);
        }
コード例 #6
0
        public override void Run(RenderControl renderer)
        {
            var shape = ShapeIO.Open(GetResourcePath("hole/30-30.IGS"));

            if (shape == null)
            {
                return;
            }

            var edgeMaterial = BasicMaterial.Create("hole-edge");

            edgeMaterial.SetColor(ColorTable.Hex(0xFF0000));
            edgeMaterial.SetLineWidth(2);


            // 1. Find the exterial holes
            var holeExp = new HoleExplorLegacy();

            if (!holeExp.Initialize(shape))
            {
                return;
            }
            var holeNumber = holeExp.ComputeExteriorHoles();

            for (int ii = 0; ii < holeNumber; ++ii)
            {
                var wire     = holeExp.GetExteriorHoleWire(ii);
                var wireNode = BrepSceneNode.Create(wire, null, edgeMaterial);

                renderer.ShowSceneNode(wireNode);
            }

            // 2. Show the faces
            var material = MeshStandardMaterial.Create("hole-face");

            material.SetColor(ColorTable.Hex(0xBBAA33));
            material.SetRoughness(0.8f);
            material.SetFaceSide(EnumFaceSide.DoubleSide);

            var shapeNode = BrepSceneNode.Create(shape, material, null);

            shapeNode.SetDisplayFilter(EnumShapeFilter.Face);
            renderer.ShowSceneNode(shapeNode);
        }
コード例 #7
0
        public override void Run(RenderControl render)
        {
            mGeometry = GeometryBuilder.CreatePlane(20000, 20000, worldWidth - 1, worldDepth - 1);
            var position = mGeometry.GetAttribute(0);

            position.SetDataUsage(EnumBufferDataUsage.DYNAMIC_DRAW);
            var mPosition = new Float32Array(position.GetData());

            for (uint i = 0; i < position.GetCount() / 3; i++)
            {
                float z = (float)(35 * Math.Sin(i / 2));
                mPosition.SetValue(i * 3 + 2, z);
            }

            var material = BasicMaterial.Create("basic-water");
            var img      = FileImage.Create(GetResourcePath("textures/water.png"));
            var texture  = new ImageTexture2D();

            texture.SetSource(img);
            var desc = texture.GetDesc();

            desc.SetWrapS(EnumTextureWrappingType.REPEAT);
            desc.SetWrapT(EnumTextureWrappingType.REPEAT);
            texture.SetRepeat(new Vector2(5, 5));

            material.AddTexture("map", texture);
            var color = ColorTable.Hex(0x0044ff);

            material.SetUniform("diffuse", Uniform.Create(color));


            var node = new PrimitiveSceneNode(mGeometry, material);

            node.SetPickable(false);
            node.SetCulling(false);

            render.ShowSceneNode(node);
        }
コード例 #8
0
        public override void Run(RenderControl render)
        {
            var material = MeshStandardMaterial.Create("my-material");

            material.SetRoughness(0.75f);
            material.SetMetalness(0.1f);
            material.SetColor(ColorTable.Hex(0xFFC107));

            for (uint ii = 0; ii < 10; ++ii)
            {
                TopoShape shape = ShapeBuilder.MakePyramid(new GAx2(new GPnt(ii * 11, 0, 0), GP.DZ()), ii + 3, 5, 5 + ii);
                var       node  = BrepSceneNode.Create(shape, material, null);
                render.ShowSceneNode(node);
            }

            //var bottom = SketchBuilder.MakeRectangle(GP.XOY(), 10, 20, 2, false);
            //var shape2 = FeatureTool.Loft(bottom, new GPnt(5, 10, 10));

            //render.ShowShape(shape2, ColorTable.Blue);

            //var shape3 =  ShapeBuilder.MakeCone(GP.XOY(), 10, 0, 10, 0);
            //render.ShowShape(shape3, ColorTable.Blue);
        }
コード例 #9
0
        public override void Run(RenderControl render)
        {
            TopoShapeList tg     = new TopoShapeList();
            GPntList      points = new GPntList();

            using (var sr = new StreamReader(GetResourcePath("data/Stage4_Rotor4_Profile.curve")))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("# Profile"))
                    {
                        if (points.Count > 0)
                        {
                            var temp2 = SketchBuilder.MakeBSpline(points);
                            if (temp2 != null)
                            {
                                tg.Add(temp2);
                            }
                        }

                        points = new GPntList();
                    }
                    else
                    {
                        var temp = line.Split('\t');
                        points.Add(new GPnt(double.Parse(temp[0]), double.Parse(temp[1]), double.Parse(temp[2])));
                    }
                }
            }


            var temp1 = FeatureTool.Loft(tg, true, true);

            render.ShowShape(temp1, ColorTable.Hex(0xFF0000));
        }