reading file data and making models move accordingly

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

That looks like you have an object with an ID of 0. I assumed from the sample file - and lack of requirements - that your objects were 1 indexed. If they're 0 indexed, then you could change the indexing in the code, e.g.:

Code: Select all

objects.set_used(id + 1);
...
objects[id] = newNode;
...
objects[command.objectId]->setPosition(command.newPosition);
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
delinkx
Posts: 13
Joined: Mon Aug 04, 2008 3:26 am

Post by delinkx »

rogerborg wrote:That looks like you have an object with an ID of 0. I assumed from the sample file - and lack of requirements - that your objects were 1 indexed. If they're 0 indexed, then you could change the indexing in the code, e.g.:

Code: Select all

objects.set_used(id + 1);
...
objects[id] = newNode;
...
objects[command.objectId]->setPosition(command.newPosition);
:) yeps ! sorry dude.. again my mistake.. in the 32 agents file, it starts with index 1. this one with index 0. cool. now am working on the orientation. i added the animation. this works fine. now working on the orientation. actually my objects are players. when they move, i need make them move and face the direction.

will keep u updated on the success of this part.

thnx again for ur help. greatly appreciated.
delinkx
Posts: 13
Joined: Mon Aug 04, 2008 3:26 am

Post by delinkx »

rogerborg wrote:That looks like you have an object with an ID of 0. I assumed from the sample file - and lack of requirements - that your objects were 1 indexed. If they're 0 indexed, then you could change the indexing in the code, e.g.:

Code: Select all

objects.set_used(id + 1);
...
objects[id] = newNode;
...
objects[command.objectId]->setPosition(command.newPosition);
bro.. i completed that. thnx for ur help. i modified it little. to make it sure it moves within 50 milliseconds.

here the updated, let me knw if anything wrong in it...

Code: Select all

if(elapsedTime >= command.atTime)
				{
					
					diff = objects[command.objectId]->getPosition();
					//objects[command.objectId - 1]->setPosition(command.newPosition);
					//diff = objects[command.objectId - 1]->getPosition();
					
					resultDegrees = change_orientation(diff, command.newPosition);
					
					objects[command.objectId]->setRotation(resultDegrees);


					anim_node = smgr->createFlyStraightAnimator(diff, command.newPosition, 50, false);
					objects[command.objectId]->addAnimator(anim_node);
					
					diff = objects[command.objectId]->getPosition();
					
					
					commands.erase(eraseMe);
					
					
				}



i used the animator and time 50 so tat make sure the movement is done within tat time.

and the function change_orientation() calculates the angle between current position and next position to be moved to. so tat the model is turned to face tat position.

yeps tats it..

let me know if there is any mistake or improvement.

thnx again.
Post Reply