VisClient/org/hfbk/vis/BirdsEye.java

Go to the documentation of this file.
00001 package org.hfbk.vis;
00002 
00003 import java.awt.AWTEvent;
00004 import java.util.ArrayList;
00005 
00006 import org.dronus.gl.GLUtil;
00007 import org.hfbk.vis.visnode.VisRoot;
00008 import org.lwjgl.opengl.GL11;
00009 
00018 public class BirdsEye {
00019         
00020         public void render(VisRoot root){
00021                 
00022                 int sx=root.client.panel.getWidth(), sy=root.client.panel.getHeight();
00023                 
00024                 //the corner we draw the map to 
00025                 float   x1=.7f*sx,              y1=.7f*sy,
00026                                 w1=.3f*sx,              h1=.3f*sy;
00027                 
00028                 //set tranform and clipping to paint in corner          
00029                 GL11.glViewport((int)x1,(int)y1,(int)w1,(int)h1);
00030                 GL11.glEnable(GL11.GL_SCISSOR_TEST);
00031                 
00032                 //render a green frame
00033                 GL11.glScissor((int)x1-2,(int)y1-2,(int)w1+4,(int)h1+4);                        
00034                 GL11.glClearColor(.2f,.8f,.2f,1); 
00035                 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
00036 
00037                 //set clipping to paint in corner
00038                 GL11.glScissor((int)x1,(int)y1,(int)w1,(int)h1);                
00039                 GL11.glClearColor(.3f,.1f,.1f,1);
00040                 GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
00041 
00042                 
00043                 // lets begin rendering.                
00044                 Viewpoint vp=root.client.mouseViewpoint;                
00045                 GL11.glLoadIdentity();          
00046                 GL11.glRotatef(90, 1, 0, 0); //top-down view
00047                 //GL11.glTranslatef(0,0,100); //de-center to show more in front of viewer
00048                 GL11.glRotatef((float)(vp.angle*-180/Math.PI), 0, 1, 0); 
00049                 GL11.glTranslatef(-vp.x,-vp.y-500,-vp.z); //follow viewer
00050                 
00051                 root.render(new ArrayList<AWTEvent>()); //render without any events
00052                 
00053                 
00054                 //render a triangle to represent field of view
00055                 GL11.glLoadIdentity(); //again screen aligned transform
00056                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00057                 GL11.glDisable(GL11.GL_ALPHA_TEST);
00058                 
00059                 GL11.glTranslatef(0,0,-1);
00060                 GL11.glBegin(GL11.GL_TRIANGLES);                
00061                 GL11.glColor4f(0,1,0,.2f);
00062                 GL11.glVertex3f(0,0,0);
00063                 float x=GLUtil.aspect*GLUtil.fov;
00064                 GL11.glVertex3f( x,1,0);
00065                 GL11.glVertex3f(-x,1,0);                
00066                 GL11.glEnd();
00067                 
00068                 //restore state
00069                 GL11.glEnable(GL11.GL_ALPHA_TEST); 
00070                 GL11.glDisable(GL11.GL_SCISSOR_TEST);
00071                 GL11.glViewport(0,0,(int)sx, (int)sy);
00072         }       
00073 }

Generated on Tue Apr 7 17:57:20 2009 for visclient by  doxygen 1.5.1