Please search the forum email archives this TOPIC has been talked about
100’s of times 

 

These shapes are not meant to be used as drawing and textured  shapes.

 

 

__________________________________________________________
Gordon Tomlinson 

 <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
IM:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
 <http://www.vis-sim.com/> www.vis-sim.com
<http://www.gordontomlinson.com/> www.gordontomlinson.com 

__________________________________________________________

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of xuyuanzhen1
Sent: Wednesday, September 10, 2008 12:48 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] Utility functions

 

Hello all,

 

      But how to take texture to this shapes?For example,I draw a cylinder
by following code:

-------------------------------------------------------

osg::ref_ptr <osg::Cylinder > cylinder = new

osg::Cylinder(osg::Vec3f(), 2.0, 5.0);

sd = new osg::ShapeDrawable(cylinder.get());

geode- >addDrawable(sd.get());

-------------------------------------------------------

How I take texture to only the top face not all faces?

 

Best Regards.

 

2008-09-10 

  _____  

xuyuanzhen1 

  _____  

发件人: Vijay Patil 

发送时间: 2008-09-10  12:44:43 

收件人: OpenSceneGraph Users 

抄送: 

主题: Re: [osg-users] Utility functions 

On Wed, Sep 10, 2008 at 8:16 AM, ami guru  <[EMAIL PROTECTED] > wrote:

> Hello forum,

> 

> 

> Are there any utility functions for drawing spheres, planes , boxes ,cubes

> etc. within OSG's framework?

> 

> 

> 

> Sajjad

> 

> _______________________________________________

> osg-users mailing list

> [email protected]

> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

> 

> 

 

To draw regular shapes in OSG, refer to classes derived to

'osg::Shape'. Following is a segment from a program while

experimenting with those classes.

 

Also to find out if a particular shape is implemented in OSG, I

usually refer to HTML documentation (Generated using Doxygen). Just

refer to all the classes.

 

----------------------------------

osg::ref_ptr <osg::MatrixTransform > draw_shape(std::string shape, float x)

{

/* Geode containing a shape. */

osg::ref_ptr <osg::Geode > geode = new osg::Geode;

osg::ref_ptr <osg::ShapeDrawable > sd;

 

if(shape == "box") {

 

osg::ref_ptr <osg::Box > box = new osg::Box(osg::Vec3f(), 5.0);

sd = new osg::ShapeDrawable(box.get());

geode- >addDrawable(sd.get());

 

} else if(shape == "cylinder") {

 

osg::ref_ptr <osg::Cylinder > cylinder = new

osg::Cylinder(osg::Vec3f(), 2.0, 5.0);

sd = new osg::ShapeDrawable(cylinder.get());

geode- >addDrawable(sd.get());

 

} else if(shape == "capsule") {

 

osg::ref_ptr <osg::Capsule > capsule = new osg::Capsule(osg::Vec3f(), 2.0,
5.0);

sd = new osg::ShapeDrawable(capsule.get());

geode- >addDrawable(sd.get());

 

} else if(shape == "cone") {

 

osg::ref_ptr <osg::Cone > cone = new osg::Cone(osg::Vec3f(), 2.0, 5.0);

sd = new osg::ShapeDrawable(cone.get());

geode- >addDrawable(sd.get());

 

} else if(shape == "sphere") {

 

osg::ref_ptr <osg::Sphere > sphere = new osg::Sphere(osg::Vec3f(), 2.0);

sd = new osg::ShapeDrawable(sphere.get());

geode- >addDrawable(sd.get());

}

 

/* Use matrix tranform to place the object at desired position

 * from origin. */

osg::ref_ptr <osg::MatrixTransform > mtleft = new osg::MatrixTransform;

mtleft- >setDataVariance(osg::Object::STATIC);

 

osg::Matrix m;

m.makeTranslate(x, 0.0, 0.0);

mtleft- >setMatrix(m);

 

/* Add geode to matrix transform object. */

mtleft- >addChild(geode.get());

 

return mtleft.get();

}

 

 

 

-- 

Vijay Patil

_______________________________________________

osg-users mailing list

[email protected]

http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

 

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to