Re: SetIndexBufferData

From: Michel Walsh (vanderghast_at_VirusAreFunnierThanSpam)
Date: 08/10/04

  • Next message: JuanK: "RE: Sound effects"
    Date: Tue, 10 Aug 2004 13:18:47 -0400
    
    

    Hi,

     Is your graphic card support int4 indexes? Have you tried with an array of
    short rather than an array of integer? Have you tried to save the mesh in a
    file (after having Clean it), and edit it into the mesh viewer tool? Have
    your tried with PositionNormal (not textured) CustomVertex?

        If int[] to short[] solves your problem, please, report it, so I will
    abandon my own investigation (I try to do the same, but following the
    example in the help file, but with just partial success, right now, ie, for
    less than around 600 values in the index buffer).

    Vanderghast, Access MVP

    "Jason" <Jason@mobiform.com> wrote in message
    news:%23NF0CUnfEHA.592@TK2MSFTNGP11.phx.gbl...
    > I cant seem to get my cylinder generation code to work. I suspect it's the
    > SetIndexBufferDataCall since the create (bool?) remains undefined and the
    > buffersize remains 0. I must be missing something stupid simple. Perhaps
    > someone can point it out.
    >
    > Jason
    >
    > //The C# following code will try to make a cylinder, tho its totally
    > unconfirmed since I have yet to see its output
    >
    >
    > int slices = (int)_slices.animVal;
    > int stacks = (int)_stacks.animVal;
    > int numFaces = ( slices * 2) + ( (stacks+1) * slices * 2);
    > int numVertices = (( stacks + 2 ) * slices ) + 2;
    >
    >
    > Microsoft.DirectX.Direct3D.Mesh mesh = new
    > Microsoft.DirectX.Direct3D.Mesh( numFaces, numVertices, MeshFlags.Managed,
    > CustomVertex.PositionNormalTextured.Format, device );
    >
    >
    >
    > float r1 = _r1.animVal.value;
    > float r2 = _r2.animVal.value;
    > float length = _length.animVal.value;
    >
    > CustomVertex.PositionNormalTextured[] verts;
    >
    > verts =
    (CustomVertex.PositionNormalTextured[])mesh.VertexBuffer.Lock(0,
    > typeof(CustomVertex.PositionNormalTextured), 0, numVertices);
    >
    > int []indices = new int[numFaces*3];
    > int currentIndice = 0;
    >
    > float currentY = length/2.0f;
    > float angleInc = SVGViewPlus.SVGDOM.SVG3D.Math.Constants.TWO_PI /
    slices;
    > float heightInc = length / (stacks+1);
    >
    > //middle center top
    > verts[numVertices-2].X = 0.0f;
    > verts[numVertices-2].Y = currentY;
    > verts[numVertices-2].Z = 0.0f;
    > verts[numVertices-2].Nx = 0.0f;
    > verts[numVertices-2].Ny = 1.0f;
    > verts[numVertices-2].Nz = 0.0f;
    > verts[numVertices-2].Tu = 0.0f;
    > verts[numVertices-2].Tv = 0.0f;
    >
    > //middle center bottom
    > verts[numVertices-1].X = 0.0f;
    > verts[numVertices-1].Y = -currentY;
    > verts[numVertices-1].Z = 0.0f;
    > verts[numVertices-1].Nx = 0.0f;
    > verts[numVertices-1].Ny = -1.0f;
    > verts[numVertices-1].Nz = 0.0f;
    > verts[numVertices-1].Tu = 1.0f;
    > verts[numVertices-1].Tv = 1.0f;
    >
    >
    > Matrix33 tempMatrix = new Matrix33();
    > SVGViewPlus.SVGDOM.SVG3D.Math.Vector3 vectorPoint = new
    > SVGViewPlus.SVGDOM.SVG3D.Math.Vector3();
    >
    > for ( int i = 0; i < (stacks + 2); i++ )
    > {
    > float angle = 0.0f;
    > float V = i / (stacks + 1);
    > float radius = SVGViewPlus.SVGDOM.SVG3D.Math.Functions.Lerp( r1, 0,
    r2,
    > 1, V );
    >
    >
    > for ( int j = 0; j < slices; j++ )
    > {
    > angle += angleInc;
    >
    > //build vertices
    > tempMatrix.BuildIdentity();
    > tempMatrix.BuildRotationY( angle );
    >
    > vectorPoint.X = 0.0f;
    > vectorPoint.Y = currentY;
    > vectorPoint.Z = radius;
    >
    > vectorPoint = SVGViewPlus.SVGDOM.SVG3D.Math.Vector3.TransformNormal(
    > vectorPoint, tempMatrix );
    >
    > int index = (i*slices)+j;
    >
    > verts[index].X = vectorPoint.X;
    > verts[index].Y = vectorPoint.Y;
    > verts[index].Z = vectorPoint.Z;
    >
    > vectorPoint.Y = 0.0f;
    > vectorPoint.Normalize();
    >
    > verts[index].Nx = vectorPoint.X;
    > verts[index].Ny = vectorPoint.Y;
    > verts[index].Nz = vectorPoint.Z;
    >
    > verts[index].Tu = angle /
    > SVGViewPlus.SVGDOM.SVG3D.Math.Constants.TWO_PI;
    > verts[index].Tv = V;
    > //Build indicies
    >
    > if ( i == 0 )
    > {//top cap
    > indices[currentIndice++] = numVertices-2;
    > indices[currentIndice++] = index;
    > if ( (j+1) >= slices )
    > {
    > indices[currentIndice++] = i*slices;
    > }
    > else
    > {
    > indices[currentIndice++] = index+1;
    > }
    > }
    > else if ( i == (stacks + 1) )
    > {//bottom cap
    > indices[currentIndice++] = numVertices-1;
    > indices[currentIndice++] = index;
    > if ( (j+1) >= slices )
    > {
    > indices[currentIndice++] = i*slices;
    > }
    > else
    > {
    > indices[currentIndice++] = index+1;
    > }
    > }
    > else
    > {
    > //1 tri
    > indices[currentIndice++] = index;
    > if ( (j+1) >= slices )
    > {
    > indices[currentIndice++] = (i-1)*slices;
    > }
    > else
    > {
    > indices[currentIndice++] = ((i-1)*slices)+j+1;
    > }
    > indices[currentIndice++] = ((i-1)*slices)+j;
    >
    > //2 tri
    > indices[currentIndice++] = index;
    > indices[currentIndice++] = ((i-1)*slices)+j;
    > if ( (j-1) < 0 )
    > {
    > indices[currentIndice++] = (i)*slices+j-1+slices;
    > }
    > else
    > {
    > indices[currentIndice++] = ((i-1)*slices)+j-1;
    > }
    > }
    >
    > }
    >
    > currentY -= heightInc;
    > }
    >
    >
    > mesh.SetIndexBufferData( indices, LockFlags.None );
    >
    > // mesh.IndexBuffer.SetData( indices, 0, LockFlags.None );
    >
    > // Mesh mesh = Microsoft.DirectX.Direct3D.Mesh.Cylinder(device,
    > _r1.animVal.value, _r2.animVal.value, _length.animVal.value,
    > (int)_slices.animVal, (int) _stacks.animVal);
    > _mesh.D3DMesh = mesh.Clone(MeshFlags.Managed ,
    > CustomVertex.PositionNormalTextured.Format, device);
    > mesh.Dispose();
    >
    > // GenerateRandomTextureCoordinates();
    >
    >


  • Next message: JuanK: "RE: Sound effects"

    Relevant Pages

    • Re: Array of byte of unknown size
      ... The example given in the control's help file is for Visual Basic - so ... same thing with a variant array in Delphi ... I see out of memory errors in your future. ...
      (borland.public.delphi.language.objectpascal)
    • Re: arithenco Help
      ... You might be right about it having to do with the number of significant numbers in the array. ... I accidentally discovered that if I quantize A and then pass the quantized A with the original 'counts' to arithenco it works perfectly. ... Here's a desciption of it from the help file: ... "The vector counts represents the source's statistics by listing the number of times each symbol of the source's alphabet occurs in a test data set." ...
      (comp.soft-sys.matlab)
    • Re: opening a file problem
      ... file names (even if only one filename is selected). ... So you have to deal with an array of values not a single string. ... Dim FName As Variant ...
      (microsoft.public.excel.programming)
    • Re: Tips on domain aggregate replacements
      ... array of variant of your records. ... See the help file. ... > need to run the statement from VBA. ... > I know how to run action queries using RunSQL, but can I run select ...
      (microsoft.public.access.modulesdaovba)