Jump to content

  • Log In with Google      Sign In   
  • Create Account


betawarz

Member Since 17 Dec 2009
Offline Last Active Aug 01 2013 07:25 PM

Topics I've Started

How to compile and use FBX model files with VS2012?

31 July 2013 - 05:02 PM

Hi all,

 

I'm using D3D11 and VS2012.

 

I've read that VS2012 can automatically compile FBX files during the build phase, similar to HLSL files. I haven't been able to find any documentation on how to do this, though. What build action do I set for the FBX files?

 

Also, what function or functions should I look up on MSDN / Google that relate to loading the compiled FBX file? A tutorial or stackoverflow link, etc, will work. I just have nothing to go on at the moment, so I don't even know what to Google for. My searches haven't turned up anything.

 

Thanks


Should game objects render themselves, or should an object manager render them?

10 July 2013 - 04:15 PM

I'm learning how to program games using C++ and D3D11. I've got a basic 3D application that I re-factored from one of the simple tutorials; the one with a single spinning cube. I'm about to write a basic object manager, and pull the code for the cube out into an object class.

 

Now, I've been reading about object managers and game objects, etc. I've read two different takes on it.

 

  1. Each game object is responsible for updating and drawing itself. So each object has its own draw method that the object manager would call.
  2. Game objects only contain the information needed to draw itself; the object manager actually handles the drawing logic using that information.

I'm familiar with the first method, because it's pretty simple to wrap my head around. I've seen it used in quite a few examples and stuff. I'm trying to grok the 2nd way, though. Wouldn't the draw function of the object manager need to iterate over each object, and depending on the type do specific stuff? This would result in a pretty massive draw function with a bunch of if-else branches based on the object type. Is that good? I know it consolidates all the drawing logic into one area, so it's not spread out over many different object classes, so I could see that being a bonus.

 

Just looking for some advice on which method to go with, I guess. Thanks!


Official site for DXUT?

24 December 2009 - 03:51 PM

Is there an official site for information regarding DXUT? Perhaps news on the most current version, or full blown docs? I found DXUT by browsing the DirectX samples, inside of a sample that I randomly picked. I'm going to persue using DXUT because it seems like it's going to make things simpler. I've found the MSDN documentation on it, but it seems pretty lacking. It just goes through a simple generic description of setting up DXUT. I recently purchased Game Coding Complete, by Mike McShaffry, and he uses DXUT in the book. He doesn't even explain what DXUT is, really, or how to find it. All of his examples seem to use it, though. So, is the only way to locate DXUT through the sample browser? Is there a site that allows me to keep current with the framework? It just feels so disconnected and hidden for something so helpful. Thanks

Looking for some general advice

23 December 2009 - 05:42 AM

Hello, I've got a pretty decent game programming foundation to work with, I think. I've written several 3D games using XNA - all we're tower defense style games. I have also taken a course in school about game programming using C++ and DirectX - we focused on 2D games, will be 3D next semester. I was wanting to kind of get a jump start on the 3D programming. I wanted to make a simple first person shooter. I figured my first goal would be to create a Camera class, and perhaps a world coordinate (0, 0, 0) arrow thing so that I have something to look at with my Camera. I have been looking over the DirectX samples that come with the SDK and there seems to be a wealth of good information there. But all the different examples kind of lead me to some questions. What is DXUT? It looks like a framework to speed up game dev, almost a little like XNA is. Is DXUT something I should look into using? Does anyone know of any existing tutorials that are both recent and about writing a simple first person shooter? Thanks in advance.

Why aren't my textures drawing with transparency?

17 December 2009 - 04:09 AM

Hi all, I'm just writing a simple game to kind of mess around. I'm drawing floor and background textures, some doodad textures and then my player texture. My doodads are drawing with transparency to the background textures - I can see the background and floor behind the doodad's edges, but I can't see my player when I walk behind the doodads. Any idea what might be causing this or how I can fix it? I can see the doodads just fine behind my player object but I can't figure out what I did differently I'm not using D3DXSPRITE. Here's my load and draw methods for my Doodad objects.
void CDoodad::LoadTexture(LPDIRECT3DTEXTURE9& p_Texture, LPSTR p_Filename)
{
	// Image information structure.
	D3DXIMAGE_INFO structImageInfo;
	D3DCOLOR colorKey = 0xFFFFFFFF;
	HRESULT hres = D3DXCreateTextureFromFileEx(GraphicsDevice, p_Filename, this->Dimensions.height, this->Dimensions.width, 1, 0,
											   D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE,
											   D3DX_DEFAULT, colorKey, &structImageInfo, NULL, &p_Texture);

	// Could not load the texture.
	if (FAILED(hres))
		ABORT("Texture file %s not found", p_Filename);

	// Create vertex buffer
	if (VertexBuffer == NULL)
	{
		hres = GraphicsDevice->CreateVertexBuffer((4 * sizeof(BILLBOARDVERTEX)),  D3DUSAGE_WRITEONLY, BILLBOARDVERTEX::FVF,
												D3DPOOL_MANAGED, &VertexBuffer, NULL);

		if (FAILED(hres))
			ABORT("Failed to create vertex buffer");

		// Load vertex buffer
		BILLBOARDVERTEX* v;
		float w = (float)structImageInfo.Width / 2.0f;
		float h = (float)structImageInfo.Height / 2.0f;

		// Lock buffer
		if (SUCCEEDED(VertexBuffer->Lock(0, 0, (void**)&v, 0)))
		{ 
			// Vertex information, first triangle in clockwise order
			v[0].p = D3DXVECTOR3(w, h, 0.0f);
			v[0].tu = 1.0f; v[0].tv = 0.0f;
			v[1].p = D3DXVECTOR3(w, -h, 0.0f);
			v[1].tu = 1.0f; v[1].tv = 1.0f;
			v[2].p = D3DXVECTOR3(-w, h, 0.0f);
			v[2].tu = 0.0f; v[2].tv = 0.0f;
			v[3].p = D3DXVECTOR3(-w, -h, 0.0f);
			v[3].tu = 0.0f; v[3].tv = 1.0f;
			VertexBuffer->Unlock();
		}
		else
			ABORT("Could not lock vertex buffer");
	}
}

void CDoodad::Draw()
{
	// Set render states for graphics device
	GraphicsDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	GraphicsDevice->SetRenderState(D3DRS_ALPHAREF, 0x08); 
	GraphicsDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL); 
	GraphicsDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	GraphicsDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	GraphicsDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	GraphicsDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE );

	// Define the scale of the image doodad
	D3DXVECTOR3 Scale = D3DXVECTOR3(1.0f, 1.0f, 1.0f);

	// Create transformation matrix
	D3DXMatrixTransformation(&Translation, NULL, NULL, &Scale, NULL, NULL, &Location);

	// Apply horizontal translation
	GraphicsDevice->SetTransform(D3DTS_WORLD, &Translation);

	// Set vertex buffer and texture
	GraphicsDevice->SetStreamSource(0, VertexBuffer, 0, sizeof(BILLBOARDVERTEX));
	GraphicsDevice->SetFVF(BILLBOARDVERTEX::FVF);
	GraphicsDevice->SetTexture(0, m_Texture);

	// Draw sprite
	GraphicsDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

	// Restore alpha blend state and zbuf
	GraphicsDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
	GraphicsDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
}
Thanks in advance

PARTNERS