Sign in to follow this  
Crazyfool

Direct3d9 rendering

Recommended Posts

Hi, I have been working with tile maps from files and got a lot of things worked out. Right now I'm messing around with rendering only what the person can see, and not drawing stuff outside the screen. For testing, I'm doin a semi small screen with constant dimensions, just to test the idea. Everything works fine and dandy except when the camera moves, the screen thats drawn moves too, but at a slower rate. So if you're zoomed in, it looks normal for a while, but then it starts to move too far away and then its blackness =( Here's my camera move left, and the other move functions are pretty much the same:
void Camera::moveLeft()
{
	D3DXVECTOR3 vDirection;

	D3DXVec3Normalize(&vDirection, &(vLookAtPt - vEyePt));
	D3DXVec3Cross(&vDirection, &vDirection, &vUp);
	D3DXVec3Normalize(&vDirection, &vDirection);

        /*
        Below is used to make it so you move faster when zoomed out
        */
	vDirection *= (int)(1 + (vEyePt.y - vLookAtPt.y) / 6);

	vEyePt += vDirection * moveRate;
	vLookAtPt += vDirection * moveRate;
}

/*
moveRate is 0.03f
*/

Here's a piece of my render() function:
for(int x = camera.vLookAtPt.x + 11; x > camera.vLookAtPt.x - 11; x--)
	{
		if(abs(x) < map->width)
		{
			for(int z = camera.vLookAtPt.z - 11; z < camera.vLookAtPt.z + 11; z++)
			{
				if(abs(z) < map->height)
				{
					d3ddev->SetTexture(0, textures[map->tiles[abs(x)][abs(z)]]);

					D3DXMatrixTranslation(&matTranslate, x * 0.8, 0.0f, z * 0.8);
					d3ddev->SetTransform(D3DTS_WORLD, &(matTranslate));
					d3ddev->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
				}
			}
		}
	}

I have a feeling it has something to do with Camera moving at such a small rate, it can become things like 0.5, but the tile drawing draws things in blocks of 0.8 (tile size, if this is abnormal tell me, I have no clue what 'standard sizes' are, and im using 64x64 png image). Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this