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 

Can i use MatrixTransform to transform a HUD node?


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


Joined: 04 Jan 2019
Posts: 5

PostPosted: Fri Jan 04, 2019 1:46 pm    Post subject:
Can i use MatrixTransform to transform a HUD node?
Reply with quote

Hi,guys

Well,as the subject notes,The software in my dev job has to use a HUD to show 2d pics. Generally using a camera to create a new viewport to show the pic will be OK.

But the 'Entity' base class for the software system uses a MT (matrixtransform) to add the detailed entity node(such as basic geometry,text with a geode) and then add this MT node to the root by the datacontainer manager class.

If I create the hud entity class derived from the base class, ie, add the camera node to the MT node,does it work if I operate the move, scale commands to this hud entity by using MT,not the camera? If it doesn't work, how can I change the node structure to make the Hud entity responsive to the transform operations which is generated by MT.Or do I only have to use the camera node itself to do these transformation jobs?

Please do me a favor!Thank you,guys!
Smile
Back to top
View user's profile Send private message
Terry Welsh
Guest





PostPosted: Mon Jan 07, 2019 4:09 am    Post subject:
Can i use MatrixTransform to transform a HUD node?
Reply with quote

I have made plenty of HUD classes derived from osg::Camera. It's easy
to set it up as an orthographic or perspective projection, depending
on what look you're going for. Then I compute some simple coordinates
for the screen corners like this:

mHUDLRBT[0] = -mAspectRatio;
mHUDLRBT[1] = mAspectRatio;
mHUDLRBT[2] = -1.0f;
mHUDLRBT[3] = 1.0f;
if(mAspectRatio < 1.0f){
mHUDLRBT[0] = -1.0f;
mHUDLRBT[1] = 1.0f;
mHUDLRBT[2] = -1.0f / mAspectRatio;
mHUDLRBT[3] = 1.0f / mAspectRatio;
}

All your HUD nodes (such as osgText::Text or something derived from
MatrixTransform) can be positioned relative to those screen corners.
Every time you resize your window you should call your HUD nodes
positioning method.
- Terry

Quote:

Message: 5
Date: Fri, 04 Jan 2019 14:47:01 +0100
From: "Chen Gao" <>
To:
Subject: Can i use MatrixTransform to transform a HUD
node?
Message-ID: <>
Content-Type: text/plain; charset=UTF-8

Hi,guys

Well,as the subject notes,The software in my dev job has to use a HUD to show 2d pics. Generally using a camera to create a new viewport to show the pic will be OK.

But the 'Entity' base class for the software system uses a MT (matrixtransform) to add the detailed entity node(such as basic geometry,text with a geode) and then add this MT node to the root by the datacontainer manager class.

If I create the hud entity class derived from the base class, ie, add the camera node to the MT node,does it work if I operate the move, scale commands to this hud entity by using MT,not the camera? If it doesn't work, how can I change the node structure to make the Hud entity responsive to the transform operations which is generated by MT.Or do I only have to use the camera node itself to do these transformation jobs?

Please do me a favor!Thank you,guys!
Smile


------------------
Post generated by Mail2Forum
Back to top
PeterGao
Newbie


Joined: 04 Jan 2019
Posts: 5

PostPosted: Mon Jan 07, 2019 11:48 am    Post subject:
Re: Can i use MatrixTransform to transform a HUD node?
Reply with quote

Thank you Terry!

So you mean that if i want to move or scale these hud nodes on the main screen, i have to use the camera's setviewmatrix method to do this? Add the hud nodes to a new MT and use the Mt transform methods won't work,right?

The node structure instruction is like the following:

1. Root->hud node->Mt node->geode node->geometries;

2. Root->Mt node-> hud node->geode node->geometries;

So the first one will work and the second won't,right?


Terry Welsh wrote:
I have made plenty of HUD classes derived from osg::Camera. It's easy
to set it up as an orthographic or perspective projection, depending
on what look you're going for. Then I compute some simple coordinates
for the screen corners like this:

mHUDLRBT[0] = -mAspectRatio;
mHUDLRBT[1] = mAspectRatio;
mHUDLRBT[2] = -1.0f;
mHUDLRBT[3] = 1.0f;
if(mAspectRatio < 1.0f){
mHUDLRBT[0] = -1.0f;
mHUDLRBT[1] = 1.0f;
mHUDLRBT[2] = -1.0f / mAspectRatio;
mHUDLRBT[3] = 1.0f / mAspectRatio;
}

All your HUD nodes (such as osgText::Text or something derived from
MatrixTransform) can be positioned relative to those screen corners.
Every time you resize your window you should call your HUD nodes
positioning method.
- Terry
Back to top
View user's profile Send private message
Chris Hanson
Guest





PostPosted: Mon Jan 07, 2019 1:49 pm    Post subject:
Can i use MatrixTransform to transform a HUD node?
Reply with quote

Quote:
    Well,as the subject notes,The software in my dev job has to use a HUD to show 2d pics. Generally using a camera to create a new viewport to show the pic will be OK.
    But the 'Entity' base class for the software system uses a MT (matrixtransform) to add the detailed entity node(such as basic geometry,text with a geode) and then add this MT node to the root by the datacontainer manager class.
    If I create the hud entity class derived from the base class, ie, add the camera node to the MT node,does it work if I operate the move, scale commands to this hud entity by using MT,not the camera? If it doesn't work, how can I change the node structure to make the Hud entity responsive to the transform operations which is generated by MT.Or do I only have to use the camera node itself to do these transformation jobs?


I'm afraid I didn't understand this explanation very well myself. My first question would be, do the HUD elements (the 2d pics) stay stuck to the screen space (as if they were part of a game scoreboard overlaid onto the screen) or do the move around the screen as the main view camera rotates, tilts, moves, etc like an Augment Reality environment?


-- 


Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
PeterGao
Newbie


Joined: 04 Jan 2019
Posts: 5

PostPosted: Tue Jan 08, 2019 5:01 am    Post subject:
Re: Can i use MatrixTransform to transform a HUD node?
Reply with quote

Chris Hanson wrote:


I'm afraid I didn't understand this explanation very well myself. My first question would be, do the HUD elements (the 2d pics) stay stuck to the screen space (as if they were part of a game scoreboard overlaid onto the screen) or do the move around the screen as the main view camera rotates, tilts, moves, etc like an Augment Reality environment?


-- 


Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum


Thank you for your reply. If you feel confused by my unprofessional Smile explanation, you can think it this way as below:

Can I use a MT node to add the Hud node and then transform the hud on the screen by the MT parent node.

This should be clear.
Back to top
View user's profile Send private message
Terry Welsh
Guest





PostPosted: Tue Jan 08, 2019 5:08 am    Post subject:
Can i use MatrixTransform to transform a HUD node?
Reply with quote

Quote:
So you mean that if i want to move or scale these hud nodes on the main screen, i have to use the camera's setviewmatrix method to do this? Add the hud nodes to a new MT and use the Mt transform methods won't work,right?

The node structure instruction is like the following:

1. Root->hud node->Mt node->geode node->geometries;

2. Root->Mt node-> hud node->geode node->geometries;

So the first one will work and the second won't,right?

I have only done #1, where the HUD node is derived from osg::Camera. I
set the view matrix and projection matrix to provide a simple box in
which to render all HUD elements. The individual elements can be
positioned within that box with MatrixTransforms.

It's not very hard to get this working. Try prototyping it with one
osgText::Text element and one simple box or sphere under a
MatrixTransform.

Quote:

I'm afraid I didn't understand this explanation very well myself. My first
question would be, do the HUD elements (the 2d pics) stay stuck to the
screen space (as if they were part of a game scoreboard overlaid onto the
screen) or do the move around the screen as the main view camera rotates,
tilts, moves, etc like an Augment Reality environment?

Chris, I assumed your first idea. AR labels never crossed my mind.
Maybe Chen can tell us if I made the right assumption.
- Terry


------------------
Post generated by Mail2Forum
Back to top
Chris Hanson
Guest





PostPosted: Tue Jan 08, 2019 9:01 am    Post subject:
Can i use MatrixTransform to transform a HUD node?
Reply with quote

Quote:
Chris, I assumed your first idea. AR labels never crossed my mind.
Maybe Chen can tell us if I made the right assumption.


  I was just trying to be thorough and complete because I wasn't clear on the situation, so I was throwing all possibilities out there to see if that was the reason I wasn't getting it.


  Normally making a HUD is pretty straightforward ( https://github.com/openscenegraph/OpenSceneGraph/tree/master/examples/osghud ) so I assumed this must be a more complex case. 



--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Training • Consulting • Contracting
3D • Scene Graphs (Open Scene Graph/OSG) • OpenGL 2 • OpenGL 3 • OpenGL 4 • GLSL • OpenGL ES 1 • OpenGL ES 2 • OpenCL
Legal/IP • Forensics • Imaging • UAVs • GIS • GPS • osgEarth • Terrain • Telemetry • Cryptography • LIDAR • Embedded • Mobile • iPhone/iPad/iOS • Android
@alphapixel facebook.com/alphapixel (775) 623-PIXL [7495]

------------------
Post generated by Mail2Forum
Back to top
PeterGao
Newbie


Joined: 04 Jan 2019
Posts: 5

PostPosted: Tue Jan 08, 2019 12:48 pm    Post subject:
Re: Can i use MatrixTransform to transform a HUD node?
Reply with quote

Yeah,Terry. #1 is the exactly the right way to use HUD. I've been trying these days to use MT transformation method to operate the child HUD node but it will never be able to control it because i found that I've used the following line of code:

camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);

When I looked up the detailed explanation of this code on the net,I realized that MT will never be working on it.If we want to control its position, we only have to and only need to use the camera node itself.That will be Ok.

I haven't tried to delete this line code and then use MT to control the camera node, but I guess that will result in a bad effect and I haven't seen anyone on the net to use HUD this way. So Laughing just don't care about it.

Terry Welsh wrote:
I have only done #1, where the HUD node is derived from osg::Camera. I
set the view matrix and projection matrix to provide a simple box in
which to render all HUD elements. The individual elements can be
positioned within that box with MatrixTransforms.

It's not very hard to get this working. Try prototyping it with one
osgText::Text element and one simple box or sphere under a
MatrixTransform.

- Terry


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
PeterGao
Newbie


Joined: 04 Jan 2019
Posts: 5

PostPosted: Tue Jan 08, 2019 1:23 pm    Post subject:
Re: Can i use MatrixTransform to transform a HUD node?
Reply with quote

Well,Chris. Just as you assumed,my case is quite complicated. I have to make a growing up effect HUD, ie, dynamically scaled up one. Use Mt to scale the HUD node will never work since we set the camera ABSOLUTE_RF mode. Then i tried to use the setviewmatrix method to scale it up but this won't work,too.

The only way I 've found working is to scale up the raw image passed to draw the pic. The drawable can be a texture or a drawpixels and i use the latter one. To enable dynamic effect, I have to use a custom NodeCallBack class to handle it. Each callback time I have to set and scale the image to the drawpixels to show a growing up scaled size.
But since I saw the HUD content of your github link, I guess the SnapImage struct the author creates may be a new way to handle this job.I 'll try it in the next following days. Thank you,guy!Laughing

Chris Hanson wrote:


  I was just trying to be thorough and complete because I wasn't clear on the situation, so I was throwing all possibilities out there to see if that was the reason I wasn't getting it.


  Normally making a HUD is pretty straightforward ( https://github.com/openscenegraph/OpenSceneGraph/tree/master/examples/osghud ) so I assumed this must be a more complex case. 
Back to top
View user's profile Send private message
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 Updating a PositionAttitudeTransform ... johansson_gbg General 3 Wed Oct 09, 2019 8:26 am View latest post
No new posts Orient a node to face another pleopard General 2 Wed Oct 02, 2019 2:47 pm View latest post
No new posts Different colors for a node shared sc... icf80 General 1 Thu Jun 13, 2019 12:49 pm View latest post
No new posts Deep cloning an active root scene node Robert Lockyer General 7 Thu Feb 28, 2019 5:52 pm View latest post
No new posts osg::LOD node not being considered in... Josiah425 General 1 Tue Feb 19, 2019 6:52 pm 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