示例#1
0
        //virtual public bool IsTileInFrustum(PlaneD[]frustum)
        //{
        //    InViewFrustum = false;
        //    Vector3d center = sphereCenter;
        //    if (this.Level < 2 && dataset.Projection == ProjectionType.Mercator)
        //    {
        //        return true;
        //    }
        //    Vector4d centerV4 = new Vector4d(center.X , center.Y , center.Z , 1f);
        //    Vector3d length = Vector3d.Create(sphereRadius, 0, 0);
        //    double rad = length.Length();
        //    for (int i = 0; i < 6; i++)
        //    {
        //        if (frustum[i].Dot(centerV4) + rad < 0)
        //        {
        //            return false;
        //        }
        //    }
        //    InViewFrustum = true;
        //    return true;
        //}
        public virtual bool IsTileInFrustum(PlaneD[] frustum)
        {
            if (this.Level < 2 && (dataset.Projection == ProjectionType.Mercator || dataset.Projection == ProjectionType.Toast))
            {
            //    return true;
            }
            InViewFrustum = false;

            Vector4d centerV4 = new Vector4d(sphereCenter.X, sphereCenter.Y, sphereCenter.Z, 1f);

            for (int i = 0; i < 6; i++)
            {
                if (frustum[i].Dot(centerV4)  < -sphereRadius)
                {
                    return false;
                }
            }
            InViewFrustum = true;

            return true;
        }
示例#2
0
 //        //private static void DrawPlanet2pnt5d(Device device, int planetID)
 //        //{
 //        //    Vector3 planetPosition = planet3dLocations[planetID];
 //        //    if (planetID < 9 )
 //        //    {
 //        //        device.SetTexture(0, planetTextures[planetID]);
 //        //    }
 //        //    else if (planetID == 9 )
 //        //    {
 //        //        device.SetTexture(0, planetTextures[19]);
 //        //    }
 //        //    else
 //        //    {
 //        //        return;
 //        //    }
 //        //    double diameter = planetDiameters[planetID];
 //        //    float radius = (double)(diameter / 2.0 );
 //        //    if (!Settings.Active.ActualPlanetScale)
 //        //    {
 //        //        if (planetID != 0)
 //        //        {
 //        //            radius *= 1000;
 //        //        }
 //        //        else
 //        //        {
 //        //            radius *= 100;
 //        //        }
 //        //    }
 //        //    CustomVertex.PositionTextured[] points = new CustomVertex.PositionTextured[4];
 //        //    Vector3 pos = planet3dLocations[planetID];
 //        //    points[0].Position = new Vector3(pos.X + radius, pos.Y, pos.Z + radius);
 //        //    points[0].Tu = 0;
 //        //    points[0].Tv = 0;
 //        //    points[1].Position = new Vector3(pos.X - radius, pos.Y, pos.Z + radius);
 //        //    points[1].Tu = 1;
 //        //    points[1].Tv = 0;
 //        //    points[2].Position = new Vector3(pos.X + radius, pos.Y, pos.Z - radius);
 //        //    points[2].Tu = 0;
 //        //    points[2].Tv = 1;
 //        //    points[3].Position = new Vector3(pos.X - radius, pos.Y, pos.Z - radius);
 //        //    points[3].Tu = 1;
 //        //    points[3].Tv = 1;
 //        //    //Matrix mat = Microsoft.DirectX.Matrix.RotationZ(rotationAngle);
 //        //    device.DrawUserPrimitives(PrimitiveType.TriangleStrip, points.Length - 2, points);
 //        //    // Render Stuff Here
 //        //}        public static bool Lighting = true;
 //        //private static void DrawPlanet3d(Device device, int planetID, Vector3d centerPoint)
 //        //{
 //        //    if (planetID == (int)SolarSystemObjects.Sun)
 //        //    {
 //        //        device.RenderState.Lighting = false;
 //        //    }
 //        //    else
 //        //    {
 //        //        device.RenderState.Lighting = Lighting;
 //        //    }
 //        //    double radius = GetAdjustedPlanetRadius(planetID);
 //        //    double rotationCurrent = 0;
 //        //    if (planetID == (int)SolarSystemObjects.Earth)
 //        //    {
 //        //        rotationCurrent = Coordinates.MstFromUTC2(SpaceTimeController.Now, 0)/180.0 * Math.PI;
 //        //    }
 //        //    else
 //        //    {
 //        //        rotationCurrent = (((jNow - 2451545.0) / planetRotationPeriod[planetID]) * Math.PI * 2) % (Math.PI * 2);
 //        //    }
 //        //    Matrix matOld = device.Transform.World;
 //        //    matOld = device.Transform.World;
 //        //    Matrix matLocal = device.Transform.World;
 //        //    Vector3d translation = planet3dLocations[planetID]-centerPoint;
 //        //    matLocal.Scale((double)radius, (double)radius, (double)radius);
 //        //    matLocal.Multiply(Matrix.RotationY((double)-rotationCurrent));
 //        //    matLocal.Multiply(Matrix.RotationX((double)(planetTilts[planetID]*RC)));
 //        //    matLocal.Multiply(Matrix.Translation(translation.Vector3));
 //        //    device.Transform.World = matLocal;
 //        //    Earth3d.MainWindow.MakeFrustum();
 //        //    DrawSphere(device, planetTexturesMaps[planetID], GetNameFrom3dId(planetID));
 //        //    if (planetID == 5)
 //        //    {
 //        //        device.RenderState.CullMode = Cull.None;
 //        //        Color oldAmbient = device.RenderState.Ambient;
 //        //        device.RenderState.Ambient = Color.FromArgb(40, 40, 40);
 //        //        DrawRings(device);
 //        //        device.RenderState.Ambient = oldAmbient;
 //        //        device.RenderState.CullMode = Cull.Clockwise;
 //        //    }
 //        //    device.Transform.World = matOld;
 //        //    Earth3d.MainWindow.MakeFrustum();
 //        //    device.RenderState.Lighting = false;
 //        //}
 //        public static bool Lighting = true;
 public static bool IsPlanetInFrustum(RenderContext renderContext, float rad)
 {
     PlaneD[] frustum = renderContext.Frustum;
     Vector3d center =  Vector3d.Create(0, 0, 0);
     Vector4d centerV4 = new Vector4d(0, 0, 0, 1f);
     for (int i = 0; i < 6; i++)
     {
         if (frustum[i].Dot(centerV4) + rad < 0)
         {
             return false;
         }
     }
     return true;
 }
示例#3
0
 //   public static Plane Normalize(Plane p);
 //   public static Vector3 IntersectLine(Plane p, Vector3 v1, Vector3 v2);
 //   public static Plane FromPointNormal(Vector3 point, Vector3 normal);
 //   public static Plane FromPoints(Vector3 p1, Vector3 p2, Vector3 p3);
 //    public void Transform(Matrix m);
 //    public static Plane Transform(Plane p, Matrix m);
 //    public void Scale(float s);
 //    public static Plane Scale(Plane p, float s);
 //   public float Dot(Vector3 v);
 public double Dot(Vector4d v)
 {
     //return ((((planeRef[4] * *(((float*) (&v + 4)))) + (planeRef[8] * *(((float*) (&v + 8))))) + (planeRef[12] * *(((float*) (&v + 12))))) + (planeRef[0] * *(((float*) &v))));
     return B * v.Y + C * v.Z + D * v.W + A * v.X;
 }