Skip to content

Commit

Permalink
d06 finished up to ex05
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyril HERON committed Jan 13, 2015
1 parent 236d0c3 commit f7a7a05
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 11 deletions.
8 changes: 7 additions & 1 deletion d06/ex05/Camera.doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Any other use is undefined

The class provies the following methods :

Vertex watchVertex( Vertex $worldVertex ) : Transform a NDC vertex into one with screen coordinates.
Vertex watchVertex( Vertex $worldVertex ) : return the result of the transformation a NDC vertex into one with screen coordinates.

Triangle watchTriangle( Triangle $worldTriangle ) : return the result of the transformation of a NDC triangle into one with screen coordinates, also set his visibility.

wMesh watchMesh( $mesh ) : return the result of the transformation of a NDC mesh into one with screen coordinates.

Bool isVisible( Triangle $tri ) : return true if the triangle is visible from $this.

---------------------------------------------------------------------- Camera ->
10 changes: 10 additions & 0 deletions d06/ex05/Color.doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@ Substracts each color constitutive and returns a new Color instance.
Color mult( $f );
Multiplies each color constitutive by factor $f and returns a new Color
instance.

int toPngColor( $image ):
Calculate the color code corresponding for $image and returns a int.

Color bifusion( Color $destination, $advancement ):
Creates a new Color between $this and $destination based on the advancement
and return it.

Color trifusion( Color $A, $progAm Color $B, $progB, Color $C, $progC ):
same as for 3 points.
---------------------------------------------------------------------- Color ->
7 changes: 6 additions & 1 deletion d06/ex05/Matrix.doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ The class provies the following methods :

Matrix mult( $rhs ) : return a new matrix result of the multiplication of the two others.

Vertex transforVertex( Vertex $vtx ) : return a new vertex result of the transformation of the previous vertex by the matrix.
Vertex transformVertex( Vertex $vtx ) : return a new vertex result of the transformation of the previous vertex by the matrix.

Triangle transformTriangle( Triangle $Triangle ) : return a new triangle result of the transformation of the previous vertex by the matrix.

tMesh transformMesh( $mesh ) : return a new mesh result of the transformation of the previous mesh by the matrix.

Matrix transpose() : return a new matrix result of the transposition of $this.
---------------------------------------------------------------------- Matrix ->
23 changes: 23 additions & 0 deletions d06/ex05/Render.doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<- Render ----------------------------------------------------------------------
The Render class print 2D to screen, it can be used after the camera tranformations occured.

new Render( $width, $height, $filename );

All fiels are reauiered, any other use is undefined.

The class has 3 const for different renderisation mode: VERTEX, EDGE and RESTERIZE.
The Class provides the following methods :

void renderVertex( $screenVertex ) : print $screenVertex in the image contained.

void renderSegment( Vertex $origin, Vertex $end ) : print a segment in the image contained going from origin to end.

void renderRasterize( Triangle $triangle ) : render the rasterization of a triangle.

void renderTriangle( Triangle $triangle, $mode ) : Render a triangle depending on mode choosen.

void renderMesh( $mesh ) : Render a mesh depending on the mide choosen.

void develop() : develop the image in the field specified when render was created.

---------------------------------------------------------------------- Render ->
8 changes: 4 additions & 4 deletions d06/ex05/Triangle.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static function doc() {
private $_A;
private $_B;
private $_C;
private $_visible;
private $_visiblei = false;

public function getA() {
return ( clone $this->_A );
Expand Down Expand Up @@ -54,11 +54,11 @@ public function area() {
$by = $this->_B->getY();
$cx = $this->_C->getX();
$cy = $this->_C->getY();
$area = abs(($ax * ($by - $cy) + $bx * ($cy - $ay) + $cx * ($ay - $by)) / 2);
return ($area);
$area = abs( ( $ax * ( $by - $cy ) + $bx * ( $cy - $ay ) + $cx * ( $ay - $by ) ) / 2 );
return ( $area);
}

public function get_point_color(Vertex $p) {
public function get_point_color( Vertex $p ) {
$abp = new Triangle( $this->_A, $this->_B, $p );
$acp = new Triangle( $this->_A, $this->_C, $p );
$bcp = new Triangle( $this->_B, $this->_C, $p );
Expand Down
28 changes: 28 additions & 0 deletions d06/ex05/Triangle.doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<- Triangle ----------------------------------------------------------------------
The Triangle class handles the representation of a triangle.

An instance can be created using 3 vertex:
new Triangle( $A, $B, $C );

All fields are reauiered, any other use is undefined.

The class provides the following methods :

Vertex getA() : return a clone of $A;

Vertex getB() : return a clone of $B;

Vertex getC() : return a clone of $C;

Bool getVisibility() : return true if the triangle is visible, this is only relevant for transformed triangle.

void setVisibility( $val ) : set visiblity of the triangle.

Vector getNormal() : return the normal vector of $this.

Vertex getCentroid() : return the centroid point of $this.

Number area() : return the area of a triangle.

Color get_point_color( Vertex $p ) : return the color of a point ina triangle.
---------------------------------------------------------------------- Triangle ->
10 changes: 5 additions & 5 deletions d06/ex05/Vertex.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ public function mult( $nb ) {
return (new Color( array( 'x' => $this->getX() * $nb, 'y' => $this->getY() * $nb, 'z' => $this->getZ() * $nb, 'w' => $this->getW() * $nb, 'Color' => $this->getColor()->mult( $nb ))));
}

public function equal( Vertex $vth ) {
if ( $this->getX() === $vth->getX() && $this->getY() === $vth->getY() && $this->getZ() === $vth->getZ() )
return true;
return false;
}
// public function equal( Vertex $vth ) {
// if ( $this->getX() === $vth->getX() && $this->getY() === $vth->getY() && $this->getZ() === $vth->getZ() )
// return true;
// return false;
// }
}

?>
3 changes: 3 additions & 0 deletions d06/ex05/Vertex.doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ Substracts each vortex constitutive and returns a new vortex instance.

Vortex mult( Vortex $nb )
Multiplies each vortex constitutive by factor $nb and returns a new vortex instance.

Bool equal( Vertex $vth )
Return true if both vertex have the same x,y,z coordinates.
------------------------------------------------------------------------------------- Vertex ->

0 comments on commit f7a7a05

Please sign in to comment.