VisClient/org/hfbk/vis/visnode/VisInteractive.java

Go to the documentation of this file.
00001 package org.hfbk.vis.visnode;
00002 
00003 import java.awt.event.MouseEvent;
00004 
00005 import org.dronus.gl.GLBoxRenderer;
00006 import org.dronus.gl.GLUtil;
00007 import org.dronus.graph.Node;
00008 import org.lwjgl.opengl.GL11;
00009 import org.lwjgl.util.vector.Vector3f;
00010 
00018 public class VisInteractive extends VisNodeMousable {
00019 
00020         Vector3f target;
00021         float energy;
00022         VisBalistic balistic;
00023         
00024         public VisInteractive(Node node, Vector3f pos) {
00025                 super(node, pos);
00026                 radius=w=h=25000;
00027         }
00028 
00029         public VisInteractive(Node dummy, Vector3f pos, Vector3f size) {
00030                 super(null, pos);
00031                 w=size.x;
00032                 h=size.z;
00033                 radius=Math.max(w,h);
00034         }
00035         
00036         void handleEvent(VisMouseEvent evt) {
00037                 int id=evt.awtEvent.getID();
00038 //              if (id==MouseEvent.MOUSE_DRAGGED || id==MouseEvent.MOUSE_PRESSED){
00039                 if (id==MouseEvent.MOUSE_CLICKED){
00040                         
00041                         
00042                         
00043                         target=evt.hit;
00044                         //balistic.target=traverse(balistic, target);
00045                         System.out.println(target);
00046                 }
00047         
00048         
00049         }
00050 
00051         @Override
00052         void transform() {      
00053                 super.transform();
00054                 GL11.glRotatef(90,1,0,0);
00055         }
00056         @Override
00057         void renderSelf() {
00058 /*              if(balistic==null){ //ensure our parent has a balistic object
00059                         for (VisNode n: parent.children)
00060                                 if (n instanceof VisBalistic)
00061                                         balistic=(VisBalistic)n; //found one
00062                         if (balistic==null) //found none, add one
00063                                 parent.add(balistic=new VisBalistic(new Vector3f(0,20,50)));
00064                 }
00065         */      
00066                 GL11.glDisable(GL11.GL_TEXTURE_2D);
00067                 GL11.glColor3f(.7f,.3f,.2f);
00068                 //GL11.glEnable(GL11.GL_LIGHTING);
00069                 //GLUtil.greyMaterial();
00070                 GL11.glPolygonOffset(1,1);
00071                 GLUtil.renderQuad(-w/2,-h/2, w/2, h/2);
00072                 GL11.glPolygonOffset(0,0);              
00073                 //GL11.glDisable(GL11.GL_LIGHTING);
00074                 
00075                 if (target!=null){
00076                         GL11.glColor3f(1,0,0);
00077                         
00078                         GL11.glTranslatef(target.x, target.y, target.z);
00079                         GLBoxRenderer.renderBox(5,5,200);
00080                 }
00081                 
00082         }
00083 }

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