Hi,
I have a 3DS model. How can I add tihs model as done in 2D images with Geode
and Geometry. This code adds 2D objects. What modifications should I make on it?
ref_ptr<Geode> geode(new Geode());
ref_ptr<Geometry> geometry(new Geometry());
ref_ptr<Vec3Array> vertices(new Vec3Array());
vertices->push_back(Vec3(objectPosition[0], objectPosition[1],
objectZCoordinate));
vertices->push_back(Vec3(objectPosition[2], objectPosition[1],
objectZCoordinate));
vertices->push_back(Vec3(objectPosition[2], objectPosition[3],
objectZCoordinate));
vertices->push_back(Vec3(objectPosition[0], objectPosition[3],
objectZCoordinate));
geometry->setVertexArray(vertices.get());
ref_ptr<Vec4Array> colors(new Vec4Array());
colors->push_back(Vec4(1.0f, 1.0f, 1.0f, 1.0f));
geometry->setColorArray(colors.get());
geometry->setColorBinding(Geometry::BIND_OVERALL);
ref_ptr<Vec3Array> normals(new Vec3Array());
normals->push_back (Vec3(0.0f, -1.0f, 0.0f));
geometry->setNormalArray(normals.get());
geometry->setNormalBinding(Geometry::BIND_OVERALL);
ref_ptr<Image> image(readImageFile(objectPath));
ref_ptr<Texture2D> texture(new Texture2D);
texture->setImage(image.get());
ref_ptr<StateSet> stateSet(geode->getOrCreateStateSet());
stateSet->setTextureAttributeAndModes (0, texture.get(),
StateAttribute::ON);
ref_ptr<Vec2Array> texCoords(new Vec2Array());
texCoords->push_back(Vec2(0.0, 0.0));
texCoords->push_back(Vec2(0.0, 1.0));
texCoords->push_back(Vec2(1.0, 1.0));
texCoords->push_back(Vec2(1.0, 0.0));
geometry->setTexCoordArray(0, texCoords.get());
geometry->addPrimitiveSet(new DrawArrays(PrimitiveSet::QUADS, 0,
vertices->size()));
geode->addDrawable(geometry.get());
return geode;
Thank you!
Cheers,
George
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=23936#23936
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org