[osg-users] Drawing a point

2009-05-28 Thread Mojtaba Fathi

Hi all
Accept my apology for such a simple question. I want to display two coincident 
points at (0,0,0). I use code like this:

int main()
{
    osgViewer::Viewer viewer;

    osg::ref_ptrosg::Group root (new osg::Group);
    osg::ref_ptrosg::Geode geode (new osg::Geode());
    osg::ref_ptrosg::Geometry geometry (new osg::Geometry());

    osg::ref_ptrosg::Vec3Array vertices (new osg::Vec3Array());

    vertices-push_back (osg::Vec3 ( 0.0, 0.0, 0.0));
    vertices-push_back (osg::Vec3 ( 0.0, 0.0, 0.0));

    geometry-setVertexArray (vertices.get());

    geometry-addPrimitiveSet(new 
osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices-size()));

    osg::Point *point=new osg::Point;
    point-setSize(4);
    root-getOrCreateStateSet()-setAttribute(point);

    geode-addDrawable (geometry.get());
    root-addChild(geode.get());
    viewer.setSceneData( root.get() );

    return (viewer.run());
}

But it displays nothing. I think it relates to BoundingBox and culling, so what 
should I do to display two coincident points at (0,0,0)? And how to do it for 
just one point?

Regards, Moji




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


Re: [osg-users] problem with Drawable and glCallList (sample program included)

2009-05-20 Thread Mojtaba Fathi

robertosfield wrote:
 Hi Moji,
 Could you try OSG-2.8.1 or OSG-2.9.x/svn/trunk as this has a fix in
 Drawable::compileGLObjects() for the compilation of vertex arrays,
 this fix affected ATI drivers that couldn't cope with putting VBO's
 inside a display list.  There is a chance that this might affect intel
 drivers as well.
 


Hi Robert
OK, I'll check the newer version and tell you the result.
Regards, Moji

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12585#12585





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


Re: [osg-users] problem with Drawable and glCallList (sample program included)

2009-05-20 Thread Mojtaba Fathi

Hi again
I tried OSG 2.9.4 and nothing changed, I got the same Access Violation Error.
Regards,
Moji the Great

--- On Wed, 5/20/09, Mojtaba Fathi modjta...@yahoo.com wrote:

From: Mojtaba Fathi modjta...@yahoo.com
Subject: Re: [osg-users] problem with Drawable and glCallList (sample program 
included)
To: osg-users@lists.openscenegraph.org
Date: Wednesday, May 20, 2009, 1:44 PM


robertosfield wrote:
 Hi Moji,
 Could you try OSG-2.8.1 or OSG-2.9.x/svn/trunk as this has a fix in
 Drawable::compileGLObjects() for the compilation of vertex arrays,
 this fix affected ATI drivers that couldn't cope with putting VBO's
 inside a display list.  There is a chance that this might affect intel
 drivers as well.
 


Hi Robert
OK, I'll check the newer version and tell you the result.
Regards, Moji

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12585#12585





___
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


Re: [osg-users] problem with Drawable and glCallList (sample program included)

2009-05-20 Thread Mojtaba Fathi

Hi Robert

 I think we are probably looking at a driver bug.  Could you try other
 machines/drivers to see if there is pattern to it.

I think so, I ran the program on a Virtual PC client running Windows 2000 and 
everything was fine.

 I'm not sure this signature will come across well across the globe.
 Do you intend us to think you are the Great, and in what respect-
 height, girth, wealth, intelligence, prowess in bed?  Here in the UK
 such an expression comes across as rather egotistical if one uses such
 an expression about oneself, and rather seen as blight on ones
 character.  So might I suggest a more modest signatute.

I'm not great in anything. It's just a simple expression meaning nothing 
special for me.
Someday I was looking for information about 'Cyrus the Great' in Wikipedia and 
found this article:
http://en.wikipedia.org/wiki/The_great
After that I used this expression as part of my signature. I'll omit it in my 
posts till I find a better non egotistical expression. Thanks for your notice 
and sorry for inconvenience.

Regards,
just Moji for now!




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


[osg-users] problem with Drawable and glCallList (sample program included)

2009-05-19 Thread Mojtaba Fathi

Hi all

I have a strange problem with Drawable::draw function which can't understand 
the reason. In order to show you the problem, I've attached a sample program 
which generates an Access Violation in Drawable::draw function when it calls 
glCallList function.

Before the main function, there is the definition of NUM_POINTS as follows:

#define NUM_POINTS 100

If I change this value to 10 and rerun the program, every thing seems to be 
fine, but with 100 I get the Access Violation error.

Regards
Moji the Great





  
#include osgViewer/Viewer
#include osgGA/TrackballManipulator
#include osg/ShapeDrawable
#include osgTerrain/Terrain
#include osgTerrain/GeometryTechnique
#define _USE_MATH_DEFINES
#include math.h

#define FIELD_SIZE 10
#define NUM_POINTS 100

int main()
{
	osg::ref_ptrosgViewer::Viewer viewer=new osgViewer::Viewer;

	// initiate OSG objects
	osg::ref_ptrosgTerrain::TerrainTile osgRaster=new osgTerrain::TerrainTile;
	osg::ref_ptrosgTerrain::Locator locator=new osgTerrain::Locator;
	osg::ref_ptrosgTerrain::HeightFieldLayer hf_layer=new osgTerrain::HeightFieldLayer;
	osg::ref_ptrosg::HeightField hfield=new osg::HeightField;
	osg::ref_ptrosgTerrain::GeometryTechnique geometryTechnique=new osgTerrain::GeometryTechnique;

	hfield-allocate(FIELD_SIZE,FIELD_SIZE);
	for(int row=0;row  FIELD_SIZE;row++)
		for(int col=0;col  FIELD_SIZE;col++)
			hfield-setHeight(col,row,0.01*col*row);

	locator-setTransformAsExtents(0,0,FIELD_SIZE,FIELD_SIZE);

	hf_layer-setHeightField(hfield);
	hf_layer-setLocator(locator);
	osgRaster-setElevationLayer(hf_layer);
	osgRaster-setTerrainTechnique(geometryTechnique);
	osgRaster-setRequiresNormals(false);

	// create 3d shape
	osg::ref_ptrosg::Vec3Array coords=new osg::Vec3Array;
	for(int i=0;i  NUM_POINTS;i++)
		coords-push_back(osg::Vec3d(i,i,i));

	osg::ref_ptrosg::Geometry osgPattern=new osg::Geometry;
	osgPattern-setVertexArray(coords);

	osg::DrawArrays de=*new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,NUM_POINTS);
	osgPattern-addPrimitiveSet(de);

	osg::ref_ptrosg::Geode geode=new osg::Geode;
	geode-addDrawable(osgPattern);

	osg::ref_ptrosg::Group osgGroup=new osg::Group;
	osgGroup-addChild(osgRaster);
	osgGroup-addChild(geode);

	viewer-setSceneData(osgGroup);

	viewer-run();

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


Re: [osg-users] problem with Drawable and glCallList (sample programincluded)

2009-05-19 Thread Mojtaba Fathi

Not true, because the third parameter of DrawArray constructor is the count of 
array members, not the last one.
In fact, I think the problem arises from osgTerrain, but I don't know how and 
why.

Moji the Great

--- On Wed, 5/20/09, Tomlinson, Gordon gtomlin...@overwatch.textron.com wrote:

From: Tomlinson, Gordon gtomlin...@overwatch.textron.com
Subject: Re: [osg-users] problem with Drawable and glCallList (sample 
programincluded)
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Date: Wednesday, May 20, 2009, 12:22 AM



 
I Believe your Draw Array number should be NUM_POINTS - 
1
as 
you have defined it
 
You 
providing 0-99 in you for loop but telling the array you have 
0-100
 
 


Gordon
Product 
Manager 3d
__
Gordon Tomlinson
Email  : gtomlinso...@ overwatch.textron.com
__
 



From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Mojtaba 
Fathi
Sent: Tuesday, May 19, 2009 3:40 PM
To: 
osg-users@lists.openscenegraph.org
Subject: [osg-users] problem with 
Drawable and glCallList (sample programincluded)




  
  

Hi all

I have a strange problem with 
  Drawable::draw function which can't understand the reason. In order to 
  show you the problem, I've attached a sample program which generates an 
  Access Violation in Drawable::draw function when it calls glCallList 
  function.

Before the main function, there is the definition of 
  NUM_POINTS as follows:

#define 
  NUM_POINTS 100

If I change this value to 10 and rerun the 
  program, every thing seems to be fine, but with 100 I get the Access 
  Violation error.

Regards
Moji the 
Great




-Inline Attachment Follows-

___
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


Re: [osg-users] problem with Drawable and glCallList (sample programincluded)

2009-05-19 Thread Mojtaba Fathi

Hi
I was using osg 2.6.1 and had this problem. Recently I've changed to osg 2.8.0 
and it happens again. I used both built versions and source codes. I'm using 
VS2005+SP1 and windows XP with a Toshiba laptop which has intel 945GM chipset. 
I've checked intel's site and it says my display drivers are up to date.
I think this a problem with my graphics card, and not a logical error.
This problem usually happens when I use osgTerrain in my application.
In fact, I've disabled all display lists in my application to prevent this 
error, but this is a temporary solution.

Moji the Great

--- On Wed, 5/20/09, Paul Martz pma...@skew-matrix.com wrote:

From: Paul Martz pma...@skew-matrix.com
Subject: Re: [osg-users] problem with Drawable and glCallList (sample 
programincluded)
To: 'OpenSceneGraph Users' osg-users@lists.openscenegraph.org
Date: Wednesday, May 20, 2009, 12:37 AM



 
You code is fine. It looks OK, so I built it and ran it 
and it runs fine. I'm using OSG 2.9.4. Are you on an older version of OSG, or 
is 
it possible that you linked with one version and ran with another? Do you have 
an old OpenGL driver?
 
Paul Martz
Skew Matrix Software 
LLC
http://www.skew-matrix.com
+1 303 859 9466
 



From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Mojtaba 
Fathi
Sent: Tuesday, May 19, 2009 1:40 PM
To: 
osg-users@lists.openscenegraph.org
Subject: [osg-users] problem with 
Drawable and glCallList (sample programincluded)




  
  

Hi all

I have a strange problem with 
  Drawable::draw function which can't understand the reason. In order to 
  show you the problem, I've attached a sample program which generates an 
  Access Violation in Drawable::draw function when it calls glCallList 
  function.

Before the main function, there is the definition of 
  NUM_POINTS as follows:

#define 
  NUM_POINTS 100

If I change this value to 10 and rerun the 
  program, every thing seems to be fine, but with 100 I get the Access 
  Violation error.

Regards
Moji the 
Great




-Inline Attachment Follows-

___
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


Re: [osg-users] What is everyone doing for GUIs?

2009-05-16 Thread Mojtaba Fathi

Hi
I'm using WTL.
Regards, Moji the Great

--- On Sat, 5/16/09, Mike Hall mike.hallo...@gmail.com wrote:

From: Mike Hall mike.hallo...@gmail.com
Subject: [osg-users] What is everyone doing for GUIs?
To: osg-users@lists.openscenegraph.org
Date: Saturday, May 16, 2009, 4:01 AM

Hey All,

What are you all doing for GUI development in OSG?

QT, WxWidgets, Roll you own etc?

We are designing a system, and we would like to know what the majority of 
people out there are using. We would like to have menus, mouse clicks, dialogs, 
buttons etc.

Thanks,

skibud2

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=12313#12313





___
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


Re: [osg-users] Question about osgViewer::View::EventHandlers

2009-05-15 Thread Mojtaba Fathi

Hi J-S
I did what you suggested and now it's working fine. Thnaks for your help and 
explanation.
Moji the Great

--- On Thu, 5/14/09, Jean-Sébastien Guay jean-sebastien.g...@cm-labs.com 
wrote:

From: Jean-Sébastien Guay jean-sebastien.g...@cm-labs.com
Subject: Re: [osg-users] Question about osgViewer::View::EventHandlers
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Date: Thursday, May 14, 2009, 9:21 PM

Hi Moji,

 So is there any specific reason for using ref_ptr instead of observer_ptr in 
 definition of osgViewer::View::EventHandlers?

The viewer owns the event handlers, thus ref_ptr is the right choice. The 
normal usage of an event handler is:

    viewer-addEventHandler(new MyEventHandler);

and thus the use of ref_ptr is appropriate in that case.

Perhaps one solution would be to move the event handler functionality of your 
wrapper class into another internal class, add that event handler to the viewer 
and then use ref_ptr on your viewer but observer_ptr on your event handler. 
There would then be no ref_ptr cycles.

Hope this helps,

J-S
-- __
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
___
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


Re: [osg-users] Question about osgViewer::View::EventHandlers

2009-05-15 Thread Mojtaba Fathi

Hi Robert
Thanks for your comment, it would be very helpful.
Regards
Moji the Great

--- On Fri, 5/15/09, Robert Osfield robert.osfi...@gmail.com wrote:

From: Robert Osfield robert.osfi...@gmail.com
Subject: Re: [osg-users] Question about osgViewer::View::EventHandlers
To: OpenSceneGraph Users osg-users@lists.openscenegraph.org
Date: Friday, May 15, 2009, 12:47 PM

HI Moji,

On Thu, May 14, 2009 at 5:30 PM, Mojtaba Fathi modjta...@yahoo.com wrote:
 Also, there is no such removeEventHandler function in View class, which I
 think could help me to solve the problem.

In the svn/trunk version and 2.9.x series there is an
View::removeEventHandler() implementation.

Robert.
___
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] Question about osgViewer::View::EventHandlers

2009-05-14 Thread Mojtaba Fathi

Hi all

in the body of class osgViewer::View, EventHandlers is defined as follows:

    typedef std::list osg::ref_ptrosgGA::GUIEventHandler  EventHandlers;
    
In fact, I use a wrapper class for OSG in my application which acts as a
container for all major OSG objects, like Viewer, Manipulator, etc.
This class also acts as a event handler, so adds itself to the list of event 
handlers, and here comes the problem.
Since my wrapper class uses a ref_ptr to hold the address of Viewer and viewer 
holds my wrapper's address in the list of 
event handlers using a ref_ptr too, we have a chain which resides in memory 
forever.
But, if we define EventHandlers as a list of observer pointers, there will be 
no problem and anything becomes deleted correctly.
Also, there is no such removeEventHandler function in View class, which I think 
could help me to solve the problem.

Now, I use getEventHandlers function and call the clear function to remove all 
event handlers when I receive the done signal.
But as mentioned before, I think it would be better to define EventHandlers as 
a list observer pointers, unless I have missed something special.

So is there any specific reason for using ref_ptr instead of observer_ptr in 
definition of osgViewer::View::EventHandlers?

Regards, Moji the Great




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


Re: [osg-users] CAD style rotation

2009-04-22 Thread Mojtaba Fathi

Hi all

Thanks Martin for his excellent work on SphericalManipulator. I will be so glad 
if this can be added to the submission list.

But there are a few notes and questions:

1 - you have commented the body of zoomOn function, but it's declaration exits 
in the class.
2 - I think zoomOn function offers a good and useful functionality. Is it 
necessary to remove it from the manipulator?
3 - I haven't implemented the setByMatrix function, because I don't need it. 
But this should be done.
4 - There is an small issue in getInverseMatrix and getMatrix functions. Both 
compute the matrix even if it hasn't changed from the previous step. Maybe it 
is better to compute it when needed and just return the computed one otherwise.
5 - The member variable named _dragged is not necessary and can be removed. I 
use it in my specialized version only.

Regards, Moji the Great

--- On Thu, 4/23/09, Martin Beckett m...@mgbeckett.com wrote:

From: Martin Beckett m...@mgbeckett.com
Subject: Re: [osg-users] CAD style rotation
To: osg-users@lists.openscenegraph.org
Date: Thursday, April 23, 2009, 12:18 AM

It's Moji's code so he should probably be the one to submit it.

There seems to be a few functions that aren't necessary (perhaps for some other 
code) which could be cleaned up.

It would be nice if there was a method to set a rotation origin in the model - 
or is there some general way to do this?

Martin

ps. There seems to be a lot of cut+paste code between the different 
manipulators - perhaps somebody who understands them better could look at how 
much could be moved to MatrixManipulator.

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=10679#10679





___
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] memory management incompatibility?

2009-03-12 Thread Mojtaba Fathi
Hi all

I'm using OSG 2.8 dll's for VS80 in my application. After some malloc/realloc 
and free operations, I get messages like this

Free Heap block ... modified at ... after it was freed.

I
think the problem arises from memory management incompatibility between
my app and OSG dll's. Is there any specific configuration necessary to
avoid such problems?

Regards
Moji the Great


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


[osg-users] memory management incompatibility? (SOLVED)

2009-03-12 Thread Mojtaba Fathi

Hi again
As expected, that was my fault. I found the problem and now everything is fine.
Regards, Moji the Great

--- On Thu, 3/12/09, Mojtaba Fathi modjta...@yahoo.com wrote:

From: Mojtaba Fathi modjta...@yahoo.com
Subject: [osg-users] memory management incompatibility?
To: osg-users@lists.openscenegraph.org
Date: Thursday, March 12, 2009, 11:15 AM

Hi all

I'm using OSG 2.8 dll's for VS80 in my application. After some malloc/realloc 
and free operations, I get messages like this

Free Heap block ... modified at ... after it was freed.

I
think the problem arises from memory management incompatibility between
my app and OSG dll's. Is there any specific configuration necessary to
avoid such problems?

Regards
Moji the Great


  
-Inline Attachment Follows-

___
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


Re: [osg-users] forcing a square aspect ratio

2009-02-11 Thread Mojtaba Fathi
HiI had the same problem, and I found a solution (but can't remember where I found it). It's like this: // Realize the Viewer _viewer-realize(); // correct aspect ratio double fovy,aspectRatio,z1,z2; camera-getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2); aspectRatio=double(traits-width)/double(traits-height); camera-setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);RegardsMoji the Great--- On Wed, 2/11/09, Cory Riddell c...@codeware.com wrote:From: Cory Riddell c...@codeware.comSubject: Re: [osg-users]
 forcing a square aspect ratioTo: "OpenSceneGraph Users" osg-users@lists.openscenegraph.orgDate: Wednesday, February 11, 2009, 12:18 AM


  
FWIW, I've attached a screen shot of what should be a square. The
Drawable code was taken from the quickstart guide and the vertices are:
 v-push_back(osg::Vec3(-1.f, 0.f, -1.f));
 v-push_back(osg::Vec3(1.f, 0.f, -1.f));
 v-push_back(osg::Vec3(1.f, 0.f, 1.f));
 v-push_back(osg::Vec3(-1.f, 0.f, 1.f));
Any ideas?




Cory Riddell wrote:

  I've been playing with osgviewerMFC and I've noticed that when I open anosg file (like cow.osg), the rendering is "stretched" to fit the aspectratio of the containing window. For example, if I resize the app to bewide then open the cow, I get a very long cow. If I make the windowshort and tall then open the cow, I get a very compressed cow. Resizingthe window does resize the cow, but the aspect ratio doesn't change.osgviewerQT doesn't have this problem but I don't see what's different.What controls the aspect ratio of the rendering?BTW, my cow.osg is from 2.6. Has the osg file format changed?Cory___osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org  

 
___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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


Re: [osg-users] forcing a square aspect ratio

2009-02-11 Thread Mojtaba Fathi
Hi Corydo the following for osgviewerMFC sample app:1 - open the file "MFC_OSG.cpp"2 - find the function "cOSG::InitCameraConfig"3 - go to end of the function. It reads like this:... // Realize the Viewer mViewer-realize();}4 - add these lines:... // Realize the Viewer mViewer-realize(); // NEW CODE STARTS HERE // correct aspect ratio double fovy,aspectRatio,z1,z2; mViewer-getCamera()-getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2); aspectRatio=double(traits-width)/double(traits-height);
 mViewer-getCamera()-setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2); // NEW CODE ENDS HERE
}5 - Build it and enjoy!RegardsMoji the Great--- On Thu, 2/12/09, Cory Riddell c...@codeware.com wrote:From: Cory Riddell c...@codeware.comSubject: Re: [osg-users] forcing a square aspect ratioTo: "OpenSceneGraph Users" osg-users@lists.openscenegraph.orgDate: Thursday, February 12, 2009, 12:51 AM


  
Nevermind, I found the problem. I was setting the projection matrix on
the camera I added as a slave. Instead, I did this:

 // Realize the Viewer
 _viewer-realize();

 // correct aspect ratio
 double fovy,aspectRatio,z1,z2;

_viewer-getCamera()-getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
 aspectRatio=double(traits-width)/double(traits-height);

_viewer-getCamera()-setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
 
I'd like to update the osgviewerMFC sample app. How would I go about
doing this?

Cory



Cory Riddell wrote:

  
Moji the Great-
  
I added the code you suggest to my code (and to osgviewerMFC) and it
doesn't do anything.
  
Is there something you have to do after setting the new aspect ratio to
have it take effect? I was playing around and it didn't seem to matter
what number I plugged in for the aspect ratio, my view always looked
the same.
  
Cory
  
  
Mojtaba Fathi wrote:
  

  

  
Hi
I had the same problem, and I found a solution (but can't remember
where I found it). It's like this:
  
 // Realize the Viewer
 _viewer-realize();
  
 // correct aspect ratio
 double fovy,aspectRatio,z1,z2;
 camera-getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
 aspectRatio=double(traits-width)/double(traits-height);
 camera-setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
  
Regards
Moji the Great
  
--- On Wed, 2/11/09, Cory Riddell c...@codeware.com
wrote:
  From:
Cory Riddell c...@codeware.com
Subject: Re: [osg-users] forcing a square aspect ratio
To: "OpenSceneGraph Users" osg-users@lists.openscenegraph.org
Date: Wednesday, February 11, 2009, 12:18 AM

 FWIW, I've attached a screen shot
of
what should be a square. The
Drawable code was taken from the quickstart guide and the vertices are:
 v-push_back(osg::Vec3(-1.f, 0.f, -1.f));
 v-push_back(osg::Vec3(1.f, 0.f, -1.f));
 v-push_back(osg::Vec3(1.f, 0.f, 1.f));
 v-push_back(osg::Vec3(-1.f, 0.f, 1.f));
Any ideas?




Cory Riddell wrote:

  I've been playing with osgviewerMFC and I've noticed that when I open anosg file (like cow.osg), the rendering is "stretched" to fit the aspectratio of the containing window. For example, if I resize the app to bewide then open the cow, I get a very long cow. If I make the windowshort and tall then open the cow, I get a very compressed cow. Resizingthe window does resize the cow, but the aspect ratio doesn't change.osgviewerQT doesn't have this problem but I don't see what's different.What controls the aspect ratio of the rendering?BTW, my cow.osg is from 2.6. Has the osg file format changed?Cory___osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org  


___osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org  
  
  

  


___osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org  
  
  ___osg-users mailing listosg-users@lists.openscenegraph.orghttp://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org  

 
___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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] about Drawable::ComputeBoundingBoxCallback struct

2009-02-04 Thread Mojtaba Fathi

Hi all

osg::Drawable class declares 5 structs which can be used to implement callback 
functions for different purposes. Except 'ComputeBoundingBoxCallback' struct, 
other 4 structs inherit virtually from osg::Object class.
Is there any particular reason for 'ComputeBoundingBoxCallback' struct to not 
inherit virtually from osg::Object or this is simply a bug?

Regards
Moji the Great


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