IrrNewt irrlicht\newton framework >> SVN access

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Yes, uniformally scaling the node to any size works just fine. It even put the rotation on track. I can work around this limitation for this particular project. Thanks!

So now I have some new issues.... sorry to be such a bother :oops:

Code: Select all

     if(gameManager->getRightKey())
     {
        p1body->setVelocity(vector3df(2.0f,0,0));
     }
     if(gameManager->getLeftKey())
     {
        p1body->setVelocity(vector3df(-2.0f,0,0));
     }
     if(gameManager->getDecimalKey())
        p1body->jump(100);
     if(gameManager->getDownKey())
     {
        if(p1body->crouch(0.5))
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
     }
     else if(p1body->stand(3))
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
issue 1: My character simply doesn't jump at all. Judging by how everything is scaled my charater should jump off of the screen at 100...

issue 2: Just holding crouch causes the character to move up very slowly... this IS with the 'addforcecontinuous' line from my previous code un-commented...

issue 3: I'm also noticing my character moves faster in the air than on the ground...
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

Yes, uniformally scaling the node to any size works just fine. It even put the rotation on track. I can work around this limitation for this particular project. Thanks!
i found the bug in the next release you can build a tree body also from node not scaled uniformly
issue 1: My character simply doesn't jump at all. Judging by how everything is scaled my charater should jump off of the screen at 100...
i don't understand the last phrase "my charater should jump off of the screen at 100". however try to reduce the second parameter (you didn't set it) passed to jump(). for default it is 27, try 23 for example but don't insert too low value or your character will jump also when he's on air. this parameter control the min distance from floor to jump
issue 2: Just holding crouch causes the character to move up very slowly... this IS with the 'addforcecontinuous' line from my previous code un-commented...
improve the first value you pass to stand() function (make your character stand up immediately) and\or set softness between character and floor to a higher value than 0, for example 0.5 or 1 (make your character to stand up gradually but faster)

Code: Select all

p1material->setSoftness(floormaterial,0.0f); 
issue 3: I'm also noticing my character moves faster in the air than on the ground...
set friction between character and floor to 0 trought material
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

i don't understand the last phrase "my charater should jump off of the screen at 100". however try to reduce the second parameter (you didn't set it) passed to jump(). for default it is 27, try 23 for example but don't insert too low value or your character will jump also when he's on air. this parameter control the min distance from floor to jump
I have a camera at a fixed distance. Judging by the fact that my nodes go out of the camera's view with about 40 units of movement either direction 100 should send my character flying. I just didn't want you to thing I had everything scaled so large that I couldn't see 100 units of movement.

Setting the second parameter to 1 or 300 had no effect. He just can't jump.
improve the first value you pass to stand() function (make your character stand up immediately) and\or set softness between character and floor to a higher value than 0, for example 0.5 or 1 (make your character to stand up gradually but faster)

Code: Select all

p1material->setSoftness(floormaterial,0.0f); 
I set the softness to 1 and stand to 6 as in your example but he still goes up slowly and he even jumps when i let go... I think this is because his collision frame is going into the floor... so he slowly goes up because I'm trying to keep him down... when I release he just 'pops' out.
set friction between character and floor to 0 trought material
Yay!
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

I set the softness to 1 and stand to 6 as in your example but he still goes up slowly and he even jumps when i let go... I think this is because his collision frame is going into the floor... so he slowly goes up because I'm trying to keep him down... when I release he just 'pops' out.
yes, with collision frame into floor it's normal he tries to put its own collision shape out the floor by goes down. you should try to don't put the collision frame into the floor. for example use EOM_PRECISE in setFrictionModel or simply reduce the gravity when courching. however this is a bug of newton, if you set a force too high and the body is very close to a wall\floor , the body will go trough the floor\wall for a certain time
I have a camera at a fixed distance. Judging by the fact that my nodes go out of the camera's view with about 40 units of movement either direction 100 should send my character flying. I just didn't want you to thing I had everything scaled so large that I couldn't see 100 units of movement.
Setting the second parameter to 1 or 300 had no effect. He just can't jump.
but is there a floor below your character when you try to jump?
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

yes, with collision frame into floor it's normal he tries to put its own collision shape out the floor by goes down. you should try to don't put the collision frame into the floor. for example use EOM_PRECISE in setFrictionModel or simply reduce the gravity when courching. however this is a bug of newton, if you set a force too high and the body is very close to a wall\floor , the body will go trough the floor\wall for a certain time
right I'll play with that now and see if I can get it to work.
but is there a floor below your character when you try to jump?
Yes.

I decided since I needed an 'isJumping()' function anyway I'd write it and try to use that to make my character jump. It works just fine. Here is the code for it:

Code: Select all

bool irr::newton::ICharacterController::isJumping(irr::f32 distanceFromFloor) {

	core::aabbox3d<f32> box=this->calculateAABB();

	core::line3d<f32> line(box.MinEdge,core::vector3df());
	line.end=line.start;
	line.end.Y-=999999.9f;

	irr::newton::SIntersectionPoint i_point=
		this->world->getCollisionManager()->getCollisionFirstPointEx(line);

	if(i_point.body!=NULL) {

		irr::f32 distance=i_point.point.getDistanceFrom(line.start);

		if(distance <= distanceFromFloor) {

			core::vector3df net_applied_force=this->getNetAppliedForce();

			/*
			//DEBUG
			core::stringc m;
			m+=(double)net_applied_force.Y;
			this->world->getIrrlichtDevice()->getLogger()->log(m.c_str());
			*/

			this->world->getUtils()->round(net_applied_force,1);

			/*
			//DEBUG
			m="";
			m+=(double)net_applied_force.Y;
			this->world->getIrrlichtDevice()->getLogger()->log(m.c_str());
			*/

			if(net_applied_force.Y==0.0f)
				//can jump!!
				return false;
			else
	         return true;		
				
			}//distance

		}//body!=NULL
		return false;
	}
You might want to include it in your next version as some people may want to disable movement while jumping, incorporate flips, etc...

feel free to tell me if I screwed up the code XD I think something may be wrong with it as when I set the value to 10 or lower it is always true...

That also means that the part of jump() that isn't working for me is the code that actually makes the body jump.

EDIT: my crouching code is... closer. He jumps a little bit the first time, a little less the second time, and not at all afterwards. Crouching while in the air does play havoc with gravity... but thats not a problem because my game doesn't need crouching in the air. Heres what it is at now...

Code: Select all

     if(gameManager->getDownKey())
     {
        p1body->setScale(vector3df(0.5f,0.5f,0.5f));
        pworld->getUtils()->avoidRotationOnAllAxis(p1body);
        p1node->setScale(vector3df(1,1,1));
        if(p1body->crouch(0.5))
        {
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
           
        }
     }
     else if(p1body->stand(6))
     {
           p1body->addForceContinuous(vector3df(0,0,0));
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
           p1body->addForceContinuous(vector3df(0,-30.0f,0));
     }
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

kburkhart84 wrote:@White Tiger.

You probably already know this, but your little library thingy(IrrNewt) has been ported by SIO2 to be used in IrrSpintz. Don't think it is any problem but just in case. Not trying to cause trouble though. I think it's a good thing...
a) IrrNewt is LGPL.
b) I included a link to the source code in the post on the IrrSpintz forum.
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

@ kburkhart84:

Thanks, i didn't know it. he said nothing to me :?
a) IrrNewt is LGPL.
yes i knew that :D
b) I included a link to the source code in the post on the IrrSpintz forum.
in fact no one has accused you, neither kburkhart84 or I.
only i'm saying you would say that :wink:
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

Code: Select all

if(distance <= distanceFromFloor) { 
doesn't it would be

if(distance >= distanceFromFloor) {

because if distance>distanceFromFloor the character is flying and so it's jumping

also since jump function modify velocty you should base it on velocity and not on net applied force


again

Code: Select all

p1body->setScale(vector3df(0.5f,0.5f,0.5f)); 
pworld->getUtils()->avoidRotationOnAllAxis(p1body); 
p1node->setScale(vector3df(1,1,1)); 
if(p1body->crouch(0.5)) 
crouch() function call IBody::setScale internally and it does not have much sense and

Code: Select all

p1body->addForceContinuous(vector3df(0,0,0)); 
in my personal opinion adding 0 to a value wouldn't change the final result :D

hope i'm not too hard with criticisms to your code :wink:
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

white tiger wrote:@ kburkhart84:
a) IrrNewt is LGPL.
yes i knew that :D
b) I included a link to the source code in the post on the IrrSpintz forum.
in fact no one has accused you, neither kburkhart84 or I.
only i'm saying you would say that :wink:
Why are you replying to my reply to someone else? Points a) and b) are for kburkhart84. You made the license - of course you know it's LGPL.
white tiger wrote:Thanks, i didn't know it. he said nothing to me :?
And just why am I supposed to have told you?
white tiger wrote:only i'm saying you would say that :wink:
I would say what? You're implying I'm doing something underhand when all I've done is comply with the license (and I haven't even released anything that uses IrrNewt yet).

Geez. All I've done is release some source code. There's no need for any discussion about it.
white tiger
Posts: 269
Joined: Tue Oct 31, 2006 3:24 pm
Contact:

Post by white tiger »

@sio2:
all I've done is comply with the license
I think that's no right. you didn't put a note (wich says that the file is modified) in the files you have changed with the date of every change , and so you are breaking GNU\LGPL in "TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION" , '2' section , 'b' paragraph

However i didn't say that (opposite i have said "in fact no one has accused you"). I don't want to fight with you and have nothing with you.

i have only said that if you want you can post that you have wrote a porter so we can discuss about put your porter in my site. If you don't want to post not post, it's not compulsory. in fact i have said "you would post" and not "you must post"

sio2 wrote:
white tiger wrote:Thanks, i didn't know it. he said nothing to me
And just why am I supposed to have told you?
Why are you replying to my reply to someone else?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Stop this childish bickering at once....lol
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

white tiger wrote:

Code: Select all

if(distance <= distanceFromFloor) { 
doesn't it would be

if(distance >= distanceFromFloor) {

because if distance>distanceFromFloor the character is flying and so it's jumping

also since jump function modify velocty you should base it on velocity and not on net applied force
He doesn't jump at all with >=.... all I did was copy your jump function and remove the jumping part and replaced it with return true and return false :P Doesn't that mean your jump function should base on velocity as well?

again

Code: Select all

p1body->setScale(vector3df(0.5f,0.5f,0.5f)); 
pworld->getUtils()->avoidRotationOnAllAxis(p1body); 
p1node->setScale(vector3df(1,1,1)); 
if(p1body->crouch(0.5)) 
crouch() function call IBody::setScale internally and it does not have much sense and
My character node never changed scale when it crouched... just moved down into the floor... perhaps you used a non-uniform scale and came across the same bug you fixed earlier?

Code: Select all

p1body->addForceContinuous(vector3df(0,0,0)); 
in my personal opinion adding 0 to a value wouldn't change the final result :D
You're right; I regarded it as setForceContinuous; not add.... so I'm back to the jumping character problem...
hope i'm not too hard with criticisms to your code :wink:
Its the only way I can learn :P
olivehehe_03
Posts: 157
Joined: Tue Mar 20, 2007 8:30 am

Post by olivehehe_03 »

I just noticed something wierd...I've got a car driving around on my terrain and I was just messing around to see what the framerate was like with and without vsync (about 60 with and 200 without) and it might just be me, but it seems like my car took longer to get to it's max steering angle when the framerate was 60 than it did when the framerate was 200. Basically, it was turning slower.

I guess what I'm asking is are the "newton::ICar->turnRight();" and "newton::ICar->turnLeft();" functions framerate independant?

Also, while I'm here, how would I make a vehicle have more than 4 wheels? I want to make a tank and I want it to have 8 wheels (4 on each side) so that it reacts realistically. And if it's possible, instead of turning the front two wheels to steer, i want to be able to make the wheels on the left side turn separately to the ones on the right side. I'm not asking you to write code for me, I'm just asking if it's possible :D

Thanks in advance
Last edited by olivehehe_03 on Mon Jun 04, 2007 4:13 am, edited 1 time in total.
Tell me what you cherish most. Give me the pleasure of taking it away.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

An update on my code.. I've got jumping working... I'm just checking my character's velocity now... I thought there was a minute chance of "double jumping" but it hasn't ever happened yet... and I've been toying with it lots... so my only issue now is the jumping after releasing crouch. I also tried setting my node's position when it stops crouching to be sure its not in the ground... it still jumps up when I stop.
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Woo! I've fixed all my problems. The code acts as expected like this:

Code: Select all

if(gameManager->getEscapeKey())
     {
        gameManager->stopMusic();
        gameManager->resetPause();
        gameManager->setGameState(1);
     }
     if(gameManager->getPKey())
     {
        if(!gameManager->isPaused())
           gameManager->setPause(true);
        else
           gameManager->setPause(false);
     }
     if(gameManager->getDecimalKey() && (p1body->getVelocity().Y <= 0.02f) && (p1body->getVelocity().Y >= -0.02f))
        p1body->setVelocity(vector3df(p1body->getVelocity().X,8.0f,p1body->getVelocity().Z));
     if(gameManager->getRightKey() && !gameManager->getLeftKey())
        p1body->setVelocity(vector3df(2.0f,p1body->getVelocity().Y,0));
     else if(gameManager->getLeftKey() && !gameManager->getRightKey())
        p1body->setVelocity(vector3df(-2.0f,p1body->getVelocity().Y,0));
     else
        p1body->setVelocity(vector3df(0,p1body->getVelocity().Y,0));
     if(gameManager->getDownKey() && p1body->getVelocity().Y <= 0.02f && p1body->getVelocity().Y >= -0.02f)
     {
        if(p1body->crouch(0.5))
        {
           p1body->setScale(vector3df(0.5f,0.5f,0.5f));
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
           p1node->setScale(vector3df(1,1,1));
           pworld->getUtils()->avoidRotationOnAllAxis(p1body); 
        }
     }
     else if(p1body->isCrouching())
     {
        if(p1body->stand(6))
        {
           p1body->setVelocity(vector3df(p1body->getVelocity().X, 0, 0));
           pworld->getUtils()->avoidRotationOnAllAxis(p1body);
        }
     }
Post Reply