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 

changing dimensions of a box


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


Joined: 30 May 2017
Posts: 3

PostPosted: Tue May 30, 2017 1:06 pm    Post subject:
changing dimensions of a box
Reply with quote

Hey guys,
i'm an absolute beginner in osg, but i have to use it at a project in university. I'm using MS visual studio 2013 for coding.
I've got this task:

Creating a box, which changes its dimensions regarding to time.
e.g. the box has to grow in x-direction for 5 sec after that in y-direction for 8 sec and so on.

Maybe someone could give me a short introduction, how to deal with this problem.

Thank you!

Cheers,
Mat
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11154

PostPosted: Tue May 30, 2017 2:54 pm    Post subject:
changing dimensions of a box
Reply with quote

HI Mat,

You can tackle this a number of ways. The route I'd take would be to
create a static sized box using an osg::Geometry (see the osggeometyr
example) then use a vertex shader to modify the vertex values. Have a
look at the osghaders for how to set up shaders - this example
includes a code path which animates use vertex shaders.

Robert.

On 30 May 2017 at 14:06, Mat Monk <> wrote:
Quote:
Hey guys,
i'm an absolute beginner in osg, but i have to use it at a project in university. I'm using MS visual studio 2013 for coding.
I've got this task:

Creating a box, which changes its dimensions regarding to time.
e.g. the box has to grow in x-direction for 5 sec after that in y-direction for 8 sec and so on.

Maybe someone could give me a short introduction, how to deal with this problem.

Thank you!

Cheers,
Mat

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








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


Joined: 30 May 2017
Posts: 3

PostPosted: Thu Jun 01, 2017 3:42 pm    Post subject:
Reply with quote

Hey Robert,

thank you very much.
As you said, I created a static box. But i dont understand the shaders function in the example osgshaders.

I found a example of a rotating quad and modified it, so it includes my box instead the quad. But finally i couldn't change the rotation to changing the dimensions in x-direction for examples.

I added the document with my code.


robertosfield wrote:
HI Mat,

You can tackle this a number of ways. The route I'd take would be to
create a static sized box using an osg::Geometry (see the osggeometyr
example) then use a vertex shader to modify the vertex values. Have a
look at the osghaders for how to set up shaders - this example
includes a code path which animates use vertex shaders.

Robert.

On 30 May 2017 at 14:06, Mat Monk <> wrote:
Quote:
Hey guys,
i'm an absolute beginner in osg, but i have to use it at a project in university. I'm using MS visual studio 2013 for coding.
I've got this task:

Creating a box, which changes its dimensions regarding to time.
e.g. the box has to grow in x-direction for 5 sec after that in y-direction for 8 sec and so on.

Maybe someone could give me a short introduction, how to deal with this problem.

Thank you!

Cheers,
Mat

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








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

Thank you!

Cheers,
Mat
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11154

PostPosted: Fri Jun 02, 2017 7:54 am    Post subject:
changing dimensions of a box
Reply with quote

HI Mat,

On 1 June 2017 at 16:42, Mat Monk <> wrote:
Quote:
As you said, I created a static box. But i dont understand the shaders function in the example osgshaders.

I guess you must be learning OpenGL/OpenGL Shaders as well as OSG then.

Quote:
I found a example of a rotating quad and modified it, so it includes my box instead the quad. But finally i couldn't change the rotation to changing the dimensions in x-direction for examples.

Using callbacks to update the vertices is one possible solution, but
the most heavy-wieght in terms of CPU cost.

If you want to modify the vertices of the geoemtry using a callback
then you've done most of the required steps. The only thing missing
is that you have to iterate over all the vertices in the Vec3Array.
Vec3Array is std::vector<osg::Vec3> under the hood so knowledge of
Standard C++ should help here. Also look at the include/osg/Vec3f
class to see what maths methods are available.

Robert.


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


Joined: 30 May 2017
Posts: 3

PostPosted: Fri Jun 02, 2017 11:24 pm    Post subject:
Re: changing dimensions of a box
Reply with quote

Dear Robert,
thank you so much for your help.
My program is now able to change the boxes dimensions.
But how can i interrupt the dynamiccallback to change my vertex "factor" for example after 3 sec, so the box grows in y- direction instead of x-direction?
robertosfield wrote:
HI Mat,

On 1 June 2017 at 16:42, Mat Monk <> wrote:
Quote:
As you said, I created a static box. But i dont understand the shaders function in the example osgshaders.

I guess you must be learning OpenGL/OpenGL Shaders as well as OSG then.

Quote:
I found a example of a rotating quad and modified it, so it includes my box instead the quad. But finally i couldn't change the rotation to changing the dimensions in x-direction for examples.

Using callbacks to update the vertices is one possible solution, but
the most heavy-wieght in terms of CPU cost.

If you want to modify the vertices of the geoemtry using a callback
then you've done most of the required steps. The only thing missing
is that you have to iterate over all the vertices in the Vec3Array.
Vec3Array is std::vector<osg::Vec3> under the hood so knowledge of
Standard C++ should help here. Also look at the include/osg/Vec3f
class to see what maths methods are available.

Robert.


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


Cheers,
Mat
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 ViewerBase::frame() method slow after... gambr General 8 Fri Jul 21, 2017 9:11 am View latest post
No new posts Changing another thread's node's Stat... CTW_Liu General 4 Mon Dec 05, 2016 7:49 am View latest post
No new posts Link Problems Arise After CMAKE (desp... dsargrad Build system [build] 0 Sun Jun 12, 2016 11:52 am View latest post
No new posts Stats not showing after changing came... hunter789 General 4 Tue Mar 29, 2016 3:28 pm View latest post
No new posts viewport is changing after huge sized... drony General 5 Tue Mar 22, 2016 9:30 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