Code: Simple Node Rotator

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Code: Simple Node Rotator

Post by dejai »

Hey have you ever seen in those games where the player moves around a 2d tree like in the early nitendo games and it seems to follow him well this is a simple snippet for that. Its not full source but it is a fun small code snippet and can save a bit of processing for trees in the distance that cannot be reached. Or For the Rotation of a portal and or enemy to face the player.

(Comments Are Appreciated)

:D

Code: Select all


/////////// Game While Loop /////////////
while (device->run())// While Device is Running Do..
{
    
driver->beginScene(true, true, SColor(221,122,212,221));// Start The Scene
      smgr->drawAll();// Draw all Scene Manager
      guienv->drawAll();// Draw All Gui Environment
      
vector3df portalrot = player_node->getRotation();
portalrot.X = 0; // This stops it rotating on the X Axis
portalrot.Z = 0; // This stops it rotating on the Z Axis

portal_node->setRotation(portalrot); // Opps Forgot to add this

driver->endScene();
}
device->drop();
return 0;

Comments on the code are thanked.
Last edited by dejai on Fri Oct 12, 2007 2:40 pm, edited 1 time in total.
Programming Blog: http://www.uberwolf.com
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post by dejai »

Err, maybe I shouldn't have posted it the codes so simple............
.....

I'll add a portal soon than without the seeing into the other area from your section.
Programming Blog: http://www.uberwolf.com
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Also, this code does nothing. ;)

vector3df portalrot is initialised to be a copy of the node's rotation, it is not a reference to it. Changing the values in portalrot will have no effect on the node itself.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Urgh, no, I get what you mean, but you can't use the existing Irrlicht billboard for trees or anything more complex than really simple effects. Shudder.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
shogun
Posts: 162
Joined: Wed Sep 05, 2007 11:02 am
Location: inside

Post by shogun »

Yeah. But "billboard" just describes what dejai wants, not my fault if Irrlicht doesn't allow to use them for trees.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply