Videos from physics springs system

This is a discussion on Videos from physics springs system within the Game Programming forums, part of the General Programming Boards category; EDIT: The model in the movies/pictures is actually a minigun made by sentral on these boards (he's making models for ...

  1. #1

    Join Date
    May 2005
    Posts
    1,041

    Videos from physics springs system

    EDIT:
    The model in the movies/pictures is actually a minigun made by sentral on these boards (he's making models for the game). The lines coming down is where the thrusters make contact with the ground.
    People have had problems with the movies ( had to download fraps just to watch the .avi files), and I've also noticed that downloading from this host was running a tab bit slow (perhaps I should post on rapidshare?)

    I'm in the process of taking some screenshots and perhaps trying to find a better way to record video.


    8 screenshots


    Each of these files is about 20MB, so unless you have broadband don't bother (these are less than 30 seconds apiece, on lowest quality and only 25 fps).


    Here's some footage I recorded using fraps, it just shows the latest thing I've implemented in my physics: a set of thrusters that stabalize a hovertank (for the computer game I'm currently working on).


    ramp

    bounce
    Last edited by BobMcGee123; 03-25-2006 at 01:56 PM.
    I'm not immature, I'm refined in the opposite direction.

  2. #2

    Join Date
    May 2005
    Posts
    1,041
    Here is the prototype code that I wrote...it's very messy, it's just to test the concepts. When I implement a final version I will measure the distances with dotproducts instead of square roots, and I will collect leafs for doing collision detection only once and reuse that data (because otherwise each call to test for collision detection has to re-find which leafs it passes through).

    Code:
    void	Hovertank::ApplyThrust()
    {
    	Matrix4x4	trans,rot;
    	trans.SetTranslation(&CurrentState.mPosition);
    
    	Vector3	*euler_orientation = &CurrentState.mEuler_Orientation;
    //	Vector3	deg_orientation(	RAD2DEG(euler_orientation->x), RAD2DEG(euler_orientation->y), RAD2DEG(euler_orientation->z) );
    
    	rot.InitFromRadians(euler_orientation->x,euler_orientation->y,euler_orientation->z);
    	
    	Matrix4x4	temp_mat = trans * rot;
    
    	Thruster	temp_thrusters[NUM_THRUSTERS];
    	
    	float	rest_height = mRadius + 1.0f;
    	
    	for(int i = 0; i < NUM_THRUSTERS; i++)
    	{
    		temp_thrusters[i].Position		=	temp_mat * mThrusters[i].Position;
    		temp_thrusters[i].Orientation	=	CurrentState.mMat_Orientation * mThrusters[i].Orientation;
    		
    		Vector3	end = temp_thrusters[i].Position	+	(temp_thrusters[i].Orientation * 10000.0f);		
    		
    		Vector3	start = temp_thrusters[i].Position;
    		
    		gpGLRenderer->AddDebugLineToRenderer(start.x,start.y,start.z,end.x,end.y,end.z,1,0,0,2.0f);
    		gpGLRenderer->AddDebugSphereToRenderer(start.x,start.y,start.z,0,0,0,1,1,1,2.0f);
    
    		end = temp_thrusters[i].Position + (temp_thrusters[i].Orientation	*	rest_height);
    		
    		HitInfo	CGTrace = TraceSphereToBSPFaces(gpBSP,temp_thrusters[i].Position,end,5.0f,gpPhysicsManager->physics_epsilon);
    
    		//spring force = k * x
    		//k is some constant
    		//x is the amount of compression
    
    		if(CGTrace.Time	<	1.0f)
    		{
    			float	dist_to_point			=		(CGTrace.HitPoint - temp_thrusters[i].Position).GetLength();	//dist from collision point to cg
    			float	compression				=		fabs(rest_height - dist_to_point);
    			
    			float	force_magnitude(0);
    
    			if(dist_to_point <= rest_height)
    				force_magnitude			=		(mMass * gpPhysicsManager->mGravAccel) * compression;
    			else
    			{
    				force_magnitude			=	   (mMass * gpPhysicsManager->mGravAccel) / compression;
    			}
    
    			Vector3	force_vector			=		temp_thrusters[i].Orientation	*	force_magnitude * -1.0f;
    			
    			// dampen the velocity 
    			Vector3	local_contact		  = temp_thrusters[i].Position	-	CurrentState.mPosition;
    			Vector3	angular_part		  = CrossProduct(&CurrentState.mAngularVelocity,&local_contact);
    			float	velocity_magnitude	  = DotProduct(&temp_thrusters[i].Orientation,&CurrentState.mLinearVelocity) + 
    			DotProduct(&temp_thrusters[i].Orientation,&angular_part); 
    
    			Vector3	dampen_velocity_force = temp_thrusters[i].Orientation * 100.0f * velocity_magnitude * -1.0f;
    			force_vector += dampen_velocity_force;
    
    #if	0
    			// dampen the acceleration
    			Vector3	angular_accel = CrossProduct(&(mJInverseGlobal * mMoments),&local_contact);
    			
    			float	acceleration_magnitude = DotProduct(&temp_thrusters[i].Orientation,&(mForces * mMassInv)) + 
    				DotProduct(&temp_thrusters[i].Orientation,&angular_accel);
    
    			Vector3	dampen_acceleration_force = temp_thrusters[i].Orientation * acceleration_magnitude * -5.0f;
    
    			force_vector += dampen_acceleration_force;
    #endif
    			
    		//	DebugPrintFloat("force_applied",force_magnitude,gpTextManager);
    			
    			AddForce(force_vector,local_contact);
    			gpGLRenderer->AddDebugSphereToRenderer(CGTrace.HitPoint.x,CGTrace.HitPoint.y,CGTrace.HitPoint.z,0,0,0,1,1,1,5.0f);
    		}
    		else
    		{
    		//	gpTextManager->PushLineOfText("No force applied",-1024,1,1,0);
    		}
    	}
    }
    I'm not immature, I'm refined in the opposite direction.

  3. #3
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Spiffy! in the ramp video, would the tank eventually stop rolling (err...hover rolling?)?

    Also, what's with the top line of debug text? lol. Good to know somebody else uses those debugging techniques ;-)

  4. #4
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    The video doesn't work for me (in linux or windows) How bout some screenies?

  5. #5
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Note: I had to go get fraps to play the videos. I'll let Bob post screenshots.

  6. #6

    Join Date
    May 2005
    Posts
    1,041
    >>Spiffy! in the ramp video, would the tank eventually stop rolling (err...hover rolling?)?

    Well, it's on a cushion of air, thus no friction...I'd have to simulate induced drag friction (real hoveranks have a 'skirt' underneath). Otherwise, there would have to be an instruction in the hovertank AI that says 'bring to stop'

    >>Also, what's with the top line of debug text? lol. Good to know somebody else uses those debugging techniques ;-)

    hahahahahahahaha, holy crap, that's been there for like three months, I swear I completely was unaware that that was still there...i suck


    >>The video doesn't work for me (in linux or windows) How bout some screenies?

    Weird, yeah I'll do that for you


    >>Note: I had to go get fraps to play the videos. I'll let Bob post screenshots.

    That isn't right, I'm going to try to re-record it or something...it just didn't work when you tried playing the video normally? Or did it tell you (somehow) that you needed to get fraps? Strange, I'm not happy about that.
    I'm not immature, I'm refined in the opposite direction.

  7. #7
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Without fraps, media player and quicktime were complaining about missing codecs. I thought downloading fraps would surely solve that problem, and it did.
    real hoveranks have a 'skirt' underneath
    real hovertanks? Did I miss a jump in warfare technology somewhere?

  8. #8

    Join Date
    May 2005
    Posts
    1,041
    I guess I meant Hovercraft not Hovertanks The US Marine Corps has a Hovercraft delivery vehicle which is powered by old huey helicopter motors. The author of "Physics for Game Developers" David Bourg worked for a company called Textron engineering, working on developing these types of vehicles.

    Chapter 9 of that book is all about Hovercraft (but otherwise I don't really like it).
    I'm not immature, I'm refined in the opposite direction.

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Agreed Physics for Game Developers is far too sparse. I'm looking at getting another book on physics in games.

  10. #10
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >That isn't right, I'm going to try to re-record it or something..

    Windows Media player just failed with an obscure message about a "ClassFactory" not working.

    Xine gave an error message saying that the video was recorded with Fraps 3, and it only supported 1 and 2.

  11. #11

    Join Date
    May 2005
    Posts
    1,041
    >>Agreed Physics for Game Developers is far too sparse. I'm looking at getting another book on physics in games.

    I highly suggest "Game Physics" by David Eberly



    >>Xine gave an error message saying that the video was recorded with Fraps 3, and it only supported 1 and 2.

    Weird...*sigh*

    Do you know of any software that does the same thing as fraps?

    Also, to anybody that downloaded the movies, was it downloading at a slow rate? Did you try the movies bubba?


    Ultimately I think I just need to start releasing playable demos
    I'm not immature, I'm refined in the opposite direction.

  12. #12
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I think I've thrown some of his books out there before, but anything by Eric Lengyel is worth a look. He's very heavy with math and proofs.

  13. #13

    Join Date
    May 2005
    Posts
    1,041
    I second that.
    I'm not immature, I'm refined in the opposite direction.

  14. #14
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Just checked my Amazon account and it seems I tried to buy Eric Lengyel's 3D math book. I sent an email about it to them because I've never gotten it. I do remember something about an out of stock email so that might be the issue but I don't remember. I did order the Game Physics book so I'm looking forward to getting it.

    -------------------------------------------------------------
    EDIT: OMG I found the book....on top of my monitor. Geez. Now I gotta email Amazon saying I was a tard and if it was any closer to me, it woulda smacked me in the face. ROFLMAO.

    DOH!!!

    --------------------------------------------------------------
    My library continues to grow....

    I'm running out of advanced books to get. I don't need anymore primers on DirectX, vectors, matrices, etc. Now I need some really meaty books that dive head first into the mess we call game progrmaming.

    EDIT: I also d/l Milkshape 3D and I must say I like it. It's far simpler than Blender and it's very easy to create models. Me thinks I'll be buying it soon.

    And so with all these books, all these posts, and all this code.......how come we don't take the plunge and just apply at a game studio for a job? Intimidating isn't it.
    Last edited by VirtualAce; 03-26-2006 at 01:07 AM.

  15. #15
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >And so with all these books, all these posts, and all this code.......how come we don't take >the plunge and just apply at a game studio for a job? Intimidating isn't it.

    Because game programming is a nice hobby.. and once something becomes your profession, its not a fun hobby anymore. Think about working on games all day 5 days a week (yeah, sounds kinda nice), but when you get home, the last thing you're going to want to do is work on your personal game project. Its the same reason I decided not to persue music as a profession.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Operating System
    By Houssen in forum C Programming
    Replies: 18
    Last Post: 04-22-2008, 12:51 PM
  2. File System Implementation
    By dodgeviper in forum C Programming
    Replies: 9
    Last Post: 11-16-2007, 12:04 PM
  3. Using system icons
    By @nthony in forum Windows Programming
    Replies: 1
    Last Post: 01-13-2007, 06:56 PM
  4. Linux database system needed
    By BobS0327 in forum Tech Board
    Replies: 7
    Last Post: 06-11-2006, 03:56 PM
  5. BIOS system and memory allocation problem
    By beely in forum Tech Board
    Replies: 9
    Last Post: 11-25-2003, 06:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21