Darkonoid

20
PRINCIPLES OF PRINCIPLES OF COMPUTER GRAPHICS COMPUTER GRAPHICS FINAL PROJECT FINAL PROJECT ORUÇ HÜSEYİN GÜRSOY ORUÇ HÜSEYİN GÜRSOY

description

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

Transcript of Darkonoid

Page 1: Darkonoid

PRINCIPLES OFPRINCIPLES OFCOMPUTER GRAPHICSCOMPUTER GRAPHICS

FINAL PROJECTFINAL PROJECT

ORUÇ HÜSEYİN GÜRSOYORUÇ HÜSEYİN GÜRSOY

Page 2: Darkonoid

3-D ARKONOID = DARKONOID3-D ARKONOID = DARKONOID

From 2-D to 3-DFrom 2-D to 3-D

Page 3: Darkonoid

LAYOUT OF PRESENTATIONLAYOUT OF PRESENTATION

Introduction of DarkonoidIntroduction of Darkonoid

Objects usedObjects used

How it worksHow it works

Page 4: Darkonoid

INTRODUCTIONINTRODUCTION

3-D Environment3-D Environment

Move your 3-D base with mouse,Move your 3-D base with mouse,

Try to destroy 3-D itemsTry to destroy 3-D items

Move your camera with keyboardMove your camera with keyboard

Score and info on seperate windowScore and info on seperate window

Page 5: Darkonoid

3-D GAME VOLUME (SEETHROUGH)

BASE (SEETHROUGH)

BALL LINE(To understand Ball's level)

BALL

ITEMS to destroyRED = 5 pointsBLUE = 3 pointsGREEN = 1 points

Page 6: Darkonoid

BALL :BALL : Sphere-like shaped,Sphere-like shaped,random colouredrandom coloured

BASE :BASE : 6-GON shaped,6-GON shaped,seethrough (to see the seethrough (to see the

ball)ball)

Surface of the base is like round shaped,Surface of the base is like round shaped,This gives you the minor control of the This gives you the minor control of the

ball ! ball !

Page 7: Darkonoid

ITEMS:ITEMS:

RED = 5 pointsRED = 5 pointsBLUE = 3 pointsBLUE = 3 pointsGREEN = 1 pointsGREEN = 1 points

The ball bounces according to the The ball bounces according to the side it hitsside it hits

SCOREBOARDSCOREBOARD

Page 8: Darkonoid

Package LayoutPackage Layout arko_starterarko_starter

ArkoStarter.javaArkoStarter.java

geometriesgeometries

geoms3Dgeoms3D

N_gon3D.javaN_gon3D.java

Obj3D.javaObj3D.java

Point3D.javaPoint3D.java

Geometry.javaGeometry.java

Matrix.javaMatrix.java

rendererrenderer

MovementStatus.javaMovementStatus.java

Renderer.javaRenderer.java

Page 9: Darkonoid

MATRIXMATRIX

Matrix includesMatrix includes public int satir; // #rowspublic int satir; // #rows public int sutun; // #columnspublic int sutun; // #columns public double[][] sayi; // matrix itemspublic double[][] sayi; // matrix items

ConstructionConstruction public Matrix(int satir, int sutun)public Matrix(int satir, int sutun) public Matrix(Point3D p)public Matrix(Point3D p)

Page 10: Darkonoid

MATRIX, methodsMATRIX, methods public void sifirla()public void sifirla()

// makes identity// makes identity

public void Esitle(Matrix e)public void Esitle(Matrix e)

// makes equal to e// makes equal to e

public void MultiplyWith(Matrix m)public void MultiplyWith(Matrix m)

// multiplies with m// multiplies with m

public void transMatrix(double a,double b,double c)public void transMatrix(double a,double b,double c)

// makes this matrix a translation matrix// makes this matrix a translation matrix

public void scaleMatrix(double sx, double sy, double sz)public void scaleMatrix(double sx, double sy, double sz)

// makes this matrix a scaling matrix// makes this matrix a scaling matrix

public void rotateAroundY(double theta)public void rotateAroundY(double theta)

// makes this matrix a rotation matrix// makes this matrix a rotation matrix

public void rotateMatrixAroundPoint(Point3D p, double theta)public void rotateMatrixAroundPoint(Point3D p, double theta)

// makes this matrix a rotation around a Point matrix// makes this matrix a rotation around a Point matrix

public void strToConsole()public void strToConsole()

// writes matrix to console// writes matrix to console

Page 11: Darkonoid

Geometry (base geometry)Geometry (base geometry)

Each Geometry has a Matrix tEach Geometry has a Matrix t

Methods;Methods; void display(GLAutoDrawable drawables);void display(GLAutoDrawable drawables); void applyTransform(Matrix transform);void applyTransform(Matrix transform); double range(Point3D p);double range(Point3D p); void renk(double r,double g,double b);void renk(double r,double g,double b);

Page 12: Darkonoid

Point3DPoint3D COORDINATES OF THE POINTCOORDINATES OF THE POINT

public double x;public double x;

public double y;public double y;

public double z;public double z; COLOR OF THE POINTCOLOR OF THE POINT

public double r;public double r;

public double g;public double g;

public double b;public double b; SPECİFİC METHODSSPECİFİC METHODS

public void renkRandom()public void renkRandom()

Page 13: Darkonoid

N_gon3DN_gon3D

N_gon3D has;N_gon3D has; public int n;public int n;

public Point3D Points[];public Point3D Points[];

public Point3D center;public Point3D center;

ConstructionConstruction

public N_gon3D(Point3D center, double r1,double r2, int n)public N_gon3D(Point3D center, double r1,double r2, int n)

center : center pointcenter : center point

r1 : radius 1r1 : radius 1

r2 : radius 2r2 : radius 2

n : n of n_gonn : n of n_gon

Page 14: Darkonoid

Obj3DObj3D

Obj3D has;Obj3D has; public N_gon3D alt;public N_gon3D alt;

public N_gon3D ust;public N_gon3D ust;

public int n;public int n;

public double r1;public double r1;

public double r2;public double r2;

public double h;public double h;

ConstructionConstruction

public Obj3D(int n, double r1,double r2, double h)public Obj3D(int n, double r1,double r2, double h)

h : height of objecth : height of object

Page 15: Darkonoid

How it works ?How it works ? Initialisation and creation,Initialisation and creation,

Creation of the battle groundCreation of the battle ground Creation of the baseCreation of the base Creation of the ballCreation of the ball Creation of the itemsCreation of the items

At each displayAt each display apply the ball its transfomation matrixapply the ball its transfomation matrix detect a collision (with items or base or walls detect a collision (with items or base or walls

of the battle ground)of the battle ground) if (collision) calculate the appropriate if (collision) calculate the appropriate

transformation matrix of the ball and do the transformation matrix of the ball and do the appropriate actionsappropriate actions

Page 16: Darkonoid

Range from a PlaneRange from a Plane double rangeFromPlane(Point3D p, Point3D p1,Point3D p2,Point3D p3)double rangeFromPlane(Point3D p, Point3D p1,Point3D p2,Point3D p3)

PLANE PLANE ax + by + cz + d = 0ax + by + cz + d = 0

You must get into this form from three points...You must get into this form from three points...

Page 17: Darkonoid

Range from a PlaneRange from a Plane

double a=p2.y*(p3.z-p1.z)+p1.y*(p2.z-p3.z)+p3.y*(p1.z-p2.z);double a=p2.y*(p3.z-p1.z)+p1.y*(p2.z-p3.z)+p3.y*(p1.z-p2.z);

double b=p2.x*(p1.z-p3.z)+p1.x*(p3.z-p2.z)+p3.x*(p2.z-p1.z);double b=p2.x*(p1.z-p3.z)+p1.x*(p3.z-p2.z)+p3.x*(p2.z-p1.z);

double c=p2.x*(p3.y-p1.y)+p1.x*(p2.y-p3.y)+p3.x*(p1.y-p2.y);double c=p2.x*(p3.y-p1.y)+p1.x*(p2.y-p3.y)+p3.x*(p1.y-p2.y);

double d=-a*p1.x-b*p1.y-c*p1.z;double d=-a*p1.x-b*p1.y-c*p1.z;

range=(a*p.x+b*p.y+c*p.z+d)/Math.sqrt(a*a+b*b+c*c);range=(a*p.x+b*p.y+c*p.z+d)/Math.sqrt(a*a+b*b+c*c);

return (double)range;return (double)range;

Page 18: Darkonoid

Reflection from a PlaneReflection from a Plane get the normal of the planeget the normal of the plane get the projection of your vector on the normal and get the projection of your vector on the normal and

negate itnegate it add the 2 x result to your vectoradd the 2 x result to your vector

Page 19: Darkonoid

Round-like shaped surfaceRound-like shaped surface get the range from ball to the center,get the range from ball to the center, rotate the normal by (asin(range/radius)/4)rotate the normal by (asin(range/radius)/4) do this in 3D (just two more steps)do this in 3D (just two more steps)

Page 20: Darkonoid

Making algorithm fasterMaking algorithm faster

range from items are calculated for all range from items are calculated for all sides of items (two much operaton)sides of items (two much operaton)

to avoid this ;to avoid this ;

first range from one of the center first range from one of the center points is calculated,points is calculated,

if this range is below some value then if this range is below some value then further check for collision is donefurther check for collision is done