temp.normalize( ); temp.sub( light ); temp.normalize( ); cos_alpha
temp.normalize( ); temp.sub( light ); temp.normalize( ); cos_alpha = view.dot( temp ); intensity = (int) (lightMax * ( lightAmbient + lightDiffuse * cos_theta + lightSpecular * Math.pow( cos_alpha, lightGlossiness ))); } } } } return intensity; } 2.4 Putting it together MyJava3D The MyJava3D example defines the RenderingEngineinterface. This interface defines a simple rendering contract between a client and a 3D renderer implementation. The RenderingEngineinterface defines a simple renderer that can render 3D geometry described using a Java 3D GeometryArray. The GeometryArraycontains the 3D points and normal vectors for the 3D model to be rendered. In addition to adding GeometryArraysto the RenderingEngine(addGeometrymethod), the viewpoint of the viewer can be specified (setViewAngle), the direction of a single light can be specified (setLightAngle), the scaling factor to be applied to the model can be varied (setScale), and the size of the rendering screen defined (setScreenSize). To render all the GeometryArraysadded to the RenderingEngineusing the current light, screen, scale, and view parameters, clients can call the render method, supplying a Graphicsobject to render into, along with an optional GeometryUpdater. The GeometryUpdaterallows a client to modify the positions of points or rendering parameters prior to rendering. From AwtRenderingEngine.java /** * Definition of the RenderingEngine interface. A RenderingEngine 22
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost JSP Web Hosting services