Rotating child object in OpenGL c++OpenGL translation before and after a rotationWhat are the differences between a pointer variable and a reference variable in C++?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListActivity restart on rotation AndroidWhat is the “-->” operator in C++?Rotate and translate object in local and global orientation using glmOpenGL Rotation Around a Point Using GLMMy 3d OpenGL object rotates around the world origin, not local-space origin. What am I doing wrong or misunderstanding?Rotate object towards 3D pointcursor orientation openGL c++
How do I run a game when my PCs have different approaches to combat?
What to do when you reach a conclusion and find out later on that someone else already did?
What exactly makes a General Products hull nearly indestructible?
Why are there not any MRI machines available in Interstellar?
Is there a way to shorten this while condition?
This message is flooding my syslog, how to find where it comes from?
How much damage does a magic stone cause when hurled from a sling?
If my business card says 〇〇さん, does that mean I'm referring to myself with an honourific?
What is the difference between $path and $PATH (lowercase versus uppercase) with zsh?
What does Kasparov mean here?
How to write a sincerely religious protagonist without preaching or affirming or judging their worldview?
How do campaign rallies gain candidates votes?
Area of parallelogram = Area of square. Shear transform
Where is this photo of a group of hikers taken? Is it really in the Ural?
401(k) investment after being fired. Do I own it?
Passing lines from the text file of a list of files to or as arguments
Should I leave my PhD after 3 years with a Masters?
kids pooling money for Lego League and taxes
How do professional electronic musicians/sound engineers combat listening fatigue?
Will LSST make a significant increase in the rate of astronomical event alerts?
High income, sudden windfall
Where to place an artificial gland in the human body?
Terence Tao - type books in other fields?
Are glider winch launches rarer in the USA than in the rest of the world? Why?
Rotating child object in OpenGL c++
OpenGL translation before and after a rotationWhat are the differences between a pointer variable and a reference variable in C++?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListActivity restart on rotation AndroidWhat is the “-->” operator in C++?Rotate and translate object in local and global orientation using glmOpenGL Rotation Around a Point Using GLMMy 3d OpenGL object rotates around the world origin, not local-space origin. What am I doing wrong or misunderstanding?Rotate object towards 3D pointcursor orientation openGL c++
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm adding a robot with multiple DoG to my OpenGL application(later i want to implement inverse kinematics for this robot) and i need to move objects that are "connected" together.
So far i added 3 STL object into scene and it looks like this
There is base, joint1 and joint2.
Base is stationary, joint1 and joint2 are for now rotating around Z axis based on keyboard input, but they both just rotate around theirs origin point, which is fine for joint1, but for joint2 i need them to be connected and translate accordingly.
Here is the output after rotation.
For object positioning and rotating i'm using regular MVP matrix and glm.
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, 2.85f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
Is there any way to create something like child-parent Unity relationship in OpenGL? Or should i somehow change the position of joint2 based on joint1 rotation?
c++ opengl rotation glm-math robot
add a comment |
I'm adding a robot with multiple DoG to my OpenGL application(later i want to implement inverse kinematics for this robot) and i need to move objects that are "connected" together.
So far i added 3 STL object into scene and it looks like this
There is base, joint1 and joint2.
Base is stationary, joint1 and joint2 are for now rotating around Z axis based on keyboard input, but they both just rotate around theirs origin point, which is fine for joint1, but for joint2 i need them to be connected and translate accordingly.
Here is the output after rotation.
For object positioning and rotating i'm using regular MVP matrix and glm.
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, 2.85f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
Is there any way to create something like child-parent Unity relationship in OpenGL? Or should i somehow change the position of joint2 based on joint1 rotation?
c++ opengl rotation glm-math robot
1
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
1
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34
add a comment |
I'm adding a robot with multiple DoG to my OpenGL application(later i want to implement inverse kinematics for this robot) and i need to move objects that are "connected" together.
So far i added 3 STL object into scene and it looks like this
There is base, joint1 and joint2.
Base is stationary, joint1 and joint2 are for now rotating around Z axis based on keyboard input, but they both just rotate around theirs origin point, which is fine for joint1, but for joint2 i need them to be connected and translate accordingly.
Here is the output after rotation.
For object positioning and rotating i'm using regular MVP matrix and glm.
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, 2.85f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
Is there any way to create something like child-parent Unity relationship in OpenGL? Or should i somehow change the position of joint2 based on joint1 rotation?
c++ opengl rotation glm-math robot
I'm adding a robot with multiple DoG to my OpenGL application(later i want to implement inverse kinematics for this robot) and i need to move objects that are "connected" together.
So far i added 3 STL object into scene and it looks like this
There is base, joint1 and joint2.
Base is stationary, joint1 and joint2 are for now rotating around Z axis based on keyboard input, but they both just rotate around theirs origin point, which is fine for joint1, but for joint2 i need them to be connected and translate accordingly.
Here is the output after rotation.
For object positioning and rotating i'm using regular MVP matrix and glm.
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, 2.85f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
Is there any way to create something like child-parent Unity relationship in OpenGL? Or should i somehow change the position of joint2 based on joint1 rotation?
c++ opengl rotation glm-math robot
c++ opengl rotation glm-math robot
edited Mar 26 at 16:25


genpfault
43.2k9 gold badges57 silver badges102 bronze badges
43.2k9 gold badges57 silver badges102 bronze badges
asked Mar 26 at 16:10
merethmereth
13614 bronze badges
13614 bronze badges
1
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
1
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34
add a comment |
1
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
1
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34
1
1
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
1
1
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34
add a comment |
1 Answer
1
active
oldest
votes
Thanks to the comments and more googling i managed to get this working like this:
joint1 stays the same:
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2 moves to the position of joint1, rotates, moves where it's supposed to be
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(0.0f, 13.25f, 0.0f));
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361620%2frotating-child-object-in-opengl-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks to the comments and more googling i managed to get this working like this:
joint1 stays the same:
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2 moves to the position of joint1, rotates, moves where it's supposed to be
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(0.0f, 13.25f, 0.0f));
add a comment |
Thanks to the comments and more googling i managed to get this working like this:
joint1 stays the same:
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2 moves to the position of joint1, rotates, moves where it's supposed to be
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(0.0f, 13.25f, 0.0f));
add a comment |
Thanks to the comments and more googling i managed to get this working like this:
joint1 stays the same:
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2 moves to the position of joint1, rotates, moves where it's supposed to be
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(0.0f, 13.25f, 0.0f));
Thanks to the comments and more googling i managed to get this working like this:
joint1 stays the same:
joint1M = glm::translate(joint1M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint1M = glm::rotate(joint1M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2 moves to the position of joint1, rotates, moves where it's supposed to be
joint2M = glm::translate(joint2M, glm::vec3(-50.0f, -10.4f, 0.0f));
joint2M = glm::rotate(joint2M, glm::radians(rotation), glm::vec3(0.0f, 1.0f, 0.0f));
joint2M = glm::translate(joint2M, glm::vec3(0.0f, 13.25f, 0.0f));
answered Mar 26 at 17:22
merethmereth
13614 bronze badges
13614 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55361620%2frotating-child-object-in-opengl-c%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I suggest you reading about scene graphs and hierarchical trees. In short it could help you build parent-child relationship. Whenever a parent changes on the scene its position children are transformed accordingly
– Mateusz Stompór
Mar 26 at 16:14
1
The question OpenGL translation before and after a rotation is about legacy OpenGL (fixed function pipeline matrix stack), but it shows the principle.
– Rabbid76
Mar 26 at 16:34