• entries
72
38
• views
22451

# not alot of time

119 views

but I did get quite a few things done tonight. I'll just go over them quickly because I'm just do happy.

Sphere to Plane tests are going well. It reports collisions properly. Now I have to solve the time of collision.

Tossed in wireframe toggle with 'w' key. Which caused me to move the set render state block into a funcion so I dont have to invalidate/restore just to whitch into wireframe.

Finished the dynamic plane creation (almost). I still load it as a file, just to grab a material for the object. But it creates a plane and sets its difuse and tex coords. The tex coords worked out well because the way the d3d crate polygon function makes the plane, its rotated a bit. Pic and the vertices are easy to pinpoint with a min/max search.

Thats pretty much it. Here is the new code that creates a plane and gives it tex coords. For all to enjoy.

HRESULT hr = S_OK;unsigned int indices, verts, poly = 2;verts = 4;indices = poly * 3;LPDIRECT3DVERTEXBUFFER9 vb;LPD3DXMESH mbuf = NULL;hr = D3DXCreatePolygon(g_pd3dDevice,5.0f,4, &mbuf, NULL);hr = D3DXComputeNormals(mbuf, NULL);LPD3DXMESH mb2;hr = mbuf->CloneMeshFVF(0,MY_VERT_FVF,g_pd3dDevice,&mb2);SAFE_RELEASE(mbuf);verts = mb2->GetNumVertices();MY_VERT* myVerts = new MY_VERT[verts];mb2->LockVertexBuffer(0, (void**)&vb);memcpy(myVerts,vb,verts*sizeof(MY_VERT));float minx,maxx,miny,maxy;float tx,ty;minx = maxx = miny = maxy = 0.5;for(unsigned int i=0;i{	tx = myVerts.x;	ty = myVerts.y;	if(tx < minx)		minx = tx;	if(tx > maxx)		maxx = tx;	if(ty < miny)		miny = ty;	if(ty > maxy)		maxy = ty;	myVerts.color = 0xFFFFFFFF;}myVerts[0].tu = 0.5f;myVerts[0].tv = 0.5f;for(unsigned int i=1;i{	tx = myVerts.x;	ty = myVerts.y;	if(tx == minx)	{		myVerts.tu = 0.0f;		myVerts.tv = 1.0f;	}	if(tx == maxx)	{		myVerts.tu = 1.0f;		myVerts.tv = 0.0f;	}	if(ty == miny)	{		myVerts.tv = 0.0f;		myVerts.tu = 0.0f;	}	if(ty == maxy)	{		myVerts.tv = 1.0f;		myVerts.tu = 1.0f;	}}memcpy(vb,myVerts,verts*sizeof(MY_VERT));mb2->UnlockVertexBuffer();gMeshes->AddMesh(strmesh.c_str(), mb2);delete[] myVerts;Direction = Vector3(0.0f,0.0f,1.0f);

There are no comments to display.

## Create an account

Register a new account