Hi Lukas,

You can't do a addChild() on a object that is a subclass from
osg::Geode because Geode has no addChild() method. Please look at the
headers.

Robert.

On 5 January 2014 12:40, Lukas Koebler <lukasnachhi...@gmail.com> wrote:
> Hi,
>
> I´m new in OSG and I hope you can help me.
> I´ve done a new constructor called "3dBox". In this constructor I wanna 
> create a cube.
>
> Code:
>
>         mp_Quader2 = new Geode();
>
>         3dBox(*mp_Quader2);
>
>         this->addChild(mp_Quader2);
>
>
>
> This is how I want it in the end. But it doesn´t work jet.
> The constructor:
>
> Code:
>
> 3dBox::3dBox(Geode *mQuader){
>         //mQuader = new Geode();
>
>         // Eigene Geometrie Klasse erzeugen
>         mGeom = new Geometry();
>         // Punktearray mit 6 Punkten für schrägen Quader
>         Vec3Array *vec3array = new Vec3Array();
>         Vec3Array *vec3array2 = new Vec3Array();
>         vec3array->push_back(Vec3(0.,0.,-50.));
>         vec3array->push_back(Vec3(200,0.,-50.));
>         vec3array->push_back(Vec3(200,100,-50.));
>         vec3array->push_back(Vec3(0.,100,-50.));
>
>         vec3array->push_back(Vec3(0.,0.,120));
>         vec3array->push_back(Vec3(150,0.,120));
>         vec3array->push_back(Vec3(150,100,300));
>         vec3array->push_back(Vec3(0.,100,300));
>
>         // Indexarray erzeugen
>         DrawElementsUInt *indarray = new 
> DrawElementsUInt(PrimitiveSet::QUADS,0);
>         indarray->push_back(0); indarray->push_back(1); 
> indarray->push_back(2); indarray->push_back(3);
>         indarray->push_back(4); indarray->push_back(5); 
> indarray->push_back(6); indarray->push_back(7);
>         indarray->push_back(0); indarray->push_back(1); 
> indarray->push_back(5); indarray->push_back(4);
>         indarray->push_back(3); indarray->push_back(2); 
> indarray->push_back(6); indarray->push_back(7);
>         indarray->push_back(0); indarray->push_back(3); 
> indarray->push_back(7); indarray->push_back(4);
>         indarray->push_back(1); indarray->push_back(2); 
> indarray->push_back(6); indarray->push_back(5);
>
>         mGeom->setVertexArray(vec3array);
>         mGeom-> addPrimitiveSet(indarray);
>
>         HfT_osg_StateSet *stateset = new 
> HfT_osg_StateSet(STRANSPARENT,Vec4(1.,0.,0.,0.5));
>         mGeom->setStateSet(stateset);
>
>         // Jetzt geom der geode zuweisen
>         mQuader->addDrawable(mGeom);
>         mQuader->setName("TestQuader");
>         mTrans = new MatrixTransform();
>         mTrans->addChild(mQuader);
> }
>
>
>
>
> In the header:
>
> Code:
>
> class 3dBox : public osg::Geode
>
>
>
>
> Can you help me and explane to me why I can´t do
>
> Code:
>
> this->addChild(mp_Quader2);
>
>
>
> and what I can do to make it work.
>
>
> Important to say is when I do the thinks I do in the constructor in the class 
> it works fine.
>
> Thank you!
>
> Cheers,
> Lukas
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=57796#57796
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to