Newton/Irrlicht FPS source code available

A forum to store posts deemed exceptionally wise and useful
Guest

Newton/Irrlicht FPS source code available

Post by Guest »

I've been working on a FPS character controller using Newton and Irrilicht with the following features

first person view camera
head tilt
following camera
jump
crouch
stairs
newton based movement, newton used for collision detection and navigation.

Anyone interested in source code can contact me at dhenton[at]users[dot]sourceforge.net

If there is enough interest I will see about packaging this as a tutorial.
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

Code is available at this link.

Hope somebody can make it better!
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

cool, thanks for the src! :D
MikeR
Posts: 767
Joined: Sun Dec 26, 2004 4:03 pm
Location: Northern California USA
Contact:

Post by MikeR »

Looks good. :)
If it exists in the real world, it can be created in 3d

Sys specs:
AMD 3700+ 64 processor
1.0 gb ram
e-Geforce 6600 graphics 256 mb onboard ram
zardoz
Posts: 11
Joined: Sat Dec 18, 2004 5:18 pm

Post by zardoz »

thanks!
Nick_Japan
Posts: 98
Joined: Mon Dec 13, 2004 11:47 am
Location: Japan

Post by Nick_Japan »

Very impressive stuff! Player movement was the bit that looked the trickiest to me. Looks like we're really close to sorting out Irrlicht and Newton now. I've made some headway with vehicles - as soon as I get my laptop back from being repaired (grrr) I'll post that too. Yes a tutorial explaining how you went about it would be very interesting; your code looks very clear and readable but it's always nice to have these things described in plain english. It seems that Newton is the physics engine many people are trying to use with Irrlicht and so having proven implementations of the two working together would be a great asset. Many thanks and much respect for sharing your work - keep it up!
RLG unlogged

Post by RLG unlogged »

hey i was playin with ur source and tried using the .bsp map that comes with irrlicht, and my character just falls thru everytime, any help guys?
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

RLG unlogged wrote:hey i was playin with ur source and tried using the .bsp map that comes with irrlicht, and my character just falls thru everytime, any help guys?
This is guest (now properly logged in)

When this happened to me, It was because the newton box was not "above" anything. I have to position it by hand over an area that I know will catch it (done by trial and error).

That would be my guess.
Nick_Japan
Posts: 98
Joined: Mon Dec 13, 2004 11:47 am
Location: Japan

Post by Nick_Japan »

Heya,

I'm working with your source now - can I be really cheeky and ask you which bit implements moving the player over low obstacles or up stairs? Just pointing me to which function does this would be great!

Cheers
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

The 2 functions to look at are in the CNewtonPlayerController class

They are ApplyPlayerForceEventHandler and SetPlayerMeshTransformEventHandler


In the ApplyPlayerForceEventHandler is the following code

Code: Select all



	if (direction != 0.0f)
	{

		double dx = sin(m_Theta*3.14159/180);
		double dz = cos(m_Theta*3.14159/180);
		vector3df movevelocity((float) dx, 0.0f, (float) dz);
		movevelocity.normalize();
		movevelocity *= direction;
		NewtonBodyGetVelocity(body,&velocity.X);
		goalvelocity = movevelocity * PLAYER_SPEED;
		acceleration.X = mass*((goalvelocity.X - velocity.X) / timestep);
		acceleration.Z = mass*((goalvelocity.Z - velocity.Z) / timestep);
	}
The acceleration vector is what gets this object moving. As to why it skips over small objects and stairs, I haven't a clue. The developers of Newton have a Newton forum post somewhere mentioning that the solver/integrator used can't resolve certain kinds of differences. (Maybe I just dreamt that.)

I think the reason it works is that the stair step is seen as a ramp if the rise and run are small enough. So there is a depencency on the ratio of the player ellipsoid size and the stair tread. I'm pretty sure its just a fluke that it works, but I can't think of any other way to get it to work. Your post on character control on the Newton forum includes that response from others who tried it: there might be a better way, but not an easier one.

So really there isn't any place in the code, other than the absolute sizing of the player object, and then the requirement that the environment have a certain size. I'm planning to size all my future mesh work according to the demo.
the user
Posts: 6
Joined: Sun Mar 20, 2005 7:47 pm

Post by the user »

Have anybody a fix for the camera?
Whensoever I came on the end of the screen the camera stop.
What can i do?
Entropai

Post by Entropai »

Just one question, where's the source? Link doesn't seem to work.
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

The new and final home for the source is http://www.s-fonline.com/webhosting/dhenton9000
kike

Post by kike »

Please,put the binaries, i dont want install other enigine like audire...
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

I've uploaded an update which includes the following features

Image


Ammo Counter

Use of Irrlicht Animators for timing events (weapon fires 50 times then "cools down" for 2 seconds)

Attached weapon to FPS camera

Newton spheres as bullets--collision is reported via the Newton material callback system.


Love to have someone check it out. The bullets don't do much , but you can see them if you hit the "I" key.


Also included a binary :wink:


Files at
http://www.s-fonline.com/webhosting/dhenton9000
Post Reply