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 

Dragging individual model nodes


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
arfaa
Newbie


Joined: 27 Jul 2017
Posts: 13

PostPosted: Tue Apr 23, 2019 1:10 pm    Post subject:
Dragging individual model nodes
Reply with quote

Hi, I have model - car. It consists of two doors, four wheels .....
I want select right door by mouse and move it to another area.
How and through what should I implement it? Maybe there are examples of this?
...


Thank you!

Cheers,
Maxim
Back to top
View user's profile Send private message
icf80
User


Joined: 12 Apr 2019
Posts: 28

PostPosted: Wed Apr 24, 2019 7:30 am    Post subject:
Reply with quote

Hi,

You have to find the node associated to your object by intersection:

osgUtil::LineSegmentIntersector::Intersections ints;
bool bHasIntersections = viewer->computeIntersections(viewer->getCamera(), osgUtil::Intersector::WINDOW, x, y, ints, CULL_MASK_HERE);

if (bHasIntersections)
{
const osgUtil::LineSegmentIntersector::Intersection& inter = *(ints.begin());

const osg::NodePath& nodePath = inter.nodePath;
unsigned int idx = nodePath.size();
while (idx--)
{
osg::Node*node =nodePath[idx];

....


Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
arfaa
Newbie


Joined: 27 Jul 2017
Posts: 13

PostPosted: Wed Apr 24, 2019 8:14 am    Post subject:
Reply with quote

icf80 wrote:
Hi,

You have to find the node associated to your object by intersection:

osgUtil::LineSegmentIntersector::Intersections ints;
bool bHasIntersections = viewer->computeIntersections(viewer->getCamera(), osgUtil::Intersector::WINDOW, x, y, ints, CULL_MASK_HERE);

if (bHasIntersections)
{
const osgUtil::LineSegmentIntersector::Intersection& inter = *(ints.begin());

const osg::NodePath& nodePath = inter.nodePath;
unsigned int idx = nodePath.size();
while (idx--)
{
osg::Node*node =nodePath[idx];

....


Thank you!

Cheers,
Catalin

Yes, I found the necessary node, what should I do next?
Back to top
View user's profile Send private message
icf80
User


Joined: 12 Apr 2019
Posts: 28

PostPosted: Wed Apr 24, 2019 8:42 am    Post subject:
Reply with quote

Hi,

You should have your scene graph as follow

root - osg::MatrixTransform - osg:Node

The matrix is controlling the position of the node. Modify the matrix to modify the node position.


Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
icf80
User


Joined: 12 Apr 2019
Posts: 28

PostPosted: Wed Apr 24, 2019 8:44 am    Post subject:
Reply with quote

Hi,

Get this book, it learns basic stufff:

https://www.amazon.com/OpenSceneGraph-3-0-Beginners-Rui-Wang/dp/1849512825

Thank you!

Cheers,
Catalin
Back to top
View user's profile Send private message
arfaa
Newbie


Joined: 27 Jul 2017
Posts: 13

PostPosted: Wed Apr 24, 2019 9:17 am    Post subject:
Reply with quote

icf80 wrote:
Hi,

Get this book, it learns basic stufff:

https://www.amazon.com/OpenSceneGraph-3-0-Beginners-Rui-Wang/dp/1849512825

Thank you!

Cheers,
Catalin

this is a bad answer.
Back to top
View user's profile Send private message
Alberto Luaces
Guest





PostPosted: Wed Apr 24, 2019 11:27 am    Post subject:
Dragging individual model nodes
Reply with quote

"Maxim Senin" writes:

Quote:
Yes, I found the necessary node, what should I do next?

It depends: do you want to completely detach the door, or just rotate it
around its hinges?

--
Alberto



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


Joined: 27 Jul 2017
Posts: 13

PostPosted: Mon Apr 29, 2019 6:08 am    Post subject:
Re: Dragging individual model nodes
Reply with quote

Alberto Luaces wrote:
"Maxim Senin" writes:

Quote:
Yes, I found the necessary node, what should I do next?

It depends: do you want to completely detach the door, or just rotate it
around its hinges?

--
Alberto



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


I want to completely detach the door!!!
Back to top
View user's profile Send private message
Alberto Luaces
Guest





PostPosted: Mon Apr 29, 2019 7:26 am    Post subject:
Dragging individual model nodes
Reply with quote

"Maxim Senin" writes:

Quote:
I want to completely detach the door!!!

Nice to know!!! Then what you want is to use
osg::Transform::setReferenceFrame() on the node holding the position of
the door, switching from RELATIVE_RF to ABSOLUTE_RF so its coordinates
are in the global system and not in the coordinate system of the whole
car.

--
Alberto



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


Joined: 27 Jul 2017
Posts: 13

PostPosted: Mon Apr 29, 2019 12:48 pm    Post subject:
Re: Dragging individual model nodes
Reply with quote

Alberto Luaces wrote:
"Maxim Senin" writes:

Quote:
I want to completely detach the door!!!

Nice to know!!! Then what you want is to use
osg::Transform::setReferenceFrame() on the node holding the position of
the door, switching from RELATIVE_RF to ABSOLUTE_RF so its coordinates
are in the global system and not in the coordinate system of the whole
car.

--
Alberto



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

Is there an example or sample of such a solution?
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 [forum] 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 Different views hide/show different n... icf80 General 13 Wed Apr 17, 2019 9:56 am View latest post
No new posts why does the adding of lighting shade... mirro General 0 Mon Feb 11, 2019 3:03 am View latest post
No new posts Capturing all visible nodes ijwolf8 General 11 Fri Jan 18, 2019 9:16 pm View latest post
No new posts Selecting a mesh of 3d model (say 3ds... nebsar General 2 Wed Jan 02, 2019 9:47 pm View latest post
No new posts Questions concerning Performance issu... Andrea74 General 3 Fri Dec 14, 2018 11:24 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