Java Reference
In-Depth Information
nated. As can be seen from the result obtained, the effects of having different spread angles
and concentration can be easily demonstrated by changing the appropriate parameters of
the light sources.
foG
Fog corresponds to the use of a fading effect for the purpose of enhancing realism and
creating images, which are smoother and may lead to stronger emotional feelings (Brown
& Petersen, 1999). This is achieved by blending the colors of visual objects with that of
the fog depending on the distance of the objects from the view port. Objects, which are
further away from the view port will take on a color that is closer to the fog color. With this
fading in and out effects, distant objects will emerge into 3D world in a smoother manner,
instead of appearing suddenly. In a certain way, the influence of atmospheric effects can
be better simulated.
Figure 12. First code segment and for fogdemo.java
1. public fogdemo(String title) {
2. . . .
3. if (getInput().equalsIgnoreCase("Y")){
4. if (FogMode==1 || FogMode==2) {
5. println ("Fog influencing distance"); fogdist=Double.parseDouble(getInput()); }
6. if (FogMode==1){
7. println("Fog Front Clip distance?"); print("?"); fogfront=Double.parseDouble(getInput());
8. println("Fog Back Clip Distance?"); print("?"); fogback=Double.parseDouble(getInput());}
9. if (FogMode==2){ println("Enter Fog Density"); print("?"); density=Float.parseFloat(getInput()); }
10. println("Depth of objects to render"); print("?"); backClip=Double.parseDouble(getInput());
11. println("The Detail of the scene"); print("?");buildings=Integer.parseInt(getInput()); }
12. else { fogfront=0.1; fogback=400.0; fogdist=400.0; density=0.16f; backClip=400.0; }
13. catch(Exception e) print("Error found"); println("Initializing......");
14.
15. GraphicsConfiguration gc=SimpleUniverse.getPreferredConfiguration();
16. Canvas3D canvas3d=new Canvas3D(gc);
17. Rectangle rect=gc.getBounds();
18. setSize(640,480);
19. setLocation(rect.width/2+rect.x-320,rect.height/2+rect.y-240);
20. SimpleUniverse simpleu=new SimpleUniverse(canvas3d);
21. ViewPlatform vp=new ViewPlatform();
22. TransformGroup tvg=new TransformGroup();
23. tvg.setCapability(tvg.ALLOW_TRANSFORM_READ);
24. tvg.setCapability(tvg.ALLOW_TRANSFORM_WRITE);
25. tvg.addChild(vp);
26.
Search WWH ::




Custom Search