[SOLVED] How do I project a 3D Sphere on a 2D canvas

0 favourites
  • 3 posts
From the Asset Store
Template for a basketball game with a 3D aspect (illusion of 3D)
  • Here I am, struggling with math that goes above my head.

    Some days ago, I saw an animation of a sphere with white dots attached to it, rotating.

    Example:

    I thought that looked pretty neat and thought that it must be possible to recreate this in C2 with some simple math.

    How wrong I was.

    I found this page explaining how it should work.

    At some point reading through the article, I figured I still need to learn a lot to be able to understand this.

    So I kinda gave up on understanding it.

    But I didn't want to give up on at least having a finished version of it in C2, maybe even learning something in the process.

    So I went ahead and more or less copied the code in the article ( + the source code provided in the article) into C2.

    And of course it didn't work.

    Now I know that to help me with this is quite the request, but maybe someone got some free time and motivation and is up for this challenge.

    This is what I've gotten so far by simply copy&paste and that doesn't work at all.

    Now, again, I am no math expert, by no means, I simply want to complete this to go to sleep happily.

    Any feedback is hugely appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Here's you version tweaked to work:

    https://www.dropbox.com/s/68gwhdp68n5na ... .capx?dl=1

    And here's a few points of what had to change:

    1. Angles in js are in radians and in C2 angles are in degrees. All this means is you replace pi with 180 in all the formulas.

    2. Position information is being lost since x,y is being rotated and projected every frame. The solution for that is to store the original position in px,py,pz variables and set x,y,z from that. This is actually the biggest reason it didn't work.

    Other than that there were some things you could simplify but it wasn't crucial.

  • R0J0hound you never let me down.

    Actually, when I posted this, I hoped that you would answer.

    Thanks so much!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)