title: OpenSceneGraph - Drawing a 3D Wall
body: <p>I have the code below. I got the idea from a tutorial but my code does not show anything when run. The goal is to draw  Wall in 3d. My guess is that my points may be off but I am not sure how best to pick points, and also scale. </p>
  
  <pre><code>void BuildWall(osg::Group* root)
  {
  
      osg::Geode* WallGeode = new osg::Geode();
      osg::Geometry* WallGeometry = new osg::Geometry();
  
      WallGeode-&gt;addDrawable(WallGeometry);
      //add the Node to the root Node
      root-&gt;addChild(WallGeode);
      //specify vertices
      osg::Vec3Array* WallVertices = new osg::Vec3Array;
      WallVertices-&gt;push_back( osg::Vec3(0, 0, 0) ); // front left
      WallVertices-&gt;push_back( osg::Vec3(10, 0, 0) ); // front right
      WallVertices-&gt;push_back( osg::Vec3(10,10, 0) ); // back right
      WallVertices-&gt;push_back( osg::Vec3(0,10, 0) ); // back left 
      WallGeometry-&gt;setVertexArray( WallVertices );
  
      //specify the kind of geometry we want to draw here
      osg::DrawElementsUInt* WallBase = new osg::DrawElementsUInt(osg::PrimitiveSet::QUADS, 0);
      //specify the order we want to draw the base of our geometry
      WallBase-&gt;push_back(3);
      WallBase-&gt;push_back(2);
      WallBase-&gt;push_back(1);
      WallBase-&gt;push_back(0);
      WallGeometry-&gt;addPrimitiveSet(WallBase);
  
      //Declare and load an array of Vec4 elements to store colors.
      osg::Vec4Array* colors = new osg::Vec4Array;
      colors-&gt;push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 0 red
      colors-&gt;push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f) ); //index 1 green
      colors-&gt;push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f) ); //index 2 blue
      colors-&gt;push_back(osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f) ); //index 3 white
      //colors-&gt;push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f) ); //index 4 red
  
      WallGeometry-&gt;setColorArray(colors);
      WallGeometry-&gt;setColorBinding(osg::Geometry::BIND_PER_VERTEX);
  
      // Declare and initialize a transform node.
      osg::PositionAttitudeTransform* WallTwoXForm = new osg::PositionAttitudeTransform();
  
      // Use the 'addChild' method of the osg::Group class to
      // add the transform as a child of the root node and the
      // pyramid node as a child of the transform.
      root-&gt;addChild(WallTwoXForm);
      WallTwoXForm-&gt;addChild(WallGeode);
      float scale=root-&gt;getBound().radius();
      WallTwoXForm-&gt;setScale(osg::Vec3d(scale,scale,scale));
  
      // Declare and initialize a Vec3 instance to change the
      // position of the tank model in the scene
      osg::Vec3 WallTwoPosition(15,0,0);
  
      WallTwoXForm-&gt;setPosition(WallTwoPosition );
  
  }
  </code></pre>