Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Moving 3D shapes in a "Drag and Drop" Fashion

$
0
0

@akamal wrote:

Hello all, new to OpenFrameworks (I’ve recreated Doodle Jump if that counts for something). Intermediate in C/C++.

I’m creating a simulation/ program where students can connect different atoms together to start a chemical reaction, thus creating a compound. EX: combining hydrogen and oxygen atoms to get water.

The basic UI of the program will consist of 2 main panels. On the right side will be a small, slim panel which will serve as an element bank. The left side will be the student’s workspace. What I’d like is for students to be able to drag and drop elements from the ‘element bank’ panel, and into their workspace so that they could connect them to form compounds.

Currently, I have the panels set up, as well as the hydrogen and oxygen atoms drawn. (I just drew spheres to represent them). I have yet to add the ofEasyCam, but the shapes are being drawn in 3D.

I’m currently working on trying to add the drag and drop functionality, but I can’t seem to be able to move the sphere at all. As mentioned above, I used OpenFrameworks to recreate Doodle Jump. To move the character in Doodle jump my code looked something similar to this:

if (key == ‘a’){
player.location.x -= 30;
}

This line of code was able to move the player when I was recreating DoodleJump, but it doesn’t work when i try to move the position of the sphere. I’m not sure why I can’t move the position of the sphere. Is it because i’m using the ofPoint function to store and edit the position of the sphere? Could someone take a look at my code (it’s not much, aside from the standard stuff 25 lines tops) and let me know what I’m doing wrong? Thank you !!!

P.S. If you’re trying to create a project in project generator in order to plug in the source code files in the ‘src’ folder, please put the Elements.h and .cpp files in the parent folder of the ‘src’ folder.

EDIT: Apparently I can’t upload the files, so i’ll create a Google Drive link of the files. Thanks.
https://drive.google.com/drive/folders/1dp784Do72h-oGVfBiHxb4tZqXoowKngG?usp=sharing

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929