OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

updateCalculatedNearFar problem


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
forest37
Guest





PostPosted: Tue Oct 28, 2008 5:37 am    Post subject:
updateCalculatedNearFar problem
Reply with quote

hi all,
It seems that there is a problem with CullVisitor::updateCalculatedNearFar,I have the code like this:

osgViewer::Viewer viewer;

class MCallBack : public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::PositionAttitudeTransform *pat = dynamic_cast<osg::PositionAttitudeTransform *>(node);
if( pat != NULL )
{
osg::Camera *camera=viewer.getCamera();
osg::Matrixd pMatrix = camera->getViewMatrix();
pat ->setAttitude(pMatrix.getRotate());
}
}
};

osg::Node* fun()
{
osg::Geode* geode=new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0,0,0),0.1)));

osg::MatrixTransform *mt=new osg::MatrixTransform ;
Matrix matrix;
matrix.setTrans(osg::Vec3(1,0,0));
mt->setMatrix(matrix);
mt->addChild(geode);

osg::PositionAttitudeTransform * tran = new osg::PositionAttitudeTransform;
tran->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
tran->setPosition(osg::Vec3(5,5,0));
tran->addChild(mt);
tran->setUpdateCallback(new MCallBack());

osg::Projection* ProjectionMatrix = new osg::Projection;
ProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,10,0,10));
ProjectionMatrix->addChild(tran);

return ProjectionMatrix;
}

int _tmain(int argc, _TCHAR* argv[])
{
osg::Node* mRoot =fun();
viewer.setSceneData(mRoot);
return viewer.run();
}

when i rotate the scene,the scene is culled not exactly.
Is there a bug with osg or something wrong with my code?

thanks for any advice.

best regards

forest


[¹ãžÊ] œð?ï?î¹??¢?¥??-·¿²»?€·¿

------------------
Post generated by Mail2Forum
Back to top
Robert Osfield
Guest





PostPosted: Tue Oct 28, 2008 9:24 am    Post subject:
updateCalculatedNearFar problem
Reply with quote

Hi Forest,

Do you expect people to really follow this? Just throw the code out
there and expect people to know what effect your are trying to do?
Please remember that everyone will be busy with their own work and
just scan emails. You need to convey what you are trying to do in a
digestable form otherwise people will just ignore it.

The best I can do is say that use of Projection node has long been
deprecated, it just kept around for backwards compatibility. Use an
in scene graph osg::Camera when you want to over the projection and
view matrix.

Robert.

2008/10/28 forest37 <>:
Quote:

hi all,
It seems that there is a problem with
CullVisitor::updateCalculatedNearFar,I have the code like this:

osgViewer::Viewer viewer;

class MCallBack : public osg::NodeCallback
{
public:
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
osg::PositionAttitudeTransform *pat =
dynamic_cast<osg::PositionAttitudeTransform *>(node);
if( pat != NULL )
{
osg::Camera *camera=viewer.getCamera();
osg::Matrixd pMatrix = camera->getViewMatrix();
pat ->setAttitude(pMatrix.getRotate());
}
}
};

osg::Node* fun()
{
osg::Geode* geode=new osg::Geode;
geode->addDrawable(new osg::ShapeDrawable(new
osg::Sphere(osg::Vec3(0,0,0),0.1)));

osg::MatrixTransform *mt=new osg::MatrixTransform ;
Matrix matrix;
matrix.setTrans(osg::Vec3(1,0,0));
mt->setMatrix(matrix);
mt->addChild(geode);

osg::PositionAttitudeTransform * tran = new osg::PositionAttitudeTransform;
tran->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
tran->setPosition(osg::Vec3(5,5,0));
tran->addChild(mt);
tran->setUpdateCallback(new MCallBack());

osg::Projection* ProjectionMatrix = new osg::Projection;
ProjectionMatrix->setMatrix(osg::Matrix::ortho2D(0,10,0,10));
ProjectionMatrix->addChild(tran);

return ProjectionMatrix;
}
int _tmain(int argc, _TCHAR* argv[])
{
osg::Node* mRoot =fun();
viewer.setSceneData(mRoot);
return viewer.run();
}

when i rotate the scene,the scene is culled not exactly.
Is there a bug with osg or something wrong with my code?

thanks for any advice.

best regards

forest

________________________________
[¹ãžÊ] œð?ï?î¹??¢?¥??-·¿²»?€·¿





------------------
Post generated by Mail2Forum
Back to top
forest37
Guest





PostPosted: Wed Oct 29, 2008 2:12 am    Post subject:
updateCalculatedNearFar problem
Reply with quote

hi robert,
Thanks for your advice.
I know people are busy,so i concentrate the code.Sometimes problems are hard to describe in native language much less a foreign language.I will try to describle problems in english instead of codes.

Thank you again.
Best regards

forest




[¹ãžÊ] ??»Ý³¢±??€¿Í26µ?Ð??·

------------------
Post generated by Mail2Forum
Back to top
Wang Rui
Guest





PostPosted: Wed Oct 29, 2008 2:19 am    Post subject:
updateCalculatedNearFar problem
Reply with quote

Hi forest,

Why not try to describe your question again at bbs.osgchina.org? Maybe your theory will be more clear using native language. It is a Chinese forum. Smile

Wang Rui

2008/10/29 forest37 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:

hi robert,
Thanks for your advice.
I know people are busy,so i concentrate the code.Sometimes problems are hard to describe in native language much less a foreign language.I will try to describle problems in english instead of codes.

Thank you again.
Best regards

forest




[¹ãžÊ] ??»Ý³¢±??€¿Í26µ?Ð??·
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Happy New Year to all OSG Users Chris Hanson General 0 Mon Jan 07, 2019 10:17 am View latest post
No new posts osg-users Digest, Vol 138, Issue 27 Zachary1234 General 0 Tue Jan 01, 2019 1:16 am View latest post
No new posts Problem in loading VPB database from ... peckham0927 General 1 Sun Dec 23, 2018 1:25 pm View latest post
No new posts osg-users Digest, Vol 137, Issue 14 poweruserm@live.com.au General 0 Fri Nov 16, 2018 11:16 pm View latest post
No new posts General Users starting questions in O... A Z General 1 Mon Oct 15, 2018 3:59 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP