Skip to main content
Line 3D         A fine code snippet to create a line in 3D space

Independent of distance to the camera, it is always visible with one pixel width (unless there is an object in between the line and the camera).

Note: Recent version of Ogre::Material does not have a dispose() method, so if you get a compile error simply remove the line:

Copy to clipboard
myManualObjectMaterial->dispose(); // dispose pointer, not the material

From the following code

Copy to clipboard
Ogre::ManualObject* myManualObject = mSceneMgr->createManualObject("manual1"); Ogre::SceneNode* myManualObjectNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("manual1_node"); // NOTE: The second parameter to the create method is the resource group the material will be added to. // If the group you name does not exist (in your resources.cfg file) the library will assert() and your program will crash Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("manual1Material","General"); myManualObjectMaterial->setReceiveShadows(false); myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true); myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0); myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(0,0,1); myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1); myManualObjectMaterial->dispose(); // dispose pointer, not the material myManualObject->begin("manual1Material", Ogre::RenderOperation::OT_LINE_LIST); myManualObject->position(3, 2, 1); myManualObject->position(4, 1, 0); // etc myManualObject->end(); myManualObjectNode->attachObject(myManualObject);

See also



Alias: Line3D