IrrNewt irrlicht\newton framework >> SVN access

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
matgaw
Posts: 45
Joined: Sat Oct 06, 2007 11:33 am

Post by matgaw »

I don't see any significant Newton performance change since using the 1.5 code.

How can you tell your physics is only 4 fps? How many of you have this problem? Could you paste some code to test? Does this issue show all the time or only in some cases?

For everybody having the compilation problem: don't forget to set the proper directories for your Newton and Irrlicht SDKs.
FriendlyWarlord
Posts: 58
Joined: Thu Apr 06, 2006 11:54 pm

Post by FriendlyWarlord »

matgaw wrote:I don't see any significant Newton performance change since using the 1.5 code.

How can you tell your physics is only 4 fps? How many of you have this problem? Could you paste some code to test? Does this issue show all the time or only in some cases?
Before I switched to your 1.5 code, I couldn't even compile or run the IrrNewt demos (probably because I had no clue what I was doing)! The physics was running slowly and jerkily for me because the demo (demo.cpp that comes with IrrNewt) used IWorld->update() instead of IWorld->update(timestep)... a bug perhaps, but that's ok for me, because I never have to use IWorld->update() without the timestep parameter. So, if there's a problem with the 1.5 IrrNewt, I can't really help because I never got the 1.4.2 version working =/
=D
matgaw
Posts: 45
Joined: Sat Oct 06, 2007 11:33 am

Post by matgaw »

I use world->update() with no timestep and I don't have problems. What operating system and compiler are you using? Maybe problem lies there...
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

wow, thanks a lot...
Well, when I tried running the demo (demo.cpp), the fire particles and the character animation and the camera would move smoothly at at least 60 FPS, but the cubes I throw moved only a few times a second. I fixed this by using world->update(timestep) instead of just world->update(). I also made sure it called world->update(timestep) only 1/timestep times a second.
could you maybe post some example code, I'm not really sure how to implement a timer in irrlicht...

The demo and VC8 solution showing my problem and code is here to
download
btw...

thanks a lot in advance

EDIT...
My physics always updated faster than 4fps actually, I just had quite regular stutters, maybe every 1.5 seconds or so....
But to my own astonishment the demo in the link above also runs smooth now... can anyone see stuttering ? was it my clogged up windows ?

EDIT2:
the media files are included in the irrlicht sdk if thats what you mean
Last edited by zillion42 on Sun Dec 21, 2008 9:41 pm, edited 2 times in total.
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Post by maroxe »

nothing
Last edited by maroxe on Sun Dec 21, 2008 10:30 pm, edited 1 time in total.
FriendlyWarlord
Posts: 58
Joined: Thu Apr 06, 2006 11:54 pm

Post by FriendlyWarlord »

matgaw wrote:I use world->update() with no timestep and I don't have problems. What operating system and compiler are you using? Maybe problem lies there...
Fairly old machine, Windows XP, Visual Studio 2005.
Get this - now I can't get update() to NOT work! Here's the skinny:

-Yesterday I compiled the IrrNewt lib in Debug mode. This allowed me to compile and run examples\demo\demo.cpp with several linker WARNINGS, but my project (with some IrrNewt code) as well as "examples\hello world\hello world.cpp" would give linker errors.

- Running demo.cpp with the Debug mode IrrNewt lib, using update() with no timestep would cause my weird little "slow Newton" problem. Sometimes there would be seconds where the cubes would not move at all, and then suddenly they'd fly several meters in a couple frames. All the while the Irrlicht fire particles would be animating perfectly smoothly.

- Later, I compiled the IrrNewt lib in Release mode, and there was much rejoicing. Both demo.cpp and hello world.cpp worked, as well as the IrrNewt code I'd put into my project. Using update() with no timestep would still cause the above mentioned problem, but I think it was slightly less severe.

- Today, I just tried my crappy Debug-mode lib to see what happens. Same linker errors for my project and hello world.cpp, same linker warnings for demo.cpp. Except now update() with no timestep works perfectly fine! The only thing I can think of that changed was, maybe... I rebooted since installing Newton? Maybe something weird with Visual Studio? Regardless, I can't reproduce this bug...

- My project works fine with update() with no timestep today too (while yesterday that was pretty slow). I've designed my project to use only update(timestep) though.
=D
FriendlyWarlord
Posts: 58
Joined: Thu Apr 06, 2006 11:54 pm

Post by FriendlyWarlord »

maroxe wrote:where can i download the media floder needed for the demos?
I got the media from this IrrNewt version for Irrlicht 1.5 here, I think there are some things that aren't in Irrlicht's media:
http://irrlicht.sourceforge.net/phpBB2/ ... 684#180684

zillion42 wrote:wow, thanks a lot...
Well, when I tried running the demo (demo.cpp), the fire particles and the character animation and the camera would move smoothly at at least 60 FPS, but the cubes I throw moved only a few times a second. I fixed this by using world->update(timestep) instead of just world->update(). I also made sure it called world->update(timestep) only 1/timestep times a second.
could you maybe post some example code, I'm not really sure how to implement a timer in irrlicht...

The demo and VC8 solution showing my problem and code is here to
download
btw...

thanks a lot in advance
I haven't tried your code yet, but the basics of Irrlicht timers are:

device->getTimer() to get the timer object (there's only one timer!)

irr::ITimer->getTime() or device->getTimer()->getTime() to get the time in milliseconds.

irr::ITimer->setTime() to set the timer, if you really need to (From my limited experience, it causes havok for animators in Irrlicht's demos)

And, as far as I know, the Irrlicht timer updates only when device->run() is called.


So, if you want a thing to run at 50 fps, you could do something like:

Code: Select all

s32 timestepInMilliseconds = 1000/50;
s32 time = 0;
device->getTimer()->setTime( 0 );

while( device->run() )
{
	if(device->isWindowActive())
	{
		if( device->getTimer()->getTime() >= timer )
		{
			time = device->getTimer()->getTime() + timestepInMilliseconds;

			//do stuff
			world->update( timestepInMilliseconds/1000.0 );
		}
	}
}

I made a little system where you can set the game/newton update rate and the render update rate independantly. It's set up so even if the renderer can only handle 8 or so frames per second, the game still updates at normal speed (although it'll only poll for keyboard/mouse input at 8 times... unavoidable because as far as I know Irrlicht is single-threaded). If the game can't update as fast as you tell it for a frame or two, it'll try and catch up by not rendering some frames, thus maintaining a constant game update rate (unless your machine simply can't handle it). Oh oh, and it can tell you how many frames it rendered and how many game updates it did in a second! And it can handle any frame-rate you tell it. 74.8 updates a second? Sure! Some day I'll post it in the code snippets section or something ;D


And, uh, sorry for the double post. And sorry that this had little to do with IrrNewt =p
=D
JJJohan
Posts: 7
Joined: Thu Dec 18, 2008 11:49 am
Location: Brisbane, Australia
Contact:

Post by JJJohan »

I'm getting quite a few warnings/errors here with the IrrNewt 1.5 version in Visual Studio 2008 when I try to compile any of the examples.

Code: Select all

1>c:\users\jjjohan\desktop\irrnewt\include\hidden.hpp(186) : warning C4244: 'argument' : conversion from 'irr::f64' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\hidden.hpp(186) : warning C4244: 'argument' : conversion from 'irr::f64' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\hidden.hpp(186) : warning C4244: 'argument' : conversion from 'irr::f64' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\utils.hpp(93) : warning C4244: 'argument' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\utils.hpp(93) : warning C4244: 'argument' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\utils.hpp(93) : warning C4244: 'argument' : conversion from 'irr::s32' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\include\utils.hpp(195) : error C2668: 'pow' : ambiguous call to overloaded function
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(575): could be 'long double pow(long double,int)'
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(573): or       'long double pow(long double,long double)'
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(527): or       'float pow(float,int)'
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(525): or       'float pow(float,float)'
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(489): or       'double pow(double,int)'
1>        c:\program files\microsoft visual studio 9.0\vc\include\math.h(123): or       'double pow(double,double)'
1>        while trying to match the argument list '(int, irr::u32)'
1>c:\users\jjjohan\desktop\irrnewt\include\world.hpp(284) : warning C4244: '=' : conversion from 'irr::u32' to 'irr::f32', possible loss of data
1>c:\users\jjjohan\desktop\irrnewt\examples\car\car.cpp(227) : error C2259: 'MyEventReceiver' : cannot instantiate abstract class
1>        due to following members:
1>        'bool irr::IEventReceiver::OnEvent(const irr::SEvent &)' : is abstract
1>        c:\irrlicht\include\ieventreceiver.h(351) : see declaration of 'irr::IEventReceiver::OnEvent'
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Post by maroxe »

"error C2668: 'pow' : ambiguous call to overloaded function"
just add a cast befoire parameters of this function
"error C2259: 'MyEventReceiver' : cannot instantiate abstract class"
replace:
bool irr::IEventReceiver::OnEvent(irr::SEvent )
with:
bool irr::IEventReceiver::OnEvent(const irr::SEvent &)
maroxe
Posts: 51
Joined: Wed Dec 10, 2008 1:52 pm

Post by maroxe »

ho can we make a static object with irrnewt?
JJJohan
Posts: 7
Joined: Thu Dec 18, 2008 11:49 am
Location: Brisbane, Australia
Contact:

Post by JJJohan »

Hmm I've seem to fix the last two errors, but now I've got a whole bunch of new ones, but they're too dynamic to list right now..
Fex
Posts: 4
Joined: Wed Dec 24, 2008 12:35 am

Post by Fex »

Can someone post the .lib for 1.4 please. and maybe fix up some 1.5 stuff?
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

@JJJohan & Fex

read the thread, someone has already posted a link to a fixed 1.5 version...

also searching helps alot...

http://irrlicht.sourceforge.net/phpBB2/ ... hlight=pow

http://irrlicht.sourceforge.net/phpBB2/ ... tMap%20mb2
FriendlyWarlord
Posts: 58
Joined: Thu Apr 06, 2006 11:54 pm

Post by FriendlyWarlord »

I've been stuck on a Newton problem for several days, but now it's gotten to the point that I can't really proceed until I fix it:

Is it possible to find out if a particular newton body is in contact with something? I need something like this to figure out when my character is/isn't on the ground, and other similar things. Or, is there some primitive collision detection from Irrlicht that I can use?


And now a boring list of things I have tried that didn't work:

The first thing I tried was extremely quick & dirty; it did IBody->setPosition(), then it would run the physics, then it would check if the body's position had changed (e.g. if it had bounced off a wall or floor). This worked some of the time, but was pretty unreliable.

Another similar approach: set the position and velocity of the object, then run the physics, then check whether or not the body is in the place that it would be if it didn't hit a wall. I managed to implement some things (jumping, running up/down ramps and stairs without losing traction), but again the "collision detection" worked only most of the time, and wasn't good enough. No biggie, because all along I was planning to use........

.....Collision callbacks! The ContactProcess() event fires exactly when I want it to, but it doesn't tell me which bodies are involved! The player interaction with walls and floors is quite complex - I need to know this "is the body touching a wall" state for about 7 different bodies, and making 7 different materials for this would be quite silly ^_^


It's looking like I need to use UserData for something, but it's not clear how I can get the user data from inside the callback function.

I did notice though that with ContactProcess you get a IMaterialPairAndContact object, which contains a newton NewtonContact structure. I must be crazy because I can't find anywhere what data this NewtonContact structure contains! I don't even know if I need to use it or not...

I've also thought about simply casting rays for collision detection, but I don't think I could make a very robust character controller out of that.


So yeah, I thought this problem would be incredibly simple, but apparently not. Help?
=D
matgaw
Posts: 45
Joined: Sat Oct 06, 2007 11:33 am

Post by matgaw »

This is my simple function to check if the character is on floor (or any other object):

Code: Select all

    line3df line;
    line.start=Camera.Node->getPosition();
    line.end=line.start;
    line.end.Y-=35;
    SIntersectionPoint point=World->getCollisionManager()->getCollisionFirstPoint(line);

    if (point.body)
        return true;
    else
        return false;
You may want to change the "35" parameter to your own. You can also determine the type of the body by using the point.body attributes etc.
Post Reply