public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool Coloring,
            out bool Texturing)
        {
            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            Texturing = true;
            Coloring  = true;

            parentShape = GetParent <Shape>();


            _pack          = new PackedGeometry();
            _pack._indices = _boxGeometry.Indices;
            _pack._coords  = _boxGeometry.Vertices;
            //_pack._colorIndicies = _boxGeometry.Colors;
            _pack._texCoords   = _boxGeometry.Texcoords;
            _pack.restartIndex = -1;

            _pack.Interleave();

            // BUFFER GEOMETRY
            handle = _pack.CreateHandle();
            //handle = Buffering.BufferShaderGeometry(_pack);

            //this._boxGeometry.Load(parentShape);
        }
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool coloring,
            out bool texturing)
        {
            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            coloring  = false;
            texturing = false;

            parentShape = GetParent <Shape>();

            _pack = new PackedGeometry();
            _pack.restartIndex = -1;
            _pack._indices     = Faces;
            _pack._coords      = Verts;
            _pack.bbox         = BoundingBox.CalculateBoundingBox(Verts);

            _pack.Interleave();

            // BUFFER GEOMETRY
            handle = Buffering.BufferShaderGeometry(_pack);
        }
Beispiel #3
0
        public void EnableRendering(Vector3 origin)
        {
            Vector3[] lineColors;
            int[]     lineIndicies;

            bboxShader = ShaderCompiler.BuildDefaultShader();
            bboxShader.Link();

            lineColors   = null;
            lineIndicies = null;

            lines(LineColor, 12, out lineColors, out lineIndicies);

            _geo                 = new Box.BoxGeometry();
            _pack                = new PackedGeometry();
            _pack.Coloring       = true;
            _pack._indices       = _geo.Indices;
            _pack._coords        = _geo.Vertices;
            _pack.color          = X3DTypeConverters.Vec3ToFloatArray(lineColors);
            _pack._colorIndicies = lineIndicies;
            _pack.restartIndex   = -1;
            _pack.Interleave();
            _handle = _pack.CreateHandle();

            renderingEnabled = _handle.HasGeometry;

            InitBoundaryPoints(origin);
        }
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool Coloring,
            out bool Texturing)
        {
            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            Texturing = true;
            Coloring  = true;

            parentShape = GetParent <Shape>();


            _pack = new PackedGeometry();

            /*
             * glColor3d(1,0,0);
             * glVertex3f(-1,-1,-10);
             * glColor3d(1,1,0);
             * glVertex3f(1,-1,-10);
             * glColor3d(1,1,1);
             * glVertex3f(1,1,-10);
             * glColor3d(0,1,1);
             * glVertex3f(-1,1,-10);
             */
            _pack._indices = new int[] { 0, 1, 2, 3, -1 };
            _pack._coords  = new Vector3[]
            {
                new Vector3(-1, -1, 0),
                new Vector3(1, -1, 0),
                new Vector3(1, 1, 0),
                new Vector3(-1, 1, 0)
            };
            _pack._texCoords = new Vector2[]
            {
                new Vector2(0, 0),
                new Vector2(0, 1),
                new Vector2(1, 0),
                new Vector2(1, 1)
            };
            //_pack._colorIndicies = ;

            _pack.restartIndex = -1;

            _pack.Interleave();

            // BUFFER GEOMETRY
            handle = _pack.CreateHandle();
        }
Beispiel #5
0
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool coloring,
            out bool texturing)
        {
            bbox = BoundingBox.Zero;

            // INTERLEAVE
            _pack = PackedGeometry.Pack(this);

            coloring  = _pack.Coloring;
            texturing = _pack.Texturing;
            bbox      = _pack.bbox;

            // BUFFER GEOMETRY
            handle = _pack.CreateHandle();
        }
Beispiel #6
0
        public void InitBoundaryPoints(Vector3 origin)
        {
            int[]     colIndicies;
            Vector3[] verticies;
            Vector3[] pointColors;
            int[]     indicies;

            boundaries(origin, new Vector3(1, 0, 0), out pointColors, out colIndicies, out indicies, out verticies);

            var _pb = new PackedGeometry();

            _pb.Coloring       = true;
            _pb._indices       = indicies;
            _pb._coords        = verticies;
            _pb.color          = X3DTypeConverters.Vec3ToFloatArray(pointColors);
            _pb._colorIndicies = colIndicies;
            _pb.restartIndex   = -1;
            _pb.Interleave();
            _handlepb = _pb.CreateHandle();
        }
        private IndexedFaceSet ifs2; // without bottom face

        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool Coloring,
            out bool Texturing)
        {
            PackedGeometry        master;
            PackedGeometry        packed1;
            PackedGeometry        packed2;
            List <PackedGeometry> packs;

            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            Texturing = false;
            Coloring  = false;

            packs = new List <PackedGeometry>();

            if (this.bottom)
            {
                // Cone with bottom face

                packed1 = PackedGeometry.Pack(ifs1);
                packs.Add(packed1);
            }
            else
            {
                // Cone without bottom face

                packed2 = PackedGeometry.Pack(ifs2);
                packs.Add(packed2);
            }

            master = PackedGeometry.InterleavePacks(packs);

            bbox = BoundingBox.CalculateBoundingBox(master);

            // BUFFER GEOMETRY
            handle = Buffering.BufferShaderGeometry(master);
        }
        public override void Load()
        {
            base.Load();

            generateSkyAndGround = string.IsNullOrEmpty(frontUrl) || string.IsNullOrEmpty(backUrl) ||
                                   string.IsNullOrEmpty(topUrl) || string.IsNullOrEmpty(bottomUrl) ||
                                   string.IsNullOrEmpty(leftUrl) || string.IsNullOrEmpty(rightUrl);

            if (generateSkyAndGround)
            {
            }
            else
            {
                tex_cube = createCubeMapFromURIs();
            }


            _shape = new Shape();
            _shape.Load();
            _shape.IncludeDefaultShader(CubeMapBackgroundShader.vertexShaderSource,
                                        CubeMapBackgroundShader.fragmentShaderSource);


            //Buffering.Interleave(null, out _vbo_interleaved, out NumVerticies,
            //    out _vbo_interleaved4, out NumVerticies4,
            //    _cube.Indices, _cube.Indices, _cube.Vertices, _cube.Texcoords, _cube.Normals, null, null);

            PackedGeometry _pack = new PackedGeometry();

            _pack._indices  = _cube.Indices;
            _pack._coords   = _cube.Vertices;
            _pack.Texturing = true;
            //_pack._colorIndicies = _boxGeometry.Colors;
            _pack._texCoords   = _cube.Texcoords;
            _pack.restartIndex = -1;

            _pack.Interleave();

            // BUFFER GEOMETRY
            _handle = _pack.CreateHandle();
        }
Beispiel #9
0
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool Coloring,
            out bool Texturing)
        {
            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            Texturing = true;
            Coloring  = true;

            parentShape = GetParent <Shape>();

            buildCylinderGeometry();

            _pack = PackedGeometry.Pack(ifs1);

            // BUFFER GEOMETRY
            handle = Buffering.BufferShaderGeometry(_pack);
        }
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool Coloring,
            out bool Texturing)
        {
            List <Vertex> geometry;


            handle = GeometryHandle.Zero;
            bbox   = BoundingBox.Zero;



            parentShape       = GetParent <Shape>();
            colorNode         = (Color)this.Children.FirstOrDefault(n => n.GetType() == typeof(Color));
            colorRGBANode     = (ColorRGBA)this.Children.FirstOrDefault(n => n.GetType() == typeof(ColorRGBA));
            texCoordinateNode = (TextureCoordinate)this.Children.FirstOrDefault(n => n.GetType() == typeof(TextureCoordinate));

            RGBA             = colorRGBANode != null;
            RGB              = colorNode != null;
            coloring         = RGBA || RGB;
            generateColorMap = coloring;

            texturing           = texCoordinateNode != null || parentShape.texturingEnabled;
            generateTexCoordMap = texturing;

            Coloring  = coloring;
            Texturing = texturing;

            if (RGB && !RGBA)
            {
                color = X3DTypeConverters.Floats(colorNode.color);
            }
            else if (RGBA && !RGB)
            {
                color = X3DTypeConverters.Floats(colorRGBANode.color);
            }

            _isLoaded = true;


            ////
            ////
            ////



            if (construct)
            {
                float sx = this.xSpacing;
                float sz = this.zSpacing;

                IConstructionSet      constructionSet;
                IPerlinNoiseGenerator perlinProvider;
                Bitmap largePerlinImage;

                constructionSet = SceneManager.GetCurrentConstructionSet();
                perlinProvider  = constructionSet.GetPerlinNoiseProvider();

                ElevationGrid generated = constructionSet.ElevationBuilder.BuildHeightmapFromGenerator(
                    rc,
                    perlinProvider,
                    out largePerlinImage, 40, 40, 20, 20, 20); // build a rather large height map

                largePerlinImage.Dispose();

                Color genColorNode = (Color)generated.Children.FirstOrDefault(n => n.GetType() == typeof(Color));
                this.RGB             = coloring = generateColorMap = true;
                this.height          = generated.height;
                this.color           = X3DTypeConverters.Floats(genColorNode.color);
                this.colorPerVertex  = generated.colorPerVertex;
                this.normalPerVertex = generated.normalPerVertex;
                this.Children        = generated.Children;
                this.xSpacing        = generated.xSpacing;
                this.zSpacing        = generated.zSpacing;
                this.xDimension      = generated.xDimension;
                this.zDimension      = generated.zDimension;
            }



            if (!this._isLoaded)
            {
                parentShape = GetParent <Shape>();

                texturing           = parentShape.texturingEnabled;
                generateTexCoordMap = texturing && texCoordinateNode == null;

                this._isLoaded = true;
            }


            height_mapping();

            bbox = BoundingBox.CalcBoundingBox(this);


            geometry = BuildElevationGeometryQuads(bbox);

            Buffering.BufferShaderGeometry(geometry, out handle.vbo4, out handle.NumVerticies4);
        }
Beispiel #11
0
        public override void Load()
        {
            base.Load();

            int            i;
            int            a, b;
            PackedGeometry _pack;

            cubeHandle  = GeometryHandle.Zero;
            innerHandle = GeometryHandle.Zero;
            outerHandle = GeometryHandle.Zero;

            generateCube = !(string.IsNullOrEmpty(frontUrl) || string.IsNullOrEmpty(backUrl) ||
                             string.IsNullOrEmpty(topUrl) || string.IsNullOrEmpty(bottomUrl) ||
                             string.IsNullOrEmpty(leftUrl) || string.IsNullOrEmpty(rightUrl));

            //TODO: replace cube sides that arent available with transparent sides

            generateSkyAndGround = !(string.IsNullOrEmpty(groundColor) || string.IsNullOrEmpty(skyColor) ||
                                     string.IsNullOrEmpty(groundAngle) || string.IsNullOrEmpty(skyAngle));


            // TODO: later render both skydome and skybox together
            // Alpha values in skybox should provide a way to see through to skydome.
            // Skycolor sphere should be slightly larger than groundcolor hemisphere
            // and finally skybox should fit and be smaller than groundcolor hemisphere.

            if (generateSkyAndGround)
            {
                // Sphere
                // interpolate colors from groundColor and skyColor over hemispheres using specified sky and ground angles
                this.groundColors = X3DTypeConverters.MFVec3f(groundColor);
                this.groundAngles = X3DTypeConverters.Floats(groundAngle);
                this.skyColors    = X3DTypeConverters.MFVec3f(skyColor);
                this.skyAngles    = X3DTypeConverters.Floats(skyAngle);

                // Assign colors with matching angles
                colors = new Vector3[groundColors.Length + skyColors.Length];
                for (i = 0; i < skyColors.Length; i++)
                {
                    colors[i] = skyColors[i];
                }
                for (i = skyColors.Length; i < skyColors.Length + groundColors.Length; i++)
                {
                    colors[i] = groundColors[i - skyColors.Length];
                }
                angles    = new float[groundAngles.Length + skyAngles.Length + 2];
                angles[0] = 0;
                for (i = 0; i < skyAngles.Length; i++)
                {
                    angles[i + 1] = skyAngles[i];
                }
                angles[skyAngles.Length + 1] = 0;
                for (i = 0; i < groundAngles.Length; i++)
                {
                    angles[i + skyAngles.Length + 2] = 1.5f + groundAngles[i];
                }



                groundDivisor = (1.0f / groundColors.Length) * (float)Math.PI; // how many colors divided over 90 degrees (lower hemisphere)
                skyDivisor    = (1.0f / groundColors.Length) * (float)Math.PI; // how many colors divided over 90 degrees (upper hemisphere)

                // SKYDOME
                // outer sphere (sky)

                scaleSky     = Vector3.One * 6.0f;                                             // slightly bigger than ground hemisphere
                _shaderOuter = ShaderCompiler.ApplyShader(BackgroundShader.vertexShaderSource, // Make use of the BackgroundShader for Skydome Linear Interpolation
                                                          BackgroundShader.fragmentShaderSource);
                _shaderOuter.Link();

                List <Vertex> geometryOuterSphere = BuildSphereGeometryQuads(60, Vector3.Zero, 1.0f);
                Buffering.BufferShaderGeometry(geometryOuterSphere, out outerHandle.vbo4, out outerHandle.NumVerticies4);

                min = Vector3.Zero;
                max = Vector3.Zero;
                BoundingBox.CalculateBoundingBox(geometryOuterSphere, out max, out min);
                bboxOuter = max - min;

                // inner hemisphere (ground)

                //scaleGround = Vector3.One * 5.6f;
                //_shaderInner = ShaderCompiler.ApplyShader(BackgroundShader.vertexShaderSource,
                //                                 BackgroundShader.fragmentShaderSource);
                //_shaderInner.Link();

                //List<Vertex> geometryInnerHemisphere = BuildHemisphereGeometryQuads(60, new Vector3(0, 0.0f,0), 1.0f, false);
                //Buffering.BufferShaderGeometry(geometryInnerHemisphere, out innerHandle.vbo4, out innerHandle.NumVerticies4);

                //min = Vector3.Zero;
                //max = Vector3.Zero;
                //BoundingBox.CalculateBoundingBox(geometryInnerHemisphere, out max, out min);
                //bboxInner = max - min;


                skydomeTexture = MakeSkydomeTexture();
            }

            if (generateCube)
            {
                tex_cube = createCubeMapFromURIs();

                // SKYBOX
                // innermost skybox

                scaleCube = Vector3.One * 3.1f;

                _shaderInnerCube = ShaderCompiler.ApplyShader(CubeMapBackgroundShader.vertexShaderSource,
                                                              CubeMapBackgroundShader.fragmentShaderSource);
                _shaderInnerCube.Link();

                _pack           = new PackedGeometry();
                _pack._indices  = _cube.Indices;
                _pack._coords   = _cube.Vertices;
                _pack.Texturing = true;
                //_pack._colorIndicies = _boxGeometry.Colors;
                _pack._texCoords   = _cube.Texcoords;
                _pack.restartIndex = -1;

                _pack.Interleave();

                // BUFFER GEOMETRY
                cubeHandle = _pack.CreateHandle();
            }
        }
Beispiel #12
0
 internal Geometry(GeometryHandle handle)
 {
     Handle = handle;
 }
        public override void CollectGeometry(
            RenderingContext rc,
            out GeometryHandle handle,
            out BoundingBox bbox,
            out bool coloring,
            out bool texturing)
        {
            handle    = GeometryHandle.Zero;
            bbox      = BoundingBox.Zero;
            coloring  = false;
            texturing = true;

            int           line = 0;
            float         newLinePositionY;
            List <Vertex> geometry = new List <Vertex>();
            Vertex        v;

            fontStyle = this.FontStyle;

            float z = 0f;
            float h = 0.5f;

            string combined = string.Empty;

            if (this._strings.Count == 0)
            {
                this._strings.Add("Abc");
            }

            ForeColor = System.Drawing.Color.FromArgb(255, 255, 255, 255);
            ForeColor = System.Drawing.Color.Cyan;
            BackColor = System.Drawing.Color.FromArgb(0, 0, 0, 0);

            _start_position = new Vector3(0f, 0.5f, z);

            string family;
            float  size;

            foreach (string text in this._strings)
            {
                family = FontStyle.Family.First();
                family = string.IsNullOrEmpty(family) ? "Times New Roman" : family;
                size   = FontStyle.size * 10;
                Font   = new Font(family, size);

                newLinePositionY = (line * 0.5f);

                float scale = 0.01f;

                if (line == 0)
                {
                    v = new Vertex()
                    {
                        Position = new Vector3(0f, 0f + newLinePositionY, z) * scale,
                        TexCoord = new Vector2(0f, 1f)
                    };
                    geometry.Add(v);

                    v = new Vertex()
                    {
                        Position = new Vector3(1.0f, 0f + newLinePositionY, z) * scale,
                        TexCoord = new Vector2(1f, 1f)
                    };
                    geometry.Add(v);

                    v = new Vertex()
                    {
                        Position = new Vector3(1.0f, h + newLinePositionY, z) * scale,
                        TexCoord = new Vector2(1f, 0f)
                    };
                    geometry.Add(v);

                    v = new Vertex()
                    {
                        Position = new Vector3(0f, h + newLinePositionY, z) * scale,
                        TexCoord = new Vector2(0f, 0f)
                    };

                    geometry.Add(v);
                }

                combined += text + (line < this._strings.Count ? "\n" : "");

                line++;
            }

            _combined_text = combined;

            UpdateString(combined, out bbox);



            Buffering.BufferShaderGeometry(geometry, out handle.vbo4, out handle.NumVerticies4);
        }