Пример #1
0
        /// <summary>
        /// Fetch a view from Google Street View API using current camera frustum.
        /// </summary>
        /// <param name="position">
        /// Current position in 3D space.
        /// </param>
        /// <param name="orientation">
        /// Current orientation in 3D space.
        /// </param>
        /// <returns>
        /// A Bitmap image representing the current view camera frustum.
        /// </returns>
        public Bitmap FetchView(Vector3 position, Quaternion orientation)
        {
            Vector3 orientationAngles;

            orientationAngles = QuaternionExtensions.ExtractPitchYawRoll(orientation);

            return(FetchView(position, orientationAngles.X, orientationAngles.Y));
        }
Пример #2
0
        public override void Render(RenderingContext rc)
        {
            base.Render(rc);

            rc.PushMatricies();

            //if (!loadedGeometry) return;

            // PREPARE shape for rendering

            NormalMatrix = new Matrix3(rc.matricies.modelview); // NormalMatrix = M4GetUpper3x3(ModelviewMatrix);

            var shader = CurrentShader;

            if (shader != null)
            {
                // CurrentShader = linkedShaders;


                shader.Use();

                if (shader.IsTessellator)
                {
                    if (shader.IsBuiltIn)
                    {
                        // its a built in system shader so we are using the the fixed parameter inbuilt tesselator
                        CurrentShader.SetFieldValue("TessLevelInner", this.tessLevelInner);
                        CurrentShader.SetFieldValue("TessLevelOuter", this.tessLevelOuter);
                    }
                }

                shader.SetFieldValue("lightingEnabled", 1);
                shader.SetFieldValue("headlightEnabled", 0);
                shader.SetFieldValue("calib1", rc.cam.calibTrans);
                shader.SetFieldValue("calib2", rc.cam.calibOrient);

                if (depthMask)
                {
                    Matrix4 MVP     = ApplyGeometricTransformations(rc, shader, this);
                    Vector3 lookat  = QuaternionExtensions.Rotate(rc.cam.Orientation, Vector3.UnitZ);
                    Vector3 forward = new Vector3(lookat.X, 0, lookat.Z).Normalized();
                    Vector3 up      = Vector3.UnitY;
                    Vector3 left    = up.Cross(forward);

                    Vector2 orient;
                    Vector3 position;

                    orient   = QuaternionExtensions.ExtractPitchYawRoll(rc.cam.Orientation.Inverted()).Xy; // pitch and yaw only
                    position = rc.cam.Position;

                    shader.SetFieldValue("headlightEnabled", NavigationInfo.HeadlightEnabled ? 1 : 0);
                    shader.SetFieldValue("sceneCameraPosition", position);
                    shader.SetFieldValue("model", ref MVP);
                    shader.SetFieldValue("orientation", orient);
                    shader.SetFieldValue("lookat", rc.cam.Direction);
                    shader.SetFieldValue("forward", forward);
                    shader.SetFieldValue("up", up);
                    shader.SetFieldValue("left", left);
                }
                else
                {
                    //REFACTOR!!

                    RefreshDefaultUniforms(shader);

                    if (shader.IsTessellator)
                    {
                        RefreshTessUniforms(shader);
                    }

                    //Matrix4 MVP = rc.cam.GetWorldOrientation() ;

                    //shader.SetFieldValue("modelview", ref MVP);

                    //shader.SetFieldValue("modelview", ref MVP); //GL.UniformMatrix4(uniformModelview, false, ref rc.matricies.modelview);
                    shader.SetFieldValue("projection", ref rc.matricies.projection);
                    shader.SetFieldValue("camscale", rc.cam.Scale.X);                        //GL.Uniform1(uniformCameraScale, rc.cam.Scale.X);
                    shader.SetFieldValue("X3DScale", rc.matricies.Scale);                    //GL.Uniform3(uniformX3DScale, rc.matricies.Scale);
                    shader.SetFieldValue("coloringEnabled", coloring ? 1 : 0);
                    shader.SetFieldValue("texturingEnabled", this.texturingEnabled ? 1 : 0); //GL.Uniform1(uniforms.a_texturingEnabled, this.texturingEnabled ? 1 : 0);
                    shader.SetFieldValue("normalmatrix", ref NormalMatrix);
                }

                ApplyAppearance(rc);

                // RENDER shape
                RenderShape(rc);
            }

            if (drawBoundingBox && bbox != null)
            {
                RenderBoundingBox(rc);
            }
        }