Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Sebastian Messerschmidt


Hi Robert,


On 16 November 2016 at 11:50, Rambabu Repaka  wrote:

Hi,I got the answer for my question.In the compass node creation sample code 
two errors are there.

First one: replace Compass(); with
compass(void)
{
}
second one: Replace virtual ~Compass() with
Compass::~Compass(void)
{
}


Neither of the above are an error, it's perfectly correct and legal
C++ to not use void.  The OSG uses constructors and destructor’s
without void and doesn't have a problem with users linking to it.

There must be something odd about your particular compile set up or
how you've tweaked the code.  As you've not provided any information
about compilers or linking there is no way others can actually tell
you want the actual problem is.


He was simply missing the implementation of the constructor and 
destructor, that what caused his linker-errors.

@Rambabu:

This is basic C++-knowledge and I second Robert here: Please try to 
learn the basics first and learn how to ask questions. This will 
increase the likelihood of someone actually take care about it.


Cheers
Sebastian




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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Robert Osfield
On 16 November 2016 at 11:50, Rambabu Repaka  wrote:
> Hi,I got the answer for my question.In the compass node creation sample code 
> two errors are there.
>
> First one: replace Compass(); with
> compass(void)
> {
> }
> second one: Replace virtual ~Compass() with
> Compass::~Compass(void)
> {
> }

Neither of the above are an error, it's perfectly correct and legal
C++ to not use void.  The OSG uses constructors and destructor’s
without void and doesn't have a problem with users linking to it.

There must be something odd about your particular compile set up or
how you've tweaked the code.  As you've not provided any information
about compilers or linking there is no way others can actually tell
you want the actual problem is.

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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Rambabu Repaka
Hi,I got the answer for my question.In the compass node creation sample code 
two errors are there.

First one: replace Compass(); with 
compass(void)
{
} 
second one: Replace virtual ~Compass() with 
Compass::~Compass(void)
{
}

... 

Thank you!

Cheers,
Rambabu

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





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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Robert Osfield
On 16 November 2016 at 11:09, Rambabu Repaka  wrote:
> Hi,In Osg3_Cookbook.pdf  implementing a compass node example page number 
> 74.Problem in compass class linking.

Another tiny bit of info.  You should have mentioned this info right
in your first post - give other people context to what you are doing.
Personally I'm not familiar with the Osg3_Cookbook.

Still you are failing to provide crucial information about the problem
you have. You have once mentioned the specific linker error you see.
This is crucial.

You also completely failed to mention what platform and compiler you are using?

You also failed to mentioned anything about how you are compiling the
libs and linking.

So many failures to communicate crucial information.  This is pretty
appalling.  You have to get far better at communicating the context of
your problems if you want help.

Please start making a proper effort in trying to convey relevant information.

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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Nickolai Medvedev
Hi, all.

Source file and header in archive.
To use a class a compass:

osg::ref_ptr node = osgDB::readNodeFile("arrow.osgb"); // any node 
looking to the north
if(node.valid())
{
node->getOrCreateStateSet()->setMode( GL_LIGHTING, 
osg::StateAttribute::OFF );
}
osg::ref_ptr pos = new 
osg::PositionAttitudeTransform;
pos->addChild(node.get());
pos->setScale(osg::Vec3(0.6,0.6,0.6));


osg::ref_ptr compass = new Compass;
compass->setViewport( 0.0, 0.0, 100.0, 100.0 );
compass->setProjectionMatrix( osg::Matrixd::identity() );
compass->setNeedle( pos.get() );
compass->setMainCamera( VIEWER->getCamera() );

compass->setRenderOrder( osg::Camera::POST_RENDER );
compass->setClearMask( GL_DEPTH_BUFFER_BIT );
compass->setAllowEventFocus( false );
compass->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
compass->getOrCreateStateSet()->setMode( GL_LIGHTING, 
osg::StateAttribute::OFF );
compass->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON 
);

root->addChild( compass.get() );


Good luck!

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





Compass.7z
Description: Binary data
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Rambabu Repaka
Hi,In Osg3_Cookbook.pdf  implementing a compass node example page number 
74.Problem in compass class linking.

... 

Thank you!

Cheers,
Rambabu

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





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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Robert Osfield
On 16 November 2016 at 10:43, Rambabu Repaka  wrote:
> compass class created but it is showing linker errors due to missing of 
> library.How can i get that library file in osg.

Still not enough information.  The code itself isn't likely to be the
issue so there little point in posting it.

PLEASE make the effort to think about what information other people
might need to be able to help.  If you have colleagues then chat with
them about what this might be.

I feel it's really important that you fix this problem with your
posts, you keep doing the same thing - just blurting out a call for
help but not providing any clues. Remember that people in the
community don't sit over your shoulder, we know *nothing* about what
you are doing on your computer.

To understand what the problem is for us think about this question.

 "I have piece of string, how long is it?"

No if you can't answer that without asking for more information then
you'll understand what we are faced with each time you post your calls
for help.

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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Rambabu Repaka
Hi,

class Compass : public osg::Camera
{
public:
Compass();
Compass( const Compass& copy, osg::CopyOp
copyop=osg::CopyOp::SHALLOW_COPY );
META_Node( osg, Compass );
void setPlate( osg::MatrixTransform* plate ) {_plateTransform = plate; }
void setNeedle( osg::MatrixTransform* needle ) {_needleTransform = 
needle; }
void setMainCamera( osg::Camera* camera ) {_mainCamera = camera; }
virtual void traverse( osg::NodeVisitor& nv );
protected:
virtual ~Compass();
osg::ref_ptr _plateTransform;
osg::ref_ptr _needleTransform;
osg::observer_ptr _mainCamera;
};

Compass::Compass( const Compass& copy, osg::CopyOp copyop ):osg::Camera(copy, 
copyop),
_plateTransform(copy._plateTransform),
_needleTransform(copy._needleTransform),
_mainCamera(copy._mainCamera)
{
}

void Compass::traverse( osg::NodeVisitor& nv )
{
if ( _mainCamera.valid() 
&()==osg::NodeVisitor::CULL_VISITOR )
{
osg::Matrix matrix = _mainCamera->getViewMatrix();
matrix.setTrans( osg::Vec3() );
osg::Vec3 northVec = osg::Z_AXIS * matrix;
northVec.z() = 0.0f;
northVec.normalize();
osg::Vec3 axis = osg::Y_AXIS ^ northVec;
float angle = atan2(axis.length(), 
osg::Y_AXIS*northVec);axis.normalize();
if ( _plateTransform.valid() )
_plateTransform->setMatrix( osg::Matrix::rotate(angle, axis) );
}   
_plateTransform->accept( nv );
_needleTransform->accept( nv );
osg::Camera::traverse( nv );
}

compass class created but it is showing linker errors due to missing of 
library.How can i get that library file in osg.

... 

Thank you!

Cheers,
Rambabu

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





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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Robert Osfield
HI Rambabu,

On 16 November 2016 at 09:57, Rambabu Repaka  wrote:
> Hi,Iam working with compass creation Linker errors are coming asking the 
> compass library file.How can i solve this can anyone tell.

You really need to put more effort in asking questions in a way that
others might have a chance to understand what your specific problem.
The above *completely* fails in this respect.

The only way to have a chance at helping your with the issues are at
hand are to start asking your questions, we shouldn't have to do this,
you should provide the information we need, doing so will take far
less time for us and yourself.

Rather than one by one ask these questions I suggest you read your
post, work out what other people might or might not know about your
specific set up and then tell us this information so we can build a
clearer picture of what you actually mean.  If you have colleagues get
them to read your post before you post it so they can give you
suggests about what is missing.

Also considering that perhaps this issue might not be an OSG issue at
all, perhaps you should start looking elsewhere for answers to none
OSG issues.

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


Re: [osg-users] ECEF Oriented Compass Implementation

2016-11-16 Thread Rambabu Repaka
Hi,Iam working with compass creation Linker errors are coming asking the 
compass library file.How can i solve this can anyone tell.  

... 

Thank you!

Cheers,
Rambabu

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





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


Re: [osg-users] ECEF Oriented Compass Implementation

2012-07-02 Thread Tueller, Shayne R Civ USAF AFMC 519 SMXS/MXDEC
Since you're navigating on a sphere, you always need to calculate the
bearing based off the local up vector of the sphere (ground
stabilized) and not the up vector of the ownship. The reason why your
code works from the birds eye view is because the up vectors between
the two are the same in this case. When you introduce pitch and roll,
the up vector of the ownship diverges from the sphere up vector
which probably explains why your code below no longer works.

Once you calculate the bearing correctly, your compass heading can then
be calculated by using the bearing angle to rotate around the z-axis
(0,0,1).

-Shayne 

-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of onur
akkaya
Sent: Thursday, June 28, 2012 1:20 AM
To: osg-users@lists.openscenegraph.org
Subject: [osg-users] ECEF Oriented Compass Implementation

Hi,

I have an ECEF terrain and I want to implement a compass node to show
the true north to the user.

I tried the code below but at some angles it does not work correctly.
When the camera is vertical (birds eye view) to the terrain, it works
perfect but if you rotate the camera (elevation or roll) it does not
show the correct value.

thanks,

class Compass : public osg::Camera
{
public:
Compass(void)
{
}

Compass( const Compass copy, osg::CopyOp copyop =
osg::CopyOp::SHALLOW_COPY ):
osg::Camera(copy, copyop),
_plateTransform(copy._plateTransform),
_needleTransform(copy._needleTransform),
_mainCamera(copy._mainCamera),
m_bIsFirst(false)
{
}

Compass::~Compass(void)
{
}

META_Node( osg, Compass );
void setPlate( osg::MatrixTransform* plate )
{
_plateTransform = plate; 
}

void setNeedle( osg::MatrixTransform* needle ) 
{
_needleTransform = needle; 
}

void setMainCamera( osg::Camera* camera ) 
{
_mainCamera = camera;
}

virtual void traverse( osg::NodeVisitor nv )
{
if ( _mainCamera.valid() 
nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR )
{
osg::Matrix matrix = _mainCamera-getViewMatrix();
matrix.setTrans( osg::Vec3() );
osg::Vec3 northVec = osg::Z_AXIS * matrix;  
northVec.z()= 0.0;

northVec.normalize();
osg::Vec3 axis = osg::Y_AXIS ^ northVec;
float angle = atan2(axis.length(), osg::Y_AXIS*northVec);
axis.normalize();

if ( _plateTransform.valid() )
{
_plateTransform-setMatrix( osg::Matrix::rotate(angle,
axis) );
}

_plateTransform-accept( nv );
_needleTransform-accept( nv );
osg::Camera::traverse( nv );
}
}

osg::MatrixTransform* createCompassPlate( const std::string image,
float radius, float height)
{
osg::Vec3 center(-radius, -radius, height);
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(createTexturedQuadGeometry(center,
osg::Vec3(radius*2.0f,0.0f,0.0f),
osg::Vec3(0.0f,radius*2.0f,0.0f)) );
osg::ref_ptrosg::Texture2D texture = new osg::Texture2D;  
texture-setImage(osgDB::readImageFile(image));

osg::ref_ptrosg::MatrixTransform part =new
osg::MatrixTransform();
part-getOrCreateStateSet()-setTextureAttributeAndModes(0,
texture.get() );
 
part-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT
_BIN ); 

part-addChild(geode.get());

return part.release();
}
osg::MatrixTransform* createCompassNeedle( const std::string image,
float radius, float height)
{
osg::Vec3 center(-radius/4, -radius, height);
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(createTexturedQuadGeometry(center,
osg::Vec3(radius/2,0.0f,0.0f),
osg::Vec3(0.0f,radius*2,0.0f)) );
osg::ref_ptrosg::Texture2D texture = new osg::Texture2D;  
texture-setImage(osgDB::readImageFile(image));

osg::ref_ptrosg::MatrixTransform part =new
osg::MatrixTransform();
part-getOrCreateStateSet()-setTextureAttributeAndModes(0,
texture.get() );
 
part-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT
_BIN ); 

part-addChild(geode.get());

return part.release();
}

protected:
osg::ref_ptrosg::MatrixTransform _plateTransform;
osg::ref_ptrosg::MatrixTransform _needleTransform;
osg::observer_ptrosg::Camera _mainCamera;
bool m_bIsFirst;
};

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





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

[osg-users] ECEF Oriented Compass Implementation

2012-06-29 Thread onur akkaya
Hi,

I have an ECEF terrain and I want to implement a compass node to show the true 
north to the user.

I tried the code below but at some angles it does not work correctly. When the 
camera is vertical (birds eye view) to the terrain, it works perfect but if you 
rotate the camera (elevation or roll) it does not show the correct value.

thanks,

class Compass : public osg::Camera
{
public:
Compass(void)
{
}

Compass( const Compass copy, osg::CopyOp copyop = 
osg::CopyOp::SHALLOW_COPY ):
osg::Camera(copy, copyop),
_plateTransform(copy._plateTransform),
_needleTransform(copy._needleTransform),
_mainCamera(copy._mainCamera),
m_bIsFirst(false)
{
}

Compass::~Compass(void)
{
}

META_Node( osg, Compass );
void setPlate( osg::MatrixTransform* plate )
{
_plateTransform = plate; 
}

void setNeedle( osg::MatrixTransform* needle ) 
{
_needleTransform = needle; 
}

void setMainCamera( osg::Camera* camera ) 
{
_mainCamera = camera;
}

virtual void traverse( osg::NodeVisitor nv )
{
if ( _mainCamera.valid()  
nv.getVisitorType()==osg::NodeVisitor::CULL_VISITOR )
{
osg::Matrix matrix = _mainCamera-getViewMatrix();
matrix.setTrans( osg::Vec3() );
osg::Vec3 northVec = osg::Z_AXIS * matrix;  
northVec.z()= 0.0;

northVec.normalize();
osg::Vec3 axis = osg::Y_AXIS ^ northVec;
float angle = atan2(axis.length(), osg::Y_AXIS*northVec);
axis.normalize();

if ( _plateTransform.valid() )
{
_plateTransform-setMatrix( osg::Matrix::rotate(angle, axis) );
}

_plateTransform-accept( nv );
_needleTransform-accept( nv );
osg::Camera::traverse( nv );
}
}

osg::MatrixTransform* createCompassPlate( const std::string image, float 
radius, float height)
{
osg::Vec3 center(-radius, -radius, height);
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(createTexturedQuadGeometry(center, 
osg::Vec3(radius*2.0f,0.0f,0.0f),
osg::Vec3(0.0f,radius*2.0f,0.0f)) );
osg::ref_ptrosg::Texture2D texture = new osg::Texture2D;  
texture-setImage(osgDB::readImageFile(image));

osg::ref_ptrosg::MatrixTransform part =new osg::MatrixTransform();
part-getOrCreateStateSet()-setTextureAttributeAndModes(0, 
texture.get() );

part-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT_BIN ); 

part-addChild(geode.get());

return part.release();
}
osg::MatrixTransform* createCompassNeedle( const std::string image, float 
radius, float height)
{
osg::Vec3 center(-radius/4, -radius, height);
osg::ref_ptrosg::Geode geode = new osg::Geode;
geode-addDrawable(createTexturedQuadGeometry(center, 
osg::Vec3(radius/2,0.0f,0.0f),
osg::Vec3(0.0f,radius*2,0.0f)) );
osg::ref_ptrosg::Texture2D texture = new osg::Texture2D;  
texture-setImage(osgDB::readImageFile(image));

osg::ref_ptrosg::MatrixTransform part =new osg::MatrixTransform();
part-getOrCreateStateSet()-setTextureAttributeAndModes(0, 
texture.get() );

part-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT_BIN ); 

part-addChild(geode.get());

return part.release();
}

protected:
osg::ref_ptrosg::MatrixTransform _plateTransform;
osg::ref_ptrosg::MatrixTransform _needleTransform;
osg::observer_ptrosg::Camera _mainCamera;
bool m_bIsFirst;
};

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





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