Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


gbMike

Member Since 06 Mar 2012
Offline Last Active Jan 08 2014 06:36 PM

Topics I've Started

Physics at extreme speeds

19 April 2013 - 02:24 AM

Appologies, but my question is a bit general. I'm working on a completely over the top racing game, involving extremely high speeds, between 200mph - 1500mph and above. ( it is heavily inspired by the F-zero series, as well as the anime movie Redline ) Since we are really pushing this as far over the top as we can take it, I would like to pull in some real world physics where possible. For example, after a certain speed, air friction alone becomes enough to ignite an object. What type of physics based considerations would you recoment taking into account? I'm not looking for specific formulas or anything, just any thoughts that might be relavent, or worth considering. Thanks!


Similar experience vs Published title

13 April 2013 - 03:15 AM

I'm at a bit of a crossroads for deciding which direction to take with my programming. Specifically, what do you feel is more important for better preparing to entering the industry, a published title (aka a self-published indie game) or experience in a similar industry?

 

As a self-taught programmer, I feel I could learn a great deal interfacing with other developers in even a non game related, production environment, but I'm concerned that the general skill sets that I possess and want to improve, will not cross over between jobs ( 3d math, in engine scripting and UI, and other similar. This is just based on what I have seen. If this is inaccurate, I would love to know. ) Likewise, a complete, published game speaks to my credibility, but might not provide the best avenue for improving my own skills, since I would not be working with anyone more experienced than myself.

 

Just a quick sidenote about my experience thus far, to give a little better idea of where I stand: I started teaching myself around 4 years ago. I've completed several small flash games, but never published, or sold one. I've worked on a variety of projects in C++, and several other scripting languages, but again, no published or marketed final projects. I consider my coding ability to be solid, and I can typically pass any programming test I'm given. (at least, so far)

 

Thoughts? Which would you think is a more useful direction to go?


Code Sample Review Request

09 October 2012 - 04:29 PM

I'm putting together a job application for a generalist programmer position, and I'm in the process of selecting a code sample for my review, and I would very much like to hear any feedback before sending it off. Too simple, could be written better... ect. Whatever comes to mind if you were handed it as a potential applicant.

As always, thanks for the help.



[source lang="cpp"]/* Core game class. Manages the elements, start and end of a game. Instantiated by main.cpp*/#include "Game.h"Game::Game(){ // Set default values gameInProgress = false; navigating = false; selectedNode = NULL; player = NULL; lastCoreTransform = NULL;}Game::~Game(){ if( gameInProgress ) endGame(); delete lastCoreTransform;}// Starts a new game, if one is not already runningvoid Game::startGame( int levelID ){ // Break if a game is already in progress if( gameInProgress ) return; gameInProgress = true; player = new Player(); // Create default cameras cameras.push_back( new Camera() ); //player camera cameras.push_back( new Camera() ); //fixed cam // Set camera offset, and set it to follow the player's ship currentCamera = cameras[0]; currentCamera->translate( 0, -30, -100.0f ); currentCamera->rotate ( 0.0f, 0.0f, 0.0f ); currentCamera->camTarget = player; // Offset the static camera cameras[1]->translate( 0, 0, -100.0f ); setCamera(0); // Generate the level, based on the passed in ID GameLevelData::createLevel( levelID );}// Ends the curent game, and deletes all non texture assetsvoid Game::endGame(){ gameInProgress = false; if( player != NULL ) delete player; player = NULL; // Delete all Nodes, Actors and Cameras while( Node::getNodes().size() > 0 ) delete (*Node::getNodes().begin()); while( Actor::getActors().size() > 0 ) delete (*Actor::getActors().begin()); for( int i = cameras.size()-1; i >= 0; i-- ) delete cameras[i];}// Function to be run, each time the frame updatesvoid Game::update( int timePassed ){ handleInput(); // Process user input updateActors( timePassed ); // Update all actors, AI, and physics updateCamera( timePassed ); // Update the current camera drawScene(); // Draw scene data drawHud(); // Draw 2d HUD elements}// Function to generate the view matrixvoid Game::updateCamera(){ // If a game is not running, or a camera is not set, view matrix is just an identity matrix if( !gameInProgress || currentCamera == NULL ) { iGLEngine->viewMatrix->setMatrix( mat4(1.0f) ); } else if( currentCamera->camTarget == NULL ) { // Camera has no target, so retun just the cameras transform matrix iGLEngine->viewMatrix->setMatrix( *currentCamera->getTransform()->getMatrix() ); } else { // We have a camera target. Interpolate the last camera position, a set percentage, towards // the transform of the camera target. lastCoreTransform->interpolate(currentCamera->camTarget->getCoreTransform(), 0.5f, //Rot multiplier 0.25f ); //Pos Multiplier // Apply the camera's offset, to the interpolated transformation, and set it as the current view Matrix iGLEngine->viewMatrix->setMatrix( (*currentCamera->getTransform()->getMatrix()) * glm::inverse( *lastCoreTransform->getMatrix() ) ); }}// Handles user input at the game levelvoid Game::handleInput(){ // Get a pointer to the current input state via a static accessor InputState *inputState = InputState::getInputState(); // Toggle between the two cameras with the number keys if( inputState->keyDown( SDL_SCANCODE_1 ) ) setCamera( 0 ); if( inputState->keyDown( SDL_SCANCODE_2 ) ) setCamera( 1 );}// Updates all actors, processes AI (if any), and physicsvoid Game::updateActors( int timePassed ){ for ( list<Actor *>::iterator it = Actor::getActors().begin(); it != Actor::getActors().end(); it++ ) { (*it)->update( timePassed ); }}// Draws the scene elementsvoid Game::drawScene(){ for ( list<Node *>::iterator it = Node::getNodes().begin(); it != Node::getNodes().end(); it++ ) { Mesh *mesh = static_cast<Mesh *>(*it); if( mesh && mesh->getParent() == NULL ) { mesh->drawMesh(); } }}// Recursive function, to delete a node, and all it's children.void Game::deleteNode( Node *node ){ list<Node *> children = node->getChildren(); for ( list<Node *>::iterator it = children.begin(); it != children.end(); it++ ) { deleteNode( (*it) ); } delete node;}// Sets the current cameravoid Game::setCamera( int index ){ // Verify that the passed in index is within boundaries index = ( index < 0 ) ? 0 : index; index = ( index > (int)cameras.size() ) ? (int)cameras.size() -1 : index; currentCamera = cameras[index]; // If the camera has a target, make sure to set the data for the 'lastCoreTransform' if( currentCamera->camTarget != NULL ) { // Create the lastCoreTransform if it does not already exist if( lastCoreTransform == NULL ) lastCoreTransform = new Transform(); lastCoreTransform->setMatrix( *currentCamera->camTarget->getCoreTransform()->getMatrix() ); }}[/source]

Quaternion Interpolation - Camera 'Popping" during interpolation

21 September 2012 - 03:07 PM

I'm having some difficulty replicating a bit of code, after switching from Euler, to Quaternions. The rotation value (a vec3) in my transform class, has each value (x, y, z) constrained between -180 and 180. So, if I was to rotate an object with 0 degrees rotation, 190 degrees, the new rotation would be -170.

My camera's transform needs to be rubber banded to the player. Heres how it was setup with Euler angles (This was called each frame):

   vec3 posDif = coreTransform->getTranslation() - lastCoreTransform->getTranslation();
   vec3 rotDif = coreTransform->getRotation() - lastCoreTransform->getRotation();
  
   //Adjust values
   if( rotDif.x > 180.0f )
	rotDif.x -= 360;
   if( rotDif.y > 180.0f )
	rotDif.y -= 360;
   if( rotDif.z > 180.0f )
	rotDif.z -= 360;
   if( rotDif.x < -180.0f )
	rotDif.x += 360;
   if( rotDif.y < -180.0f )
	rotDif.y += 360;
   if( rotDif.z < -180.0f )
	rotDif.z += 360;
  
   //reduce the position and rotation by a %
   posDif *= 0.25f;
   rotDif *= 0.5f;
   vec3 newRot = -(lastCoreTransform->getRotation() + rotDif);
   vec3 newPos = lastCoreTransform->getTranslation() + posDif;

Here, it is pretty easy to constrain the rotation difference. That way if last rotation was 170, and new rotation is -170, the difference will be the correct 20, rather than -340. So my question is, how do I replicate this with Quaternions? Here is the current interpolation code:

//Interpolate between this transform, and the passed in 'target'
Transform* Transform::interpolate( Transform *target, float rotMultiplier, float posMultiplier )
{
quat thisQuat = cdata->quaternion;
quat targetQuat = target->getQuat();
quat newRotQuat = glm::mix( thisQuat, targetQuat, rotMultiplier );

//check for infinities in return values
if ( newRotQuat.w <= FLT_MAX && newRotQuat.w >= -FLT_MAX)
{
  //Number is real, within boudaries.
}
else
{
		//then our quat has returned overflow numbers, either to large or too small
  // -1.#IND or  1.#IND
  newRotQuat = target->getQuat();
	}  

vec3 newRot = glm::eulerAngles( newRotQuat );

vec3 newPos = cdata->translation + ( (target->getTranslation() - cdata->translation ) * posMultiplier );

//create the new Transform, and pass in values
Transform *nTrans = new Transform();
//nTrans->setMatrix( newPos, newRot, vec3(1.0f, 1.0f, 1.0f) );
nTrans->setMatrix( vec3(0.0f,0.0f,0.0f), newRot, vec3(1.0f, 1.0f, 1.0f) );
return nTrans;
}

It causes the camera to start spinning wildly after a certain rotation is reached. How can I properly constrain the value like I used to, while the code for quaternion interpolation is handled through GLM? (glm::mix)


EDIT:
Alternatively, if anyone has a suggestion, for another way to add easing animation to the camera, I'd be interested in trying it.

How to smooth animation with matrixes

23 August 2012 - 09:34 PM

I'm attempting to add a slight smoothing to the 'camera' in my 3d engine. It locks onto the player, and follows the model, exactly. However, I would like it to, instead animate slightly, as the camera catches up to the player, just so it doesn't look so stiff. Here was my semi successful fix:

[source lang="cpp"] mat4 targetMatrix = glm::inverse( currentCamera->camTarget->getCoreTransform().getMatrix() ); //camera matrix is the camera's offset targetMatrix = currentCamera->camMatrix * targetMatrix; //get the difference between the new target matrix, and the current view matrix mat4 difMatrix = targetMatrix - viewMatrix; //only move a percentage of the total distance. //this will automatically ease out the movement difMatrix /= 4; viewMatrix += difMatrix; iGLEngine->viewMatrix->setMatrix( viewMatrix );[/source]

The problem is, when the object rotates very quickly the scene starts to warp and stretch. The amount of stretching is directly connected to the rotation speed. Anyone know why? Or, even better, another way to animate a transition from one matrix (the current view matrix) to another (the target view matrix) ?

PARTNERS