Rotating Surface Ball Game

Rotating Surface Ball Game
Andres Traumann, Katrin Valdson, Morteza Daneshmand
Email: {Andres.traumann,vkatrinn,mortezad}@ut.ee
MTAT.03.015 Computer Graphics
Course Project Report
University of Tartu, Tartu, Estonia
As the main challenge of the game described in this report, which has been developed in the
Javascript 3D library “three.js”, the player tries to collect as many points as possible upon
rotating the surface on which a green ball traverses through the scene. The objective is to make
the ball move in such a way that it would touch a yellow target object. In fact, rotating the plane
is commanded by the user through pressing either of the four prescribed keys on the keyboard,
each of which being responsible for increasing the angular velocity of the change in the
orientation of the surface in a specific direction, around x- or y-axes. More clearly, the rotation
around each axis can be controlled via two keys, which counterbalance each other.
There also another object, with red color, which randomly moves on the surface, and is intended
to distract the user, and make the playing experience more exciting. The surface is designed such
that unevenness, along with the rises and falls makes it more difficult to control or predict the
direction and speed of the movement of the ball. One of the intriguing notions while playing the
game is to handle the rotation of the surface with a certain level of care required for preventing
the ball from rolling off the surface, or even out of the area covered by the perspective camera.
In order to increase the unpredictability of the directions, thereby maintaining the diversity of the
movements needed to be performed, once the target has been hit, it is then located in a new,
randomly-selected, position for the next round, which also ensures passing through widest area
possible while trying to approach the target. In other words, since the surface involves random
convex and concave curvatures, moving the ball in various directions towards the target might
lead to a more interesting experience.
As the principal penalty incurred by colliding with the aforementioned distracting red ball, the
green ball is bounced back in a direction dependent on a bunch of physical parameters, including
the respective velocity and movement direction of both of balls. The latter significantly reduces
the chances of the player being able to lead the green ball back into the desired route targeting
the yellow object, whereby the user is trained and warned to be as careful as possible while
passing by the red ball later on, i.e. during the upcoming rounds.
The backbone of the above penalty strategy is the red ball being supposed to be significantly
bigger and heavier than the green one, meaning that hitting it is almost tantamount to depriving
the player of the privilege to control the ball thenceforth. It is also worth noticing that not only
the movement of the green ball is under the influence of the aforementioned surface curvatures,
but also is that of the red ball, intended to increase the difficulties involved in avoiding touching
it.
As far as the authors’ experiences have shown, the current version of the code base works only
with the Mozilla Firefox Browser for an unknown reason, although comprehensive investigation
has not yet been performed as to whether it would also do with others. Some parts of the code,
which deal only with specific tasks involved in the whole project, such as uploading or animating
the obj-format model of the surface, might work also with other browsers, sometimes, given the
fulfillment of certain preconditions. For example, the authors first tried to upload the foregoing
file from a local hard-disk, rather than the current remote server, which worked properly only
after disabling the cache in the Google Chrome Browser.
One of the major modules of the game is the one dealing with collision detection, which is of
paramount importance for determining the movement of both green and red balls. The approach
taken into account for the foregoing purpose is ray casting, where the ray is cast from the (x,y)
position of the ball, orthogonally, onto the surface. Afterward, the z-coordinate of the position of
the ball is calculated based on the first intersection of the aforementioned ray with the surface.
As the final stage of determining the movement properties, the curvature underneath the ball is
considered for computing the appropriate speed. More precisely, x- and y-gradients of the change
in the z-coordinate are considered for obtaining the velocity vector, which includes both speed
and orientation. Last but not least, as aforementioned, the rotation of the surface is incorporated
into the mathematical model representing the physical forces making the ball move. In other
words, the ball is not supposed to be exposed to external forces, and its movement is resulted
only from the component of the gravity decomposed along the surface.
Regarding the surface, it has been developed by the authors, using Blender, where the basic idea
has been to, first, consider a flat surface, and then extrude randomly-selected faces in the
direction orthogonal to the plane, which is followed by smoothing the resulting shape in all the
possible dimensions. The model is then exported as an obj-format file, and uploaded into a
publicly-accessible server, in order for it to be utilized for the purpose of running the project
remotely. Besides, a small score display is provided in the upper-left corner of the screen, which
guides the user as to how many points have been accomplished heretofore.
As possible future works in the related areas, one might consider incorporating further
complications, such as sudden evens, including surface quirks, happening in the scene, which
would increase the level of distraction the player faces, or implementing more sophisticated
lightning effects and shadows. Besides, the idea of animating the ball could be extended to more
complicated 3D structures, such as human body.