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 

HeadUpDisplay Problem


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
├?mit Uzun
Guest





PostPosted: Mon Nov 03, 2008 4:56 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

Hi Folks,

I have tried to create HUD for textured quad. I have read all about archive and looked to osgHUD sample but it isn't working for textured quad. And same time given code works for text. I can create HUD text on the screen but can not create textured quad on the screen. I know giving lots of code isn't good for you but I will paste all of them if anyone want to look for find out the problem.

If created texture quad add as a child to the root node, it works without giving any problem. But if add as a child to the osg::Camera node it get visible and is seen nothing. I think so, the problem is in osg::Camera node which was initilazed by;

/----------------------------------Camera-------------------------------------/
// create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild( geode );
/----------------------------------Camera-------------------------------------/

Best Regards.
--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

/---------------------------------------HUD---------------------------------------/
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) / sizeof(osg::Vec3);
int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);

osg::ref_ptr<osg::Group> root = new osg::Group();
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new osg::Vec3Array(numCoords, coords));
quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords, tCoords));
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0, numCoords));

geode->addDrawable(quad);

osg::Image* image = osgDB::readImageFile( "RWR_256_256.bmp" );
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find texture file:" << std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);

osg::StateSet *stateSet = quad->getOrCreateStateSet();
stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute:ShockedN);
stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

// create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new osgGA::TrackballManipulator());

viewer.run();

return 0;
}
/---------------------------------------HUD---------------------------------------/

------------------
Post generated by Mail2Forum
Back to top
Jeremy Moles
Guest





PostPosted: Mon Nov 03, 2008 5:23 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

On Mon, 2008-11-03 at 18:56 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Folks,

I have tried to create HUD for textured quad. I have read all about
archive and looked to osgHUD sample but it isn't working for textured
quad. And same time given code works for text. I can create HUD text
on the screen but can not create textured quad on the screen. I know
giving lots of code isn't good for you but I will paste all of them if
anyone want to look for find out the problem.

I really think you should try using osgWidget; even in it's very young
stage of development, it can handle easy stuff like this without a
hitch. And, of course, I'm very responsive to questions about it so
you're bound to get the help you need (except on the weekends, which I
waste playing video games).

If I have my way, all e-mails about creating custom "HUDs" will be
gone. :)

Quote:
If created texture quad add as a child to the root node, it works
without giving any problem. But if add as a child to the osg::Camera
node it get visible and is seen nothing. I think so, the problem is in
osg::Camera node which was initilazed by;

/----------------------------------Camera-------------------------------------/
// create a camera to set up the projection and model view matrices,
and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild( geode );
/----------------------------------Camera-------------------------------------/

Best Regards.
--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

/---------------------------------------HUD---------------------------------------/
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) / sizeof(osg::Vec3);
int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);

osg::ref_ptr<osg::Group> root = new osg::Group();
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new osg::Vec3Array(numCoords, coords));
quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords,
tCoords));
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,
0, numCoords));

geode->addDrawable(quad);

osg::Image* image = osgDB::readImageFile( "RWR_256_256.bmp" );
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find texture file:" <<
std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);

osg::StateSet *stateSet = quad->getOrCreateStateSet();
stateSet->setTextureAttributeAndModes(0, texture,
osg::StateAttribute:ShockedN);
stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

// create a camera to set up the projection and model view
matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new osgGA::TrackballManipulator());

viewer.run();

return 0;
}
/---------------------------------------HUD---------------------------------------/




------------------
Post generated by Mail2Forum
Back to top
├?mit Uzun
Guest





PostPosted: Mon Nov 03, 2008 7:10 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

Hi Jeremy,

Thanks for reply. My target with creating HUD display is playing osgMovie imagestreamed texture in it. If I can achive this operation by osgWidget I glad to use this API. And if it is possible, which osgWidget sample should I glimps? Because I have never tried osgWidget before except looking built-in samples in osg.

Best Regards.

2008/11/3 Jeremy Moles < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
On Mon, 2008-11-03 at 18:56 +0200, ├?mit Uzun wrote:
Quote:
Hi Folks,

I have tried to create HUD for textured quad. I have read all about
archive and looked to osgHUD sample but it isn't working for textured
quad. And same time given code works for text. I can create HUD text
on the screen but can not create textured quad on the screen. I know
giving lots of code isn't good for you but I will paste all of them if
anyone want to look for find out the problem.


I really think you should try using osgWidget; even in it's very young
stage of development, it can handle easy stuff like this without a
hitch. And, of course, I'm very responsive to questions about it so
you're bound to get the help you need (except on the weekends, which I
waste playing video games).

If I have my way, all e-mails about creating custom "HUDs" will be
gone. Smile


Quote:
If created texture quad add as a child to the root node, it works
without giving any problem. But if add as a child to the osg::Camera
node it get visible and is seen nothing. I think so, the problem is in
osg::Camera node which was initilazed by;

/----------------------------------Camera-------------------------------------/
// create a camera to set up the projection and model view matrices,
and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild( geode );
/----------------------------------Camera-------------------------------------/

Best Regards.
--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

/---------------------------------------HUD---------------------------------------/
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) / sizeof(osg::Vec3);
int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);

osg::ref_ptr<osg::Group> root = new osg::Group();
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new osg::Vec3Array(numCoords, coords));
quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords,
tCoords));
quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,
0, numCoords));

geode->addDrawable(quad);

osg::Image* image = osgDB::readImageFile( "RWR_256_256.bmp" );
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find texture file:" <<
std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);
texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);

osg::StateSet *stateSet = quad->getOrCreateStateSet();
stateSet->setTextureAttributeAndModes(0, texture,
osg::StateAttribute:ShockedN);
stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateSet->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

// create a camera to set up the projection and model view
matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix
camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new osgGA::TrackballManipulator());

viewer.run();

return 0;
}
/---------------------------------------HUD---------------------------------------/


Quote:
_______________________________________________
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

_______________________________________________
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



--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

------------------
Post generated by Mail2Forum
Back to top
Jeremy Moles
Guest





PostPosted: Mon Nov 03, 2008 7:32 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

On Mon, 2008-11-03 at 21:10 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Jeremy,

Thanks for reply. My target with creating HUD display is playing
osgMovie imagestreamed texture in it. If I can achive this operation
by osgWidget I glad to use this API. And if it is possible, which
osgWidget sample should I glimps? Because I have never tried osgWidget
before except looking built-in samples in osg.

Here's basically all you need:

---

WindowManager* wm = new WindowManager(...);
Box* box = new Box(...);
Widget* widget = new Widget(...);
ImageStream* stream = new ImageStream(...);

widget->setImage(stream, true);

box->addWidget(widget);

wm->addChild(box);

viewer.setSceneData(wm->createParentOrthoCamera(...));

---

Send me your ImageStream data directly (not over the lists) and I'll
whip up a real example if you wish. :)

Quote:
Best Regards.

2008/11/3 Jeremy Moles <>
On Mon, 2008-11-03 at 18:56 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Folks,

I have tried to create HUD for textured quad. I have read
all about
Quote:
archive and looked to osgHUD sample but it isn't working for
textured
Quote:
quad. And same time given code works for text. I can create
HUD text
Quote:
on the screen but can not create textured quad on the
screen. I know
Quote:
giving lots of code isn't good for you but I will paste all
of them if
Quote:
anyone want to look for find out the problem.


I really think you should try using osgWidget; even in it's
very young
stage of development, it can handle easy stuff like this
without a
hitch. And, of course, I'm very responsive to questions about
it so
you're bound to get the help you need (except on the weekends,
which I
waste playing video games).

If I have my way, all e-mails about creating custom "HUDs"
will be
gone. :)


Quote:
If created texture quad add as a child to the root node, it
works
Quote:
without giving any problem. But if add as a child to the
osg::Camera
Quote:
node it get visible and is seen nothing. I think so, the
problem is in
Quote:
osg::Camera node which was initilazed by;

/----------------------------------Camera-------------------------------------/
// create a camera to set up the projection and model view
matrices,
Quote:
and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix

camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild( geode );
/----------------------------------Camera-------------------------------------/

Best Regards.
--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

/---------------------------------------HUD---------------------------------------/
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) / sizeof(osg::Vec3);
int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);

osg::ref_ptr<osg::Group> root = new osg::Group();
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new osg::Vec3Array(numCoords,
coords));
Quote:
quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords,
tCoords));
quad->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::QUADS,
Quote:
0, numCoords));

geode->addDrawable(quad);

osg::Image* image =
osgDB::readImageFile( "RWR_256_256.bmp" );
Quote:
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find texture file:"
<<
Quote:
std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);

texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
Quote:

osg::StateSet *stateSet = quad->getOrCreateStateSet();
stateSet->setTextureAttributeAndModes(0, texture,
osg::StateAttribute:ShockedN);
stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateSet->setMode(GL_DEPTH_TEST,
osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
Quote:

// create a camera to set up the projection and model
view
Quote:
matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix

camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new
osgGA::TrackballManipulator());
Quote:

viewer.run();

return 0;
}
/---------------------------------------HUD---------------------------------------/

Quote:
_______________________________________________
osg-users mailing list


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





--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com




------------------
Post generated by Mail2Forum
Back to top
├?mit Uzun
Guest





PostPosted: Mon Nov 03, 2008 7:58 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

Hi Jeremy,

Thanks for your detailed description. You are so helpful people Smile But firstly I should examine your API and samples then I will try to implement my target operation on it, if I can't achive, I will be glad to help me Smile

Thanks for your all efforts. And I am waiting porting osganimation in osgWidget api.

But I am so thoughtful about why I can't achive simple HUD operat├ťion on textured Quad, and I wonder to know the reason.

Best Regards.

2008/11/3 Jeremy Moles < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
Quote:
On Mon, 2008-11-03 at 21:10 +0200, ├?mit Uzun wrote:
Quote:
Hi Jeremy,

Thanks for reply. My target with creating HUD display is playing
osgMovie imagestreamed texture in it. If I can achive this operation
by osgWidget I glad to use this API. And if it is possible, which
osgWidget sample should I glimps? Because I have never tried osgWidget
before except looking built-in samples in osg.


Here's basically all you need:

---

WindowManager* wm = new WindowManager(...);
Box* box = new Box(...);
Widget* widget = new Widget(...);
ImageStream* stream = new ImageStream(...);

widget->setImage(stream, true);

box->addWidget(widget);

wm->addChild(box);

viewer.setSceneData(wm->createParentOrthoCamera(...));

---

Send me your ImageStream data directly (not over the lists) and I'll
whip up a real example if you wish. Smile


Quote:
Best Regards.

2008/11/3 Jeremy Moles < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)>
On Mon, 2008-11-03 at 18:56 +0200, ├?mit Uzun wrote:
Quote:
Hi Folks,

I have tried to create HUD for textured quad. I have read
all about
Quote:
archive and looked to osgHUD sample but it isn't working for
textured
Quote:
quad. And same time given code works for text. I can create
HUD text
Quote:
on the screen but can not create textured quad on the
screen. I know
Quote:
giving lots of code isn't good for you but I will paste all
of them if
Quote:
anyone want to look for find out the problem.


I really think you should try using osgWidget; even in it's
very young
stage of development, it can handle easy stuff like this
without a
hitch. And, of course, I'm very responsive to questions about
it so
you're bound to get the help you need (except on the weekends,
which I
waste playing video games).

If I have my way, all e-mails about creating custom "HUDs"
will be
gone. Smile


Quote:
If created texture quad add as a child to the root node, it
works
Quote:
without giving any problem. But if add as a child to the
osg::Camera
Quote:
node it get visible and is seen nothing. I think so, the
problem is in
Quote:
osg::Camera node which was initilazed by;

/----------------------------------Camera-------------------------------------/
// create a camera to set up the projection and model view
matrices,
Quote:
and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix

camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild( geode );
/----------------------------------Camera-------------------------------------/

Best Regards.
--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

/---------------------------------------HUD---------------------------------------/
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) / sizeof(osg::Vec3);
int numTexCoords = sizeof(tCoords) / sizeof(osg::Vec2);

osg::ref_ptr<osg::Group> root = new osg::Group();
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new osg::Vec3Array(numCoords,
coords));
Quote:
quad->setTexCoordArray(0, new osg::Vec2Array(numTexCoords,
tCoords));
quad->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::QUADS,
Quote:
0, numCoords));

geode->addDrawable(quad);

osg::Image* image =
osgDB::readImageFile( "RWR_256_256.bmp" );
Quote:
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find texture file:"
<<
Quote:
std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);

texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
Quote:

osg::StateSet *stateSet = quad->getOrCreateStateSet();
stateSet->setTextureAttributeAndModes(0, texture,
osg::StateAttribute:ShockedN);
stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
stateSet->setMode(GL_DEPTH_TEST,
osg::StateAttribute::OFF);
stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
Quote:

// create a camera to set up the projection and model
view
Quote:
matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new osg::Camera;

// set the projection matrix

camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:

// set the view matrix
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.
camera->setRenderOrder(osg::Camera::POST_RENDER);

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new
osgGA::TrackballManipulator());
Quote:

viewer.run();

return 0;
}
/---------------------------------------HUD---------------------------------------/

Quote:
_______________________________________________
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

_______________________________________________
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



--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com
_______________________________________________
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

_______________________________________________
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





--
├?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com

------------------
Post generated by Mail2Forum
Back to top
Jeremy Moles
Guest





PostPosted: Mon Nov 03, 2008 8:04 pm    Post subject:
HeadUpDisplay Problem
Reply with quote

On Mon, 2008-11-03 at 21:48 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Jeremy,

Thanks for your detailed description. You are so helpful people Smile But
firstly I should examine your API and samples then I will try to
implement my target operation on it, if I can't achive, I will be glad
to help me Smile

Thanks for your all efforts. And I am waiting porting osganimation in
osgWidget api.

But I am so thoughtful about why I can't achive simple HUD operat├?┬▒ion
on textured Quad, and I wonder to know the reason.

Quote:
From a quick cursory glance at your example it appears you're not
setting colors for the vertexes--and you may want to disable lighting.
Also, I don't see you setting the binding (PER_VERTEX, OVERALL, etc).
Doing that will probably clear things up, but I could be missing
something.

At any rate, this is the kind of tedium osgWidget aims to abstract. :)

Quote:
Best Regards.

2008/11/3 Jeremy Moles <>
On Mon, 2008-11-03 at 21:10 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Jeremy,

Thanks for reply. My target with creating HUD display is
playing
Quote:
osgMovie imagestreamed texture in it. If I can achive this
operation
Quote:
by osgWidget I glad to use this API. And if it is possible,
which
Quote:
osgWidget sample should I glimps? Because I have never tried
osgWidget
Quote:
before except looking built-in samples in osg.


Here's basically all you need:

---

WindowManager* wm = new WindowManager(...);
Box* box = new Box(...);
Widget* widget = new Widget(...);
ImageStream* stream = new ImageStream(...);

widget->setImage(stream, true);

box->addWidget(widget);

wm->addChild(box);

viewer.setSceneData(wm->createParentOrthoCamera(...));

---

Send me your ImageStream data directly (not over the lists)
and I'll
whip up a real example if you wish. :)


Quote:
Best Regards.

2008/11/3 Jeremy Moles <>
On Mon, 2008-11-03 at 18:56 +0200, ├?┼?mit Uzun wrote:
Quote:
Hi Folks,

I have tried to create HUD for textured quad. I
have read
Quote:
all about
Quote:
archive and looked to osgHUD sample but it isn't
working for
Quote:
textured
Quote:
quad. And same time given code works for text. I
can create
Quote:
HUD text
Quote:
on the screen but can not create textured quad on
the
Quote:
screen. I know
Quote:
giving lots of code isn't good for you but I will
paste all
Quote:
of them if
Quote:
anyone want to look for find out the problem.


I really think you should try using osgWidget; even
in it's
Quote:
very young
stage of development, it can handle easy stuff like
this
Quote:
without a
hitch. And, of course, I'm very responsive to
questions about
Quote:
it so
you're bound to get the help you need (except on the
weekends,
Quote:
which I
waste playing video games).

If I have my way, all e-mails about creating custom
"HUDs"
Quote:
will be
gone. :)


Quote:
If created texture quad add as a child to the root
node, it
Quote:
works
Quote:
without giving any problem. But if add as a child
to the
Quote:
osg::Camera
Quote:
node it get visible and is seen nothing. I think
so, the
Quote:
problem is in
Quote:
osg::Camera node which was initilazed by;


/----------------------------------Camera-------------------------------------/
Quote:
// create a camera to set up the projection and
model view
Quote:
matrices,
Quote:
and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new
osg::Camera;
Quote:
Quote:

// set the projection matrix


camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:
Quote:

// set the view matrix

camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
Quote:
Quote:
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.

camera->setRenderOrder(osg::Camera::POST_RENDER);
Quote:
Quote:

// add geode to the camera node as a child
camera->addChild( geode );

/----------------------------------Camera-------------------------------------/
Quote:

Best Regards.
--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com


/---------------------------------------HUD---------------------------------------/
Quote:
int main()
{
osg::Vec3 coords[] =
{
osg::Vec3(-1, 0.f ,-1), //LL
osg::Vec3( 1, 0.f, -1), //LR
osg::Vec3( 1, 0.f, 1), //UR
osg::Vec3( -1, 0.f, 1) //UL
};

osg::Vec2 tCoords[] =
{
osg::Vec2(0,0),
osg::Vec2(1,0),
osg::Vec2(1,1),
osg::Vec2(0,1)
};

int numCoords = sizeof(coords) /
sizeof(osg::Vec3);
Quote:
Quote:
int numTexCoords = sizeof(tCoords) /
sizeof(osg::Vec2);
Quote:
Quote:

osg::ref_ptr<osg::Group> root = new
osg::Group();
Quote:
Quote:
osgViewer::Viewer viewer;
osg::Geode *geode = new osg::Geode();
osg::Geometry *quad = new osg::Geometry();

quad->setVertexArray(new
osg::Vec3Array(numCoords,
Quote:
coords));
Quote:
quad->setTexCoordArray(0, new
osg::Vec2Array(numTexCoords,
Quote:
Quote:
tCoords));
quad->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::QUADS,
Quote:
0, numCoords));

geode->addDrawable(quad);

osg::Image* image =
osgDB::readImageFile( "RWR_256_256.bmp" );
Quote:
if (image == NULL)
{
osg::notify(osg::WARN) << "Can't find
texture file:"
Quote:
<<
Quote:
std::endl;
}

osg::Texture2D* texture = new osg::Texture2D();
texture->setImage(image);


texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::REPEAT);
texture->setWrap(osg::Texture2D::WRAP_S,osg::Texture2D::REPEAT);
Quote:
Quote:

osg::StateSet *stateSet =
quad->getOrCreateStateSet();
Quote:
Quote:
stateSet->setTextureAttributeAndModes(0,
texture,
Quote:
Quote:
osg::StateAttribute:ShockedN);

stateSet->setMode(GL_BLEND,osg::StateAttribute:ShockedN);
Quote:
Quote:
stateSet->setMode(GL_DEPTH_TEST,
osg::StateAttribute::OFF);

stateSet->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
Quote:
Quote:

// create a camera to set up the projection and
model
Quote:
view
Quote:
matrices, and the subgraph to drawn in the HUD
osg::ref_ptr<osg::Camera> camera = new
osg::Camera;
Quote:
Quote:

// set the projection matrix


camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));
Quote:
Quote:

// set the view matrix

camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
Quote:
Quote:
camera->setViewMatrix(osg::Matrix::identity());

// only clear the depth buffer
camera->setClearMask(GL_DEPTH_BUFFER_BIT);

// draw subgraph after main camera view.

camera->setRenderOrder(osg::Camera::POST_RENDER);
Quote:
Quote:

// add geode to the camera node as a child
camera->addChild(geode);

// add camera to the root node as a child
root->addChild(camera.get());

viewer.setSceneData(root.get());
viewer.setCameraManipulator(new
osgGA::TrackballManipulator());
Quote:

viewer.run();

return 0;
}

/---------------------------------------HUD---------------------------------------/

Quote:
_______________________________________________
osg-users mailing list



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

_______________________________________________
osg-users mailing list


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



--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com
_______________________________________________
osg-users mailing list


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






--
├?┼?mit Uzun,
Environmental Tectonics Corporation Turkey
ODTU Teknokent
Gumus Bloklar A Blok
Zemin Kat Bati Cephe Suit 1
06531 ODTU
Ankara, Turkey
Tel: 90 (312) 210 17 80
Fax: 90 (312) 210 17 84
E-Mail: umituzun84<at>gmail<dot>com
Website: http://www.etc-turkey.com




------------------
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