Jump to content

  • Log In with Google      Sign In   
  • Create Account

littletray26

Member Since 28 May 2012
Offline Last Active Oct 14 2013 06:38 PM

Topics I've Started

Locking a D3DXMesh's vertex buffer

27 July 2013 - 06:43 PM

Hey GameDev

 

I'm trying to lock an LPD3DXMESH's vertex buffer so as I can fiddle with the vertices.

My problem is that as follows:

 

When you manually create a mesh in code, you have your own CUSTOMVERTEX kind of struct, and then when you lock the vertex buffer, you can hand it a void pointer to your CUSTOMVERTEX type. EG

	CUSTOMVERTEX* vert;
	vb->Lock(0, 0, (void**)&vert, NULL);

But when I need to lock the meshs vertex buffer, I don't have a vertex class to lock it with.

 

So my question is, how do I lock the mesh vertex buffer when I don't have a vertex struct? Is there a kind of default vertex stuct I can use?


Terrain Collision and Bounding spheres?u

25 July 2013 - 02:30 AM

Hey Gamedev 

 

I will shortly be making up some terrain for my game. How I do this, I'm yet to decide between a static mesh, or a heightmap.

 

I have 2 questions;

 

First of all, what is the best/the simplest/easiest/whatever gets the job done/ way to detect collision between the character, and the terrain. I don't want the player "snapped" onto the terrain, so I don't want him to glide up massive slopes. How would I go about doing this? Detecting the collision and offsetting the characters y position accordingly?

 

My second question is, I constantly hear people using bounding spheres for player collision. Why is this? It seems to me that a bounding box or cylinder would be more accurate (unless the player was a fatty) why use a sphere?


First Person Rolling problem

24 July 2013 - 06:57 AM

Hey GameDev :)

 

My first person camera is rolling when I move the mouse in circles. I don't know what's wrong with it, please help me.

	void Pitch(float angle)
	{
		D3DXMATRIX T;
		D3DXMatrixRotationAxis(&T, &right, angle);

		D3DXVec3TransformCoord(&up, &up, &T);
		D3DXVec3TransformCoord(&lookDirection, &lookDirection, &T);
	}
	
	void Yaw(float angle)
	{
		D3DXMATRIX T;
		D3DXMatrixRotationAxis(&T, &up, angle);

		D3DXVec3TransformCoord(&lookDirection, &lookDirection, &T);
		D3DXVec3TransformCoord(&right, &right, &T);
	}

Help rotating a sprite D3D9

29 March 2013 - 07:16 AM

Hey GameDev

 

I've 2 sprites, an enemy and a guy, and I'm trying to rotate guy, but not enemy:

 

void Draw(LPD3DXSPRITE sprite, LPDIRECT3DDEVICE9 d3dDevice)
{
	sprite->Draw(texture, &enemy, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(400, 400, 0),                D3DCOLOR_ARGB(255,255,255,255));
	sprite->SetTransform(&matrix);
	sprite->Draw(texture, &guy, &D3DXVECTOR3(0, 0, 0), &guyPosition, D3DCOLOR_ARGB(255,255,255,255));
}

 

 

Problem is it rotates both of them, and I don't know why. Help?


How does tan work exactly?

27 March 2013 - 11:51 PM

So I've been looking for a way to get a sprite to rotate and face my cursor, and I came across this:

 

You wan't a sprite to point towards the mouse pointer?

If that is the case you would probably need a algorithm to calculate it. It would depend on the location of the sprite as much as of the mouse pointer.

Let´s say the rotation 0 is straight up then that should be the case when it has the same X as mouse and Y is bigger.

The math here would be, assuming:

pos is position of sprite
mouse is position of mouse

DeltaY = mouse.Y - pos.Y
DeltaX = mouse.X - pos.X

rotation = tan^-1(DeltaY / DeltaX)

 

Now I understand that it works, but I'm wondering if one of you fine people can help me understand why it works. I'm not that great at  math, but I take every chance I can to improve. I need to understand the concept behind tan, and inverse tan, so I can apply it to any other problems I might face that would require it.

 

Thanks smile.png

 

Just to clarify, I know what tan is. Tan = opposite / adjacent. I know you feed tan the angle, and it returns o/a but why is o/a needed? What is it used for? and I don't know what inverse tan is at all.


PARTNERS