Skip to main content
gamedev.net
🔒 Locked

ProcessVertices()?????

Started by BeanDog 2 replies 700+ views
Original Post
BeanDog
BeanDog
Vertex buffers have been the bane of my existence for some time now, but I''ve finally decided to use them, as it''s the only way to get DX to actually give you the screen coordinates of the transformed points. Here''s my code to fill a D3DTLVERTEX array with the transformed D3DLVERTEX array:
//now do the vertex buffer thing...
D3DLVERTEX* tv = new D3DLVERTEX[numvtx];
D3DTLVERTEX* tlv = new D3DTLVERTEX[numvtx];
		
if(FAILED(vb->Lock(DDLOCK_WRITEONLY, (void**)&tv, NULL)))Ending=true;
for(int i = 0; i < numvtx; i++)
{
	tv = fvtx[i];
}
vb->Unlock();
	
if(FAILED(vbt->ProcessVertices(D3DVOP_TRANSFORM, 0, numvtx, vb, 0, d3d.D3DDevice, 0)))Ending=true;
	
if(FAILED(vbt->Lock(DDLOCK_READONLY, (void**)&tlv, NULL)))Ending=true;
for(i = 0; i < numvtx; i++)
{
	tlvtx[i] = tlv[i];
}
vbt->Unlock();
 
There has got to be a better way to do this! Not only that, but this doesn''t work! Everything is properly inited, and no calls fail, but the tlvtx array doesn''t contain any useful data afterward! ~BenDilts( void ); Bean Dog
BigCarlito
BigCarlito
First of all, you should replace:

D3DLVERTEX* tv = new D3DLVERTEX[numvtx];
D3DTLVERTEX* tlv = new D3DTLVERTEX[numvtx];

with just:

D3DLVERTEX* tv;
D3DTLVERTEX* tlv;

there''s no need to set these pointers to point to arrays in system memory, because the Lock function changes your pointer to point at the block of memory it creates when you called pD3D->CreateVertexBuffer. If you''re not familiar with this, check out the vbuffer sample in the DX7SDK.

Secondly, the line:

tv = fvtx;

Should be:

tv[i] = fvtx[i];

I''m surprised that even compiled.

Otherwise, everything else appears to be OK!
Good luck!



Zeus Interactive
BeanDog
BeanDog
Thanks for responding. I got rid of the new operator. But there''s still the same problem: The data returned are irrelevant and innaccurate. I have a bunch of points that I passed in as a D3DPT_POINTLIST to DrawPrimitive, just to test it. I did the code I sent you just before calling the DrawPrimitive call. The points returned by the ProcessVertices call are not the same as those drawn by the DrawPrimitive call. Que pasa? Here''s my debug screen output on the sx,sy, and sz values:

1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223925760,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223926272,1229539840,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
1223925760,1229540352,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0
255,192,0

Sorry, that was painful. You must remember this is streaming - this is what the program saw as I added and deleted points during the execution of the program. Why is this happening?
BigCarlito
BigCarlito
Ouch, that WAS painful! :-) Here is my code (pulled this outta the wayback machine):

        
// Create the vertex buffer.

D3DVERTEXBUFFERDESC vbSrcDesc;
ZeroMemory( &vbSrcDesc, sizeof(D3DVERTEXBUFFERDESC) );
vbSrcDesc.dwSize = sizeof(D3DVERTEXBUFFERDESC);
vbSrcDesc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
vbSrcDesc.dwFVF = D3DFVF_LVERTEX;
vbSrcDesc.dwNumVertices = m_dwNumVertices;
if( FAILED( pD3D->CreateVertexBuffer( &vbSrcDesc, &m_pSrcVertexBuffer, 0L ) ) )
return E_FAIL;

// Create the vertex buffer.

D3DVERTEXBUFFERDESC vbDestDesc;
ZeroMemory( &vbDestDesc, sizeof(D3DVERTEXBUFFERDESC) );
vbDestDesc.dwSize = sizeof(D3DVERTEXBUFFERDESC);
vbDestDesc.dwCaps = D3DVBCAPS_SYSTEMMEMORY;
vbDestDesc.dwFVF = D3DFVF_TLVERTEX;
vbDestDesc.dwNumVertices = m_dwNumVertices;
if( FAILED( pD3D->CreateVertexBuffer( &vbDestDesc, &m_pDstVertexBuffer, 0L ) ) )
return E_FAIL;

D3DLVERTEX* pVertices;
float vx,vy,vz,tu,tv;
if( SUCCEEDED( m_pSrcVertexBuffer->Lock( DDLOCK_WAIT,
(VOID**)&pVertices,
NULL ) ) )
{
for (i = 0; i < m_dwNumVertices; i++)
{
fin >> vx >> ch >> vy >> ch >> vz >> ch >> tu >> ch >> tv >> ch;
pVertices<i> = D3DLVERTEX( D3DVECTOR(vx,vy,vz),
D3DRGB(1,1,1),0,
tu, tv);
}

m_pSrcVertexBuffer->Unlock();
}
else
return E_FAIL;

m_pDstVertexBuffer->ProcessVertices( D3DVOP_TRANSFORM,
0,
dwVertCount,
m_pSrcVertexBuffer,
0,
pd3dDevice,
0);


Then you should be able to lock the m_pDstVertexBuffer and read the transformed results.
Hope that helps!


Edited by - BigCarlito on September 28, 2000 1:04:08 AM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.