Skip to main content
gamedev.net
🔒 Locked

Stride

Started by Newbie00 5 replies 450+ views
Original Post
Newbie00
Newbie00
Does anyone know how to find the Stride of objects from a game that is almost made? Example:
if(m_Stride == 32) {
        //Do shit here
}
 
The 32 is for the player models. I got that one from a friend but he won''t tell me how he found out how 32 is the player models.
cowsarenotevil
cowsarenotevil
You, sir, make no sense. What on earth are you talking about?
-~-The Cow of Darkness-~-
Newbie00
Newbie00
Let me try to explain this better.

First

unsigned int m_Stride;



HRESULT f_IDirect3DDevice8::SetStreamSource(UINT StreamNumber, IDirect3DVertexBuffer8 *pStreamData, UINT Stride) {
if (StreamNumber == 0)
m_Stride = Stride;
return f_pDirect3DDevice->SetStreamSource(StreamNumber, pStreamData, Stride);
}


Then


HRESULT f_IDirect3DDevice8::DrawIndexedPrimitive(D3DPRIMITIVETYPE Type, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount) {
if (Lambert) {
if(m_Stride == 32) {
DWORD old_state;
f_pDirect3DDevice->CreateStateBlock(D3DSBT_ALL, &old_state);
f_pDirect3DDevice->CaptureStateBlock(old_state);

f_pDirect3DDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

f_pDirect3DDevice->SetLight( 0, &Light );
f_pDirect3DDevice->LightEnable( 0, true );


HRESULT hResult = f_pDirect3DDevice->DrawIndexedPrimitive(Type, MinIndex, NumVertices, StartIndex, PrimitiveCount);

f_pDirect3DDevice->ApplyStateBlock(old_state);
f_pDirect3DDevice->DeleteStateBlock(old_state);

return hResult;
}
}

return f_pDirect3DDevice->DrawIndexedPrimitive(Type, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}


Somehow this makes it so that the player models in the game glow the color you have specified in Light. I really don''t understand how if m_Stride equals 32 that it would select only the player models.
JTippetts
JTippetts
I don''t know Jack about DirectX since I don''t use Windows, but it looks like Stride is actually the size of each individual vertex data element.

It looks like that SetStreamSource() function accepts a pointer to an array of vertex data. Stride is the size of each element in the array.

Say you have a vertex with the following members:

struct Vertex{
float x, y, z;
float r, g, b;
};

Where x,y,z is the vertex coordinates, and r,g,b is the diffuse color. The Stride of an array of these Vertex structures would be 6*sizeof(float), or sizeof(Vertex).
The function needs this Stride information in the case where vertex data can be of any format you wish to specify; Stride tells the function what to add to move to the next Vertex structure.

Or, so it looks to me.


Josh
vertexnormal AT linuxmail DOT org


Check out Golem at:
My cheapass website
daerid
daerid
This would probably be better off in the Game Programming forum
daerid@gmail.com
JohnBolton
JohnBolton
I would like to hear what you mean by "almost made".
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

Topic Locked

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

Sign in to reply to this topic.