Page 1 of 2

Newton/Irrlicht FPS source code available

Posted: Wed May 18, 2005 4:01 am
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.

Posted: Wed May 18, 2005 10:10 pm
by dhenton9000
Code is available at this link.

Hope somebody can make it better!

Posted: Thu May 19, 2005 1:15 am
by afecelis
cool, thanks for the src! :D

Posted: Thu May 19, 2005 1:23 am
by MikeR
Looks good. :)

Posted: Thu May 19, 2005 7:27 am
by zardoz
thanks!

Posted: Fri May 20, 2005 4:45 am
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!

Posted: Fri May 20, 2005 3:20 pm
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?

Posted: Sat May 21, 2005 5:55 am
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.

Posted: Thu Jun 30, 2005 3:38 am
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

Posted: Thu Jun 30, 2005 10:19 pm
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.

Posted: Wed Jul 06, 2005 1:47 pm
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?

Posted: Wed Oct 19, 2005 5:03 pm
by Entropai
Just one question, where's the source? Link doesn't seem to work.

Posted: Wed Oct 19, 2005 9:08 pm
by dhenton9000
The new and final home for the source is http://www.s-fonline.com/webhosting/dhenton9000

Posted: Thu Oct 20, 2005 2:47 am
by kike
Please,put the binaries, i dont want install other enigine like audire...

Posted: Wed Oct 26, 2005 11:01 am
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