コード例 #1
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);
        }
コード例 #2
0
        public override void Run(RenderControl renderer)
        {
            var ellipse = SketchBuilder.MakeEllipse(GP.Origin(), 10, 5, GP.DX(), GP.DZ());

            renderer.ShowShape(ellipse, Vector3.Blue);

            ParametricCurve pc = new ParametricCurve(ellipse);

            var paramsList = pc.SplitByUniformLength(1, 0.01);

            uint itemCount = (uint)paramsList.Count;
            var  points    = new ParticleSceneNode(itemCount, Vector3.Green, 5.0f);
            var  lines     = new SegmentsSceneNode(itemCount, Vector3.Red, 2);

            Random random = new Random();

            for (int ii = 0; ii < paramsList.Count; ++ii)
            {
                var value = pc.D1(paramsList[ii]);
                var pos   = value.GetPoint();
                var dir   = value.GetVectors()[0];
                var end   = new GPnt(pos.XYZ().Added(dir.XYZ()));

                lines.SetPositions((uint)ii, Vector3.From(pos), Vector3.From(end));
                lines.SetColors((uint)ii, Vector3.Red, Vector3.From(random.NextDouble(), random.NextDouble(), random.NextDouble()));

                points.SetPosition((uint)ii, Vector3.From(pos));
            }

            renderer.ShowSceneNode(points);
            renderer.ShowSceneNode(lines);
        }
コード例 #3
0
        public override void Run(RenderControl render)
        {
            var fileName = GetResourcePath("models/YONGSHENGDA_9998.igs");
            var shape    = ShapeIO.Open(fileName);

            if (shape == null)
            {
                return;
            }

            var face  = shape.FindChild(EnumTopoShapeType.Topo_FACE, 12);
            var edges = face.GetChildren(EnumTopoShapeType.Topo_EDGE);

            var wire = SketchBuilder.MakeWire(edges);

            if (wire == null)
            {
                return;
            }



            var curve = new ParametricCurve();

            curve.Initialize(wire);
            var ulist = curve.SplitByUniformLength(1, 0.2);


            var node = new ParticleSceneNode((uint)ulist.Count, ColorTable.Red, 2);

            for (int ii = 0; ii < ulist.Count; ++ii)
            {
                node.SetPosition((uint)ii, Vector3.From(curve.Value(ulist[ii])));
            }
            node.UpdateBoundingBox();

            render.ShowShape(wire, ColorTable.GoldEnrod);
            render.ShowSceneNode(node);
        }