12
Nov
Black Art of Java Game Programming by Joel
myAngle=new fAngle3d(); myTransformMatrix=new fMatrix3d(); } /** * set the position and angle for this polyhedron instance. */ public void setOrientation(fPoint3d pos,fAngle3d agl){ if(myPosition.equals(pos)==false){ //– if position has changed then mark the matrix //– as “dirty” meaning that the transformed points //– need to be updated. myPosition.set(pos); positionIsDirty=true; } if(myAngle.equals(agl)==false){ myAngle.set(agl); angleIsDirty=true; } } /** * paint the polyhedron instance. */ public void paint(Graphics g,fGenericCamera camera){ if(positionIsDirty || angleIsDirty){ //– position or angle has changed and the transformed //– vertices need to be updated. myTransformMatrix.makeMCStoWCStransform(myPosition,myAngle); //– transform the polyhedron model coordinates to world coords. myTransformMatrix.transform(thePolyhedron.getVertices(),transformedVertic es); //– positionIsDirty=angleIsDirty=false; } //– project the WCS to the screen with the supplied camera //– and then call the paint method of the polyhedron with //– the returned 2d array thePolyhedron.paint(g,camera.project(transformedVertices)); } } The Array transformedVertices This array is used for storing the world coordinates of the polyhedron s vertices. Since many objects are static, it is a good idea to save this information to eliminate redundant recalculations. Understanding the paint() Method
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services
