コード例 #1
0
        public override void Run(RenderControl render)
        {
            if (!ReadData())
            {
                return;
            }

            var material = PointsMaterial.Create("point-material");

            material.GetTemplate().SetVertexColors(true);

            var geometry = GeometryBuilder.CreatePoints(new Float32Array(mPositions), new Float32Array(mColors));

            var node = new PrimitiveSceneNode(geometry, material);

            //node.SetPickable(false);

            render.ShowSceneNode(node);
        }
コード例 #2
0
        public override void Run(RenderControl render)
        {
            // prepare points data
            const int COUNT  = 300;
            var       buffer = new Float32Buffer(0);

            buffer.Reserve(COUNT * 3);

            var colors = new Float32Buffer(0);

            Random random = new Random();

            for (int i = 0; i < COUNT; i++)
            {
                float x = 2000 * (float)random.NextDouble() - 1000;
                float y = 2000 * (float)random.NextDouble() - 1000;
                float z = 2000 * (float)random.NextDouble() - 1000;

                buffer.Append(x, y, z);
                colors.Append((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());
            }

            var primitive = GeometryBuilder.CreatePoints(new Float32Array(buffer), new Float32Array(colors));

            // prepare point material
            var material = PointsMaterial.Create("points-material");

            material.SetSizeAttenuation(false);
            material.SetPointSize(15.0f);
            material.SetColorMap(ImageTexture2D.Create(GetResourcePath("textures/snowflake7_alpha.png")));
            material.SetTransparent(true);

            // enable vertex color
            material.GetTemplate().SetVertexColors(true);


            // add to scene
            var node = new PrimitiveSceneNode(primitive, material);

            node.SetPickable(false);
            render.ShowSceneNode(node);
        }