Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


ThePointingMan

Member Since 09 Nov 2010
Offline Last Active Today, 10:25 AM

Topics I've Started

Communication between objects and systems in Game engines.

19 May 2015 - 03:28 AM

Heya! I've been doing some work on a little engine for myself, and I've stumbled upon a little thing that I'm not entirely sure how I should approach. I'm not sure how I should handle instances where an object needs to communicate with one of the modules of the engine. A specific example of this would be for a raycast. If I have a player who needs to care about whether or not their on the ground for example, when I update the player I'm going to want them to shoot a raycast down to see if there is in fact something beneath them. This would mean that the object needs to know about the physics systems existence, a dependency that I'd rather avoid! Searching through some older topics I've seen a suggestion that the objects store a pointer to the scene, and then the scene contain things like the collision system etc, an idea that scares me for similar reasons. Am I just being too paranoid about this? Functionally it would work to have these dependencies, should their existence bother me or would anyone be able to explain to me some better designs on avoiding these kinds of dependencies?


Is hatred for unity justified?

21 March 2014 - 03:09 PM

I'm currently going to school for programming, and my 3d graphics teacher absolutely hates unity. He complains about how he can always tell when a game was made with unity because the load times will be huge for small things and he will think to himself, "That shouldn't have taken that long." Another complaint of his is that it does everything for you and thus leads to incredibly generic games. I rather like unity, as it allows me to wip up a game fairly quickly without having to worry about first making a framework, but I must admit hearing his hate for it does spark a bit of fear in me, in the long run if my productions do get bigger, despite unity's ease of use, will it harm my product in the end, or is that entirely dependent on the user? If my fundamentals of coding are strong enough does it's easy workflow still come with a price or is it just as efficient as any other engine or is my teachers hate for unity justified?


Smoothing out the ray tracing of a surface on a curve

13 October 2013 - 04:51 AM

I've been using unity for some school projects recently, and I made a  racing game fairly similar to F-zero GX. It was really unpolished though, and I've got a question about one thing that I thought really needed polish. While the hover car goes along the track, it shoots a ray directly below it and orientates itself so that the car's up is the same as the surface's normal. Gravity is always pulling in the hover cars down direction. The biggest problem I am having with doing this is that with upward curves. Lets say I was doing a loop de loop. The car would move forward by an amount, then orientate itself and move forward again. If you are going fast enough though, you end up moving so far forward that you tap the surface of the loop de loops curve with your ship, making you loose all momentum. Does anyone have any ideas as to what I could do to work around this?


Depth Transparecy issues.

18 June 2013 - 09:43 AM

I've been working on a Direct3D game run for a while now and I've come across an issue with alpha blending that I don't quite know how to solve. 

I've set my render states like this

// both sides of the triangles
    d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);    
	//Set render states
	d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);// turn off the 3D lighting
	//make it so things color can fade
	d3ddev->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
	d3ddev->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
	d3ddev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
	//-------------------------------------------------------------
    d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE);    // turn on the z-buffer
	d3ddev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

Now at first I thought everything was perfectly fine, things that where transparent in my png file would go on screen transparent, but I later found out that they will only be transparent to things they have been rendered after, so if i render a see through a space ship, and then a red cube and then an asteroid and put the red cube in front of both the space ship and the asteroid, only the space ship will be visible with a red tinge, the asteroid will be completely blocked out. Does anyone know why this is happening and how it can be solved?


Rotation in 3D

06 June 2013 - 05:42 PM

I am using direct x to try and make a free roaming camera. I am having a bit of difficulty when it comes to rotation. I have tried a few things, each having different result, none being the results that I want. This is basically how my camera system works. I plan on changing it a lot later, but i needed this to be done fast, and its mostly functional.

for(auto index = targets.begin(); index != targets.end(); index++)
		{
			auto node = static_cast<CameraNode*>(*index);
			if(node->Player != NULL)
			{
				Position = node->Position;//this is a pointer to the players position vector
			}
			if(Position != NULL)
			{
				

				static int i;
				i++;
				//Deal with the matrices
				D3DXMATRIX mTranslate;
				D3DXMATRIX mRotateX;
				D3DXMATRIX mRotatey;
				D3DXMATRIX mRotatez;
				D3DXMATRIX mScale; //MAYBEH LAAAAATA
				D3DXMATRIX mWorld;
				//Set All Matrices to a neutral state
				D3DXMatrixIdentity(& mWorld);
				D3DXMatrixIdentity(&mTranslate);
				D3DXMatrixIdentity(& mRotateX);
				D3DXMatrixIdentity(& mRotatey);
				D3DXMatrixIdentity(& mRotatez);
				D3DXMatrixIdentity(& mScale);
				//MoveEverythaaaang
				D3DXMatrixTranslation(&mTranslate,Position->Position.x,Position->Position.y,Position->Position.z);
				D3DXMatrixRotationX(&mRotateX,Position->Angle.x*(M_PI/180));
				D3DXMatrixRotationY(&mRotatey,Position->Angle.y*(M_PI/180));
				D3DXMatrixRotationZ(&mRotatez,Position->Angle.z*(M_PI/180));
				//Update the world
				mWorld = mTranslate * mRotateX * mRotatey * mRotatez;// this line maximum important

				// set the view transform
				D3DXMatrixLookAtLH(&node->Camera->mCamera,
				&D3DXVECTOR3 (0.0f, 0.0f, 600.0f),    // the camera position
				&D3DXVECTOR3 (0.0f, 0.0f, 0.0f),      // the look-at position
				&D3DXVECTOR3 (0.0f, -1.0f, 0.0f));    // the up direction
				// set the projection transform
			
				D3DXMatrixPerspectiveFovLH(&node->Camera->mLense,
										   D3DXToRadian(45),
										   (FLOAT)600 / (FLOAT)600,
										   1.0f,    // the near view-plane
										   1000000.0f);    // the far view-plane
			
				node->Camera->mCamera = node->Camera->mCamera * mWorld;
			}
		}

So basically I am multiplying the camera's matrix by a matrix that is being affected by a vector containing pitch, yaw, and whatever the name for the other axis of rotation is, and a position vector

 

Now if I multiply mtranslate by the rotation matrices, then I can turn my camera just fine, but moving forward only goes the base forward, so it I am looking left, forward is not to the left, but remains unchanged.

if i do it the other way around then when i rotate I orbit around the center point.

To counter this I when't with the one that would still move forward and backwards independent of which direction you are looking and threw this in to my player move thing.

for(auto index = targets.begin(); index != targets.end(); index++)
		{
			auto node = static_cast<MoveNode*>(*index);
			//Deal with the matrices
			D3DXMATRIX mTranslate;
			D3DXMATRIX mRotateX;
			D3DXMATRIX mRotatey;
			D3DXMATRIX mRotatez;
			D3DXMATRIX mScale; //MAYBEH LAAAAATA
			D3DXMATRIX mWorld;
			//Set All Matrices to a neutral state
			D3DXMatrixIdentity(& mWorld);
			D3DXMatrixIdentity(&mTranslate);
			D3DXMatrixIdentity(& mRotateX);
			D3DXMatrixIdentity(& mRotatey);
			D3DXMatrixIdentity(& mRotatez);
			D3DXMatrixIdentity(& mScale); 
			//MoveEverythaaaang
			D3DXMatrixTranslation(&mTranslate,node->Position->Position.x,node->Position->Position.y,node->Position->Position.z);
			D3DXMatrixRotationX(&mRotateX,node->Position->Angle.x*-(M_PI/180));
			D3DXMatrixRotationY(&mRotatey,node->Position->Angle.y*-(M_PI/180));
			D3DXMatrixRotationZ(&mRotatez,node->Position->Angle.z*-(M_PI/180));
			D3DXMATRIX mRotation = mRotateX * mRotatey * mRotatez;

			D3DXVECTOR3 Position;

			//D3DXVec3TransformCoord(&Position,&node->Velocity->VelocityPos,&mRotateX);w
			D3DXVec3TransformCoord(&Position,&node->Velocity->VelocityPos,&mRotation);
			//D3DXVec3TransformCoord(&Position,&node->Velocity->VelocityPos,&mRotatez);
			node->Position->Position += Position;// * time;
			node->Position->Position += Position;// * time;
			node->Position->Angle += node->Velocity->AngularVelocity;// * time;
		}

Now this works if I only rotate on one axis, but as soon as I start rotating on 2 things go crazy!

 

Any advise on how I should go about making this not go insane for a free roaming camera/how have you accomplished what I am trying to do in the past?


PARTNERS