Exemplo n.º 1
0
        public int SetBuffer2D(S4Camera cam, CustomVertex.PositionNormalColored[] buf, int ptr)
        {
            if (!qBelow)
            {
                return(ptr);
            }
            for (int i = 0; i < Base.NF * 3; i += 3)
            {
                Vector3 v0 = Coords3D[Base.Faces[i]];
                Vector3 v1 = Coords3D[Base.Faces[i + 1]];
                Vector3 v2 = Coords3D[Base.Faces[i + 2]];
                if (v0.Z != WRONGPT && v1.Z != WRONGPT && v2.Z != WRONGPT)
                {
                    bool qinv = true;
#if true
                    Vector3 v1x = v1, v2x = v2;
                    v1x.Subtract(v0); v2x.Subtract(v0);
                    Vector3 n = new Vector3(v1x.Y * v2x.Z - v1x.Z * v2x.Y, v1x.Z * v2x.X - v1x.X * v2x.Z, v1x.X * v2x.Y - v1x.Y * v2x.X);
                    if (n.Z < 0)
                    {
                        n.Scale(-1f); qinv = false;
                    }
                    n.Z += n.Length() / 4;
                    n.Normalize();
#else
                    Vector3 n = new Vector3(0.91f, 0.3f, 0.3f);
#endif
                    buf[ptr++] = new CustomVertex.PositionNormalColored(v0, n, Col);
                    buf[ptr++] = new CustomVertex.PositionNormalColored(qinv ? v1 : v2, n, Col);
                    buf[ptr++] = new CustomVertex.PositionNormalColored(qinv ? v2 : v1, n, Col);
                }
            }
            return(ptr);
        }
Exemplo n.º 2
0
        public S3DirectX()
        {
            m_bUseDepthBuffer = true;

//            Camera _cam = new CCamera();
            Camera _cam = new S4Camera(4, 2);

            m_Camera = _cam;
            m_Light  = new CameraLight(_cam);
        }
Exemplo n.º 3
0
        public void RecalcCoord(S4Camera cam)
        {
            qBelow = true;
            int dim = Base.PDim;

            if (ExtraTwist != null)
            {
                for (int j = 0; j < dim; j++)
                {
                    double s = 0;
                    for (int k = 0; k < dim; k++)
                    {
                        s += ExtraTwist[k, j] * FCtr[k];
                    }
                    CurPt[j] = s;
                }
                if (cam.AbovePlane(CurPt))
                {
                    qBelow = false;
                    return;
                }
            }
            for (int i = 0; i < Base.NV; i++)
            {
                if (ExtraTwist != null)
                {
                    for (int j = 0; j < dim; j++)
                    {
                        double s = 0;
                        for (int k = 0; k < dim; k++)
                        {
                            s += ExtraTwist[k, j] * Coords[i * dim + k];
                        }
                        CurPt[j] = s;
                    }
                }
                else
                {
                    for (int j = 0; j < dim; j++)
                    {
                        CurPt[j] = Coords[i * dim + j];
                    }
                }
                bool x = cam.Apply(CurPt, out Coords3D[i]);
                if (!x)
                {
                    Coords3D[i].Z = WRONGPT;
                }
            }
        }
Exemplo n.º 4
0
 public int SetBuffer1D(S4Camera cam, CustomVertex.PositionNormalColored[] buf, int ptr, int col)
 {
     if (!qBelow)
     {
         return(ptr);
     }
     for (int i = 0; i < Base.NE * 2; i += 2)
     {
         Vector3 v0 = Coords3D[Base.Edges[i]];
         Vector3 v1 = Coords3D[Base.Edges[i + 1]];
         if (v0.Z != WRONGPT && v1.Z != WRONGPT)
         {
             buf[ptr++] = new CustomVertex.PositionNormalColored(v0, new Vector3(0, 0, 1), col);
             buf[ptr++] = new CustomVertex.PositionNormalColored(v1, new Vector3(0, 0, 1), col);
         }
     }
     return(ptr);
 }