how to draw an arrow object or a line object in the scene?
how to draw an arrow object or a line object in the scene?
I am trying to add a line which connects two objects, and an arrow pointing away from an object in the scene.
Do I have to create a scene node for an arrow or line? Such as creating an ArrowSceneNode?
Or can I use OpenGL to directly draw some lines there? It doesn't look I can use OpenGL to draw directly. No complaint when compiling but I see no opengl graphics output.
Do I have to create a scene node for an arrow or line? Such as creating an ArrowSceneNode?
Or can I use OpenGL to directly draw some lines there? It doesn't look I can use OpenGL to draw directly. No complaint when compiling but I see no opengl graphics output.
-
SwitchCase
- Posts: 170
- Joined: Sun Jul 01, 2007 11:41 pm
- Location: Manchester, UK
Code: Select all
IAnimatedMesh* arrowMesh = smgr->addArrowMesh ("arrowMesh");
Code: Select all
IAnimatedSceneNode* arrowNode = smgr->addAnimatedMeshSceneNode (arrowMesh);
Code: Select all
ISceneNode* arrowNode = smgr->addSceneNode ("arrowMesh");
There are extra parameters, default values are used if you don't pass these member functions some parameters, the only essential ones are the first though. - look in the Irrlicht documentation in the 'irrlicht/docs/' folder. A search for "arrow mesh" sends you to irr::scene::ISceneManager Class Reference where you'll find what you need.
As for changing the size of the arrow:
Code: Select all
arrowNode->setScale (vector3df(x value, y value, z value) );
You need to look in the documentation when you have questions like this in the future. And i'm sure by doing this you'll also be able to find out about drawing lines.
Thank you for the help. I am trying to convert a direction vector, i.e., a vector pointing from one point to another, to a 'rotation' matrix, so that I can assign this rotation matrix to the arrowMesh. How to do it properly?
I am a bit confused by the coordinate system of Irrlicht. Is it a left-hand system?
Thanks again,
I am a bit confused by the coordinate system of Irrlicht. Is it a left-hand system?
Thanks again,
-
SwitchCase
- Posts: 170
- Joined: Sun Jul 01, 2007 11:41 pm
- Location: Manchester, UK
Why do you need a matrix? Simply give the scenenode rotation setter function your vector.
Where your vector is of type irr::core::vector3df

Code: Select all
sceneNode->setRotation ( yourVector );-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
I think what humorstar may be wanting is something like this:
Code: Select all
#include "irrlicht.h"
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
IrrlichtDevice *device = createDevice( EDT_OPENGL,
dimension2d<s32>(800, 600),
32);
ISceneManager* smgr = device->getSceneManager();
IVideoDriver* driver = device->getVideoDriver();
(void)smgr->addCameraSceneNode();
IBillboardSceneNode * bill = smgr->addBillboardSceneNode();
bill->setMaterialType(video::EMT_SOLID );
bill->setMaterialTexture(0, driver->getTexture("../../media/wall.bmp"));
bill->setMaterialFlag(video::EMF_LIGHTING, false);
ISceneNodeAnimator * animator = smgr->createFlyCircleAnimator(vector3df(0, 0, 100), 40.f, 0.005f, vector3df(1, 1, 1).normalize());
bill->addAnimator(animator);
animator->drop();
// The arrow mesh points towards +Y, but getHorizontalAngle() assumes +Z
// so we'll use a parent node to rotate the arrow mesh node by 90 degrees.
ISceneNode * arrowParent = smgr->addEmptySceneNode();
arrowParent->setPosition(vector3df(0, 0, 100));
ISceneNode * arrow = smgr->addAnimatedMeshSceneNode(smgr->addArrowMesh("arrow",
SColor(255, 255, 0, 0), SColor(255, 0, 255, 0)), arrowParent);
arrow->setMaterialFlag(video::EMF_LIGHTING, false);
arrow->setRotation(vector3df(90, 0, 0));
arrow->setScale(vector3df(20, 20, 20));
while (device->run())
{
driver->beginScene(true, true, video::SColor(0,100,100,100));
smgr->drawAll();
driver->endScene();
const vector3df toBillboard = (bill->getAbsolutePosition() - arrow->getAbsolutePosition()).normalize();
const vector3df rotations = toBillboard.getHorizontalAngle();
arrowParent->setRotation(rotations);
}
}
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
rogerborg
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
Ah, right, getHorizontalAngle() wasn't made const until after 1.4.2. Happy to help.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way