Example #1
0
 public unsafe VertexInfoWeights(VertexInfo VertexInfo)
 {
     fixed (float* WPtr = W)
     {
         for (int n = 0; n < 8; n++) WPtr[n] = VertexInfo.Weights[n];
     }
 }
Example #2
0
 public VertexInfoWeights(VertexInfo vertexInfo)
 {
     for (var n = 0; n < 8; n++)
     {
         W[n] = vertexInfo.Weights[n];
     }
 }
Example #3
0
 private static void PointMultAdd(ref VertexInfo dest,ref VertexInfo src,float f)
 {
     dest.Position += src.Position * f;
     dest.Texture  += src.Texture * f;
     dest.Color    += src.Color * f;
     dest.Normal   += src.Normal * f;
 }
 public VertexInfoWeights(VertexInfo vertexInfo)
 {
     fixed(float *wPtr = W)
     {
         for (var n = 0; n < 8; n++)
         {
             wPtr[n] = vertexInfo.Weights[n];
         }
     }
 }
Example #5
0
        private VertexInfo[,] GetControlPoints(int uCount,int vCount)
        {
            var controlPoints = new VertexInfo[uCount,vCount];

            var vertexPtr =
                (byte*)GpuProcessor.Memory.PspAddressToPointerSafe(
                    GpuStateStructPointer.GetAddressRelativeToBaseOffset(GpuStateStructPointer.VertexAddress));
            var vertexReader = new VertexReader();

            vertexReader.SetVertexTypeStruct(GpuStateStructPointer.VertexState.Type,vertexPtr);

            for (var u = 0; u < uCount; u++)
            {
                for (var v = 0; v < vCount; v++)
                {
                    controlPoints[u,v] = vertexReader.ReadVertex(v * uCount + u);
                    //Console.WriteLine("getControlPoints({0}, {1}) : {2}", u, v, controlPoints[u, v]);
                }
            }
            return(controlPoints);
        }
Example #6
0
 public virtual void DrawCurvedSurface(GlobalGpuState GlobalGpuState, GpuStateStruct* GpuStateStruct, VertexInfo[,] Patch, int UCount, int VCount)
 {
     Console.Error.WriteLine("GpuImpl.DrawCurvedSurface Not Implemented!!");
 }
Example #7
0
 public void ReadVertices(int Index, VertexInfo* VertexInfo, int Count)
 {
     //Console.WriteLine("ReadVertices: {0:X8} : {1}, {2}, {3}", new IntPtr(BasePointer), Index, Count, VertexSize);
     for (int n = 0; n < Count; n++)
     {
         ReadVertex(Index + n, &VertexInfo[n]);
     }
 }
Example #8
0
        public void ReadVertex(int Index, VertexInfo* VertexInfo)
        {
            this.PointerOffset = VertexSize * Index;
            this.VertexInfo = VertexInfo;

            // Vertex has to be aligned to the maxium size of any component.
            //VertexAlignment();

            ReadWeights();
            ReadTextureCoordinates();
            ReadColor();
            ReadNormal();
            ReadPosition();
        }
Example #9
0
        private void DrawBezier(int uCount,int vCount)
        {
            var divS = GpuStateStructPointer.PatchState.DivS;
            var divT = GpuStateStructPointer.PatchState.DivT;

            if ((uCount - 1) % 3 != 0 || (vCount - 1) % 3 != 0)
            {
                Logger.Warning("Unsupported bezier parameters ucount=" + uCount + " vcount=" + vCount);
                return;
            }
            if (divS <= 0 || divT <= 0)
            {
                Logger.Warning("Unsupported bezier patches patch_div_s=" + divS + " patch_div_t=" + divT);
                return;
            }

            //initRendering();
            //boolean useTexture = context.vinfo.texture != 0 || context.textureFlag.isEnabled();
            //boolean useNormal = context.lightingFlag.isEnabled();

            var anchors = GetControlPoints(uCount,vCount);

            // Don't capture the ram if the vertex list is embedded in the display list. TODO handle stall_addr == 0 better
            // TODO may need to move inside the loop if indices are used, or find the largest index so we can calculate the size of the vertex list

            /*
             * if (State.captureGeNextFrame && !isVertexBufferEmbedded()) {
             *  Logger.Info("Capture drawBezier");
             *  CaptureManager.captureRAM(context.vinfo.ptr_vertex, context.vinfo.vertexSize * ucount * vcount);
             * }
             */

            // Generate patch VertexState.
            var patch = new VertexInfo[divS + 1,divT + 1];

            // Number of patches in the U and V directions
            var upcount = uCount / 3;
            var vpcount = vCount / 3;

            var ucoeff = new float[divS + 1][];

            for (var j = 0; j <= divT; j++)
            {
                var vglobal = (float)j * vpcount / divT;

                var vpatch = (int)vglobal;  // Patch number
                var v      = vglobal - vpatch;
                if (j == divT)
                {
                    vpatch--;
                    v = 1.0f;
                }
                var vcoeff = BernsteinCoeff(v);

                for (var i = 0; i <= divS; i++)
                {
                    var uglobal = (float)i * upcount / divS;
                    var upatch  = (int)uglobal;
                    var u       = uglobal - upatch;
                    if (i == divS)
                    {
                        upatch--;
                        u = 1.0f;
                    }
                    ucoeff[i] = BernsteinCoeff(u);

                    var p = default(VertexInfo);
                    p.Position = Vector4.Zero;
                    p.Normal   = Vector4.Zero;

                    for (var ii = 0; ii < 4; ++ii)
                    {
                        for (var jj = 0; jj < 4; ++jj)
                        {
                            /*
                             * Console.WriteLine(
                             *  "({0}, {1}) : {2} : {3} : {4}",
                             *  ii, jj,
                             *  p.Position, anchors[3 * upatch + ii, 3 * vpatch + jj].Position,
                             *  ucoeff[i][ii] * vcoeff[jj]
                             * );
                             */
                            PointMultAdd(
                                ref p,
                                ref anchors[3 * upatch + ii,3 * vpatch + jj],
                                ucoeff[i][ii] * vcoeff[jj]
                                );
                        }
                    }

                    p.Texture.X = uglobal;
                    p.Texture.Y = vglobal;

                    patch[i,j] = p;

                    /*
                     * Console.WriteLine(
                     *  "W: ({0}, {1}) : {2}",
                     *  i, j,
                     *  patch[i, j]
                     * );
                     */

                    /*
                     * if (useTexture && context.vinfo.texture == 0)
                     * {
                     *  p.t[0] = uglobal;
                     *  p.t[1] = vglobal;
                     * }
                     */
                }
            }

            GpuProcessor.GpuImpl.BeforeDraw(GpuStateStructPointer);
            GpuProcessor.GpuImpl.DrawCurvedSurface(GlobalGpuState,GpuStateStructPointer,
                                                   patch,uCount,vCount);
        }