Darkonoid

392 views

Published on

Darkonoid is the 3-d version of the old game Arkonoid (3-D
Arkonoid=Darkonoid).

Published in: Education, Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
392
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Darkonoid

  1. 1. PRINCIPLES OF COMPUTER GRAPHICS FINAL PROJECT ORUÇ HÜSEYİN GÜRSOY
  2. 2. 3-D ARKONOID = DARKONOID From 2-D to 3-D
  3. 3. LAYOUT OF PRESENTATION <ul><ul><ul><li>Introduction of Darkonoid </li></ul></ul></ul><ul><ul><ul><li>Objects used </li></ul></ul></ul><ul><ul><ul><li>How it works </li></ul></ul></ul>
  4. 4. INTRODUCTION <ul><ul><ul><ul><ul><li>3-D Environment </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Move your 3-D base with mouse, </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Try to destroy 3-D items </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Move your camera with keyboard </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Score and info on seperate window </li></ul></ul></ul></ul></ul>
  5. 5. 3-D GAME VOLUME (SEETHROUGH)‏ BASE (SEETHROUGH)‏ BALL LINE (To understand Ball's level)‏ BALL ITEMS to destroy RED = 5 points BLUE = 3 points GREEN = 1 points
  6. 6. BALL : Sphere-like shaped, random coloured BASE : 6-GON shaped, seethrough (to see the ball)‏ Surface of the base is like round shaped, This gives you the minor control of the ball ! 
  7. 7. ITEMS: RED = 5 points BLUE = 3 points GREEN = 1 points The ball bounces according to the side it hits SCOREBOARD
  8. 8. Package Layout <ul><li>arko_starter </li></ul><ul><ul><li>ArkoStarter.java </li></ul></ul><ul><li>geometries </li></ul><ul><ul><li>geoms3D </li></ul></ul><ul><ul><ul><li>N_gon3D.java </li></ul></ul></ul><ul><ul><ul><li>Obj3D.java </li></ul></ul></ul><ul><ul><ul><li>Point3D.java </li></ul></ul></ul><ul><ul><li>Geometry.java </li></ul></ul><ul><ul><li>Matrix.java </li></ul></ul><ul><li>renderer </li></ul><ul><ul><li>MovementStatus.java </li></ul></ul><ul><ul><li>Renderer.java </li></ul></ul>
  9. 9. MATRIX <ul><li>Matrix includes </li></ul><ul><ul><li>public int satir; // #rows </li></ul></ul><ul><ul><li>public int sutun; // #columns </li></ul></ul><ul><ul><li>public double[][] sayi; // matrix items </li></ul></ul><ul><li>Construction </li></ul><ul><ul><li>public Matrix(int satir, int sutun)‏ </li></ul></ul><ul><ul><li>public Matrix(Point3D p)‏ </li></ul></ul>
  10. 10. MATRIX, methods <ul><li>public void sifirla()‏ </li></ul><ul><ul><li>// makes identity </li></ul></ul><ul><li>public void Esitle(Matrix e)‏ </li></ul><ul><ul><li>// makes equal to e </li></ul></ul><ul><li>public void MultiplyWith(Matrix m)‏ </li></ul><ul><ul><li>// multiplies with m </li></ul></ul><ul><li>public void transMatrix(double a,double b,double c)‏ </li></ul><ul><ul><li>// makes this matrix a translation matrix </li></ul></ul><ul><li>public void scaleMatrix(double sx, double sy, double sz)‏ </li></ul><ul><ul><li>// makes this matrix a scaling matrix </li></ul></ul><ul><li>public void rotateAroundY(double theta)‏ </li></ul><ul><ul><li>// makes this matrix a rotation matrix </li></ul></ul><ul><li>public void rotateMatrixAroundPoint(Point3D p, double theta)‏ </li></ul><ul><ul><li>// makes this matrix a rotation around a Point matrix </li></ul></ul><ul><li>public void strToConsole()‏ </li></ul><ul><ul><li>// writes matrix to console </li></ul></ul>
  11. 11. Geometry (base geometry)‏ <ul><li>Each Geometry has a Matrix t </li></ul><ul><li>Methods; </li></ul><ul><ul><li>void display(GLAutoDrawable drawables); </li></ul></ul><ul><ul><li>void applyTransform(Matrix transform); </li></ul></ul><ul><ul><li>double range(Point3D p); </li></ul></ul><ul><ul><li>void renk(double r,double g,double b); </li></ul></ul>
  12. 12. Point3D <ul><li>COORDINATES OF THE POINT </li></ul><ul><ul><li>public double x; </li></ul></ul><ul><ul><li>public double y; </li></ul></ul><ul><ul><li>public double z; </li></ul></ul><ul><li>COLOR OF THE POINT </li></ul><ul><ul><li>public double r; </li></ul></ul><ul><ul><li>public double g; </li></ul></ul><ul><ul><li>public double b; </li></ul></ul><ul><li>SPECİFİC METHODS </li></ul><ul><ul><li>public void renkRandom()‏ </li></ul></ul>
  13. 13. N_gon3D <ul><li>N_gon3D has; </li></ul><ul><ul><li>public int n; </li></ul></ul><ul><ul><li>public Point3D Points[]; </li></ul></ul><ul><ul><li>public Point3D center; </li></ul></ul><ul><li>Construction </li></ul><ul><ul><li>public N_gon3D(Point3D center, double r1,double r2, int n)‏ </li></ul></ul><ul><ul><li>center : center point </li></ul></ul><ul><ul><li>r1 : radius 1 </li></ul></ul><ul><ul><li>r2 : radius 2 </li></ul></ul><ul><ul><li>n : n of n_gon </li></ul></ul>
  14. 14. Obj3D <ul><li>Obj3D has; </li></ul><ul><ul><li>public N_gon3D alt; </li></ul></ul><ul><ul><li>public N_gon3D ust; </li></ul></ul><ul><ul><li>public int n; </li></ul></ul><ul><ul><li>public double r1; </li></ul></ul><ul><ul><li>public double r2; </li></ul></ul><ul><ul><li>public double h; </li></ul></ul><ul><li>Construction </li></ul><ul><ul><li>public Obj3D(int n, double r1,double r2, double h)‏ </li></ul></ul><ul><ul><li>h : height of object </li></ul></ul>
  15. 15. How it works ? <ul><li>Initialisation and creation, </li></ul><ul><ul><li>Creation of the battle ground </li></ul></ul><ul><ul><li>Creation of the base </li></ul></ul><ul><ul><li>Creation of the ball </li></ul></ul><ul><ul><li>Creation of the items </li></ul></ul><ul><li>At each display </li></ul><ul><ul><li>apply the ball its transfomation matrix </li></ul></ul><ul><ul><li>detect a collision (with items or base or walls of the battle ground)‏ </li></ul></ul><ul><ul><li>if (collision) calculate the appropriate transformation matrix of the ball and do the appropriate actions </li></ul></ul>
  16. 16. Range from a Plane <ul><li>double rangeFromPlane(Point3D p, Point3D p1,Point3D p2,Point3D p3)‏ </li></ul><ul><ul><li>PLANE  ax + by + cz + d = 0 </li></ul></ul><ul><ul><li>You must get into this form from three points... </li></ul></ul>
  17. 17. Range from a Plane <ul><li>double a=p2.y*(p3.z-p1.z)+p1.y*(p2.z-p3.z)+p3.y*(p1.z-p2.z); </li></ul><ul><li>double b=p2.x*(p1.z-p3.z)+p1.x*(p3.z-p2.z)+p3.x*(p2.z-p1.z); </li></ul><ul><li>double c=p2.x*(p3.y-p1.y)+p1.x*(p2.y-p3.y)+p3.x*(p1.y-p2.y); </li></ul><ul><li>double d=-a*p1.x-b*p1.y-c*p1.z; </li></ul><ul><li>range=(a*p.x+b*p.y+c*p.z+d)/Math.sqrt(a*a+b*b+c*c); </li></ul><ul><li>return (double)range; </li></ul>
  18. 18. Reflection from a Plane <ul><li>get the normal of the plane </li></ul><ul><li>get the projection of your vector on the normal and negate it </li></ul><ul><li>add the 2 x result to your vector </li></ul>
  19. 19. Round-like shaped surface <ul><li>get the range from ball to the center, </li></ul><ul><li>rotate the normal by (asin(range/radius)/4)‏ </li></ul><ul><li>do this in 3D (just two more steps)‏ </li></ul>
  20. 20. Making algorithm faster <ul><li>range from items are calculated for all sides of items (two much operaton)‏ </li></ul><ul><li>to avoid this ; </li></ul><ul><ul><ul><ul><ul><li>first range from one of the center points is calculated, </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>if this range is below some value then further check for collision is done </li></ul></ul></ul></ul></ul>

×