[osg-users] Camera and light problem

2008-03-08 Thread Jon
Thanks Vincent for your answer.

 

I tried to follow your suggestion, but the problem persists.

 

If you look at the code, I have :

|_root

---|_modelGraph

---|transform

-|lightsource

-|geode

 

Any suggestions ? What are my mistakes?

My goal is to have a model moving with the camera and a light represented by
a sphere that does not move (fixed coord).

Just one precision: when I place the light in the scene, the light
coordinates depends of the model: ((0,0,0) puts the light inside the model)

 

Could this explain the problem?

How can I prevent this?

 

Thanks again.

 

{

//_modelGraph group represents the current scene

//_root group will contains _modelGraph plus the light

 

//create the light

osg::ref_ptrosg::Light light = new osg::Light;

//make the light a point light by setting w to 1.0

light-setPosition(osg::Vec4(-10.0f, -10.0f, 0.0f, 10.0f));

 

//create a lightsource for the light

osg::ref_ptrosg::LightSource lightSource = new osg::LightSource;

 

//create a transformation node that will move the node in the scene

osg::ref_ptrosg::MatrixTransform transform = new osg::MatrixTransform;

transform-addChild(lightSource.get());

  

//Position the light

osg::Vec3 pos(-5.0f, 10.0f, 0.0f);

transform-setMatrix(osg::Matrix::translate(pos));

 

//create a small sphere to represent the lights position

osg::ref_ptrosg::Geode geode = new osg::Geode;

 

osg::ref_ptrosg::TessellationHints hints = new osg::TessellationHints;

hints-setDetailRatio(0.3);

 

osg::ref_ptrosg::ShapeDrawable shape = new osg::ShapeDrawable(new
osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 0.6f), hints.get());

shape-setColor(lightColor);

 

geode-addDrawable(shape.get());

transform-addChild(geode.get());

 

_root-addChild(transform.get());

 

//add the model to the light's root group

_root-addChild(_modelGraph.get());

}

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] thousand spheres

2008-03-08 Thread nicolas peña
Hi,
I have used OSG in the past to create the visuals aspects
of a huge scale network simulator (up to 2 nodes).
So if you detail more your problem may be I can help.
I created my nodes instances with a  simple 'for' loop,
placing each one either using a random generator or
reading from a configuration file.
 Cheers,
Nicolas.


2008/3/8, wanyama harold [EMAIL PROTECTED]:

 Hi guys,Iam working on designing a simple network
 consisting of nodes and links. my only problem is I
 want nodes in thousands of numbers and i dont want to
 keep on creating a new instance of a  network
 node(read sphere). how can i write a function that can
 use randomness to achieve these many nodes? I hope am
 clear.
 thx


   ___
 Rise to the challenge for Sport Relief with Yahoo! For Good

 http://uk.promotions.yahoo.com/forgood/
 ___
 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


[osg-users] Saving and Loading Scenes

2008-03-08 Thread Renan Mendes
Hi,

I need some help on saving and loading scenegraphs. Reading the OSG
documentation, specifically the osgDB namespace, I saw that I have no idea
where to begin! Can someone give me a reference?

Thanks,

Renan M Z Mendes
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Saving and Loading Scenes

2008-03-08 Thread Benjamin Eikel
On Saturday 08 March 2008 at 13:50:04, Renan Mendes wrote:
 Hi,

 I need some help on saving and loading scenegraphs. Reading the OSG
 documentation, specifically the osgDB namespace, I saw that I have no idea
 where to begin! Can someone give me a reference?

 Thanks,

 Renan M Z Mendes

Hello Renan,

I think you start with osgDB::writeNodeFile [1]. With that function you can 
write a whole scene graph into a .osg file for example.

Regards,
Benjamin


[1] 
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a02205.html#a63
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Saving and Loading Scenes

2008-03-08 Thread Renan Mendes
Benjamin,

  I've used this function (it compiled alright), but when running my
aplication, there was an error message, saying that I didn't have the plugin
for reading and writing files...  I went to the OSG website and searched for
reading and writing plugins, but there were so many, I didn't know which one
to choose. Do you have a suggestion?

   Renan M Z Mendes
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Saving and Loading Scenes

2008-03-08 Thread Benjamin Eikel
On Saturday 08 March 2008 at 14:26:13, Renan Mendes wrote:
 Benjamin,

   I've used this function (it compiled alright), but when running my
 aplication, there was an error message, saying that I didn't have the
 plugin for reading and writing files...  I went to the OSG website and
 searched for reading and writing plugins, but there were so many, I didn't
 know which one to choose. Do you have a suggestion?

Renan M Z Mendes

Hello Renan,

the plugin is selected by the filename you give to this function. For writing 
files, I think the OpenSceneGraph format (file extenstion .osg) is the only 
one which supports most of the nodes. So you should call the function with 
something like MySceneGraph.osg as filename.
If it still complains about missing plugins maybe the plugins where not 
installed correctly. If you are using GNU/Linux and have installed 
OpenSceneGraph to /usr then there should be a directory 
called /usr/lib/osgPlugins-2.2.0 containing the plugins (if you installed 
version 2.2.0 of course).

Regards,
Benjamin
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] thousand spheres

2008-03-08 Thread wanyama harold
Hi Nicholas,
thanxs. i would like more details becoz thats exactly
what i want. i thought of the for loop but dint know
how to simply implement. i would be grateful if u
could show me how.


Hi,
I have used OSG in the past to create the
visuals aspects
of a huge scale network simulator (up to 2
nodes).
So if you detail more your problem may be I
can help.
I created my nodes instances with a  simple
'for' loop,
placing each one either using a random
generator or
reading from a configuration file.
 Cheers,
Nicolas.


  __
Sent from Yahoo! Mail.
The World's Favourite Email http://uk.docs.yahoo.com/nowyoucan.html
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org