3D puzzle

Hey VVVVers,

Well, back to the forum again.

I would like to do a 3D puzzle. At the moment I’m using an online puzzle through the HTMLTexture DX11. I have some limitations with that so I would like to do it entirely in VVVV

What basically I need to achieve:

  1. A collision detect between each piece of the puzzle
  2. If it’s the correct piece it will snap with the other
  3. Understand when it’s complete

BONUS: End up with a contribution so someone else in the future will find it easier.

So I have rough draft in my mind on how to approach this but I would like to hear your opinion and your approach that would probably be more helpful and fast than mine.

P.S I don’t have a clue about VL

P.S 2 It’s going to be touch installation.


1 Like

there are so many ways, i think if you want to have physics in there bullet is your way

you can use bvh to add custom collision shapes
there is a raycast, so you can pick up picies

i’m not sure about stability but i think it’s a matter of tweaking a friction

if the piece is left from "grasp": if the piece is over its coords: if there's another correctly placed piece in any surrounding coord: piece2pieceSnapAnimation()

@antokhio , That’s the question. Do we need physics to implement a 3D puzzle? It could provide more features but is it needed?

@h99 Like the logic of that, don’t know how to use it.

These could be a start.


Ok so how to detect the collision between the parts? any way it will be acceptable.

with 3d select contribution I’m able to detect the collision between the “hit” and the parts but how can i detect when one part has a collision with the other parts?

The actual question is what would you like to get from this collision? (Data or effect)

Actual mesh collision detection is an physics engine feature.

You should prolly start by having somekind of invisible solved puzzle in scene, so you can get some final xyz of fragment, so you check if pice is near it’s final position.

Basically you can run twice the 3d select contrib, first time against your actual pices, second time against final result.

Attaching some pices together and moving them attached is bit of

well I actually want both…data and effect…

data so I can know when they collide and the effect of attaching them together.

I will do the pipeline you suggest, the twice run of 3d select with an invisible solved puzzle and see the next step from there

OK so I skipped the collision part for now and tried to achieve the movement.

As you can see in the video I uploaded two of the pieces are matching with the mouse pointer but the other two are getting offset when I click on them. Any clues? Any tips?

record_000003.zip (2.4 MB)

So basically when I map the coordinates of the XY (mouse) with the transformation of the puzzles it changes their position? but even if i connect direct the XY of the mouse to the transformation it still offsets the pieces. so whatever I do I get the offset. it’s not the aspect ratio because it’s connected to all necessary points

edit…So I found the issue…The problem was that I was changing the piece coordinates with the mouse coordinates but when I dropped the piece somewhere in the screen and then try to pick it up again it was offsetting the difference between last drop and new pick up…So a solution I found was to: Get the XY coordinates of the piece and subtract them from the XY coordinates of the mouse. After that I was feeding it to the transformation.

It works BUT.

The Issue is that is flickering between the two distances (probably is because is doing the subtract all the time) and it’s not stable.

What I thought is that when you pick up the piece, it will do the subtract at that frame and then switch to the XY coordinates of the mouse. I did manually and it works. Now I need to it automatically.

i would recommend moving the pieces by framedifference. That way you dont have to care about mouse position vs object center and such stuff. see my attempt at puzzeling with quads. quite fun thing to patch.
drag quads by framedifference.v4p (21.7 KB)

Hey tgd,

Thank for the patch.
They not moving thought… did I missed anything?

You haven’t connect hittest points xy with the mouse xy…I did it but they not moving again.

huh, saved everything connected, strange. mouse XY needs to be connected to hittetst and framedifference.
i was patching it with an alpha but the mouseXY pin has changed naming there. that might be the problem.
sorry, as it is the part the patch is all about :) just reconnect, should be good.

OK. Back to this…

I’ve made something…It’s been attached.

The thing is that if you can open it you will see that is selecting Puzzle.zip (813.4 KB)

My problem is that it doesn’t select on piece at every click but if they overlap it’s selecting multiple pieces…how can I get rid of this?

There are multiple ways to solve this of course. The easiest one might be just putting a sift node between hittest and the s+h. Sift for “1” and set the find pin to “last” so you get always the frontmost piece. Also connect your color switch to the sift node rather than the hittest so you highlight just the piece you are about to move.

1 Like

Or you just Select a 3D object

1 Like

tgd you are a small god!! Thank you!

That worked as a charm!

Lecloneur I’m using select 3D object in another way somewhere in my patch…That works very nice too.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.