00001 package org.hfbk.vis.visnode;
00002
00003 import java.io.BufferedReader;
00004 import java.io.File;
00005 import java.io.FileNotFoundException;
00006 import java.io.FileReader;
00007 import java.io.IOException;
00008 import java.util.LinkedList;
00009 import java.util.List;
00010
00011 import org.dronus.graph.Node;
00012 import org.lwjgl.opengl.GL11;
00013 import org.lwjgl.util.vector.Vector3f;
00014
00015 public class VisFrame extends VisNode{
00016
00017 int dl;
00018 float tx,ty,tz,maxx,maxz,minx,minz;
00019
00020 List<List<Vector3f>> walls=new LinkedList<List<Vector3f>>();
00021 List<Vector3f> markers=new LinkedList<Vector3f>();
00022
00023 String mapfile="salon.coord";
00024
00025 public VisFrame(Node node, Vector3f position) {
00026
00027 super(node,position);
00028
00029 if (node.text.length()>0)
00030 mapfile=node.text;
00031
00032 loadWalls();
00033
00034 radius=2000;
00035
00036 }
00037
00038
00039 private void loadWalls() {
00040
00041 try {
00042 BufferedReader r=new BufferedReader(new FileReader(new File(mapfile)));
00043 String l;
00044 maxx=-100000;maxz=-100000;
00045 minx=100000;minz=100000;
00046 do{
00047
00048 List<Vector3f> currentWall=new LinkedList<Vector3f>();
00049
00050 walls.add(currentWall);
00051
00052 while ((l=r.readLine())!=null){
00053 if (l.equals(""))
00054 break;
00055 else{
00056 String[] coords=l.split(" ");
00057
00058 if (coords[0].equals("M"))
00059 {
00060 markers.add(new Vector3f(Float.parseFloat(coords[1]),
00061 Float.parseFloat(coords[2]),
00062 Float.parseFloat(coords[3])
00063 ));
00064 }
00065 else
00066 {
00067 tx=Float.parseFloat(coords[0])/2;
00068 ty=Float.parseFloat(coords[1])/2;
00069 tz=Float.parseFloat(coords[2])/2;
00070
00071
00072 minx=Math.min(tx,minx);
00073
00074 maxx=Math.max(tx,maxx);
00075
00076
00077 minz=Math.min(tz,minz);
00078 maxz=Math.max(tz,maxz);
00079
00080 currentWall.add( new Vector3f(tx,ty,tz
00081 ));
00082
00083
00084 }
00085 }
00086 }
00087 }while(l!=null);
00088 System.out.println(minz+" "+maxz+" "+minx+" "+maxx);
00089
00090
00091 } catch (FileNotFoundException e) {
00092 e.printStackTrace();
00093 } catch (NumberFormatException e) {
00094
00095 e.printStackTrace();
00096 } catch (IOException e) {
00097
00098 e.printStackTrace();
00099 }
00100
00101
00102 }
00103
00104 @Override
00105 void transform() {
00106 super.transform();
00107
00108 GL11.glTranslatef(0,-5,0);
00109 }
00110
00111 @Override
00112 void renderSelf() {
00113
00114 if (dl==0){
00115 dl=GL11.glGenLists(1);
00116 GL11.glNewList(dl, GL11.GL_COMPILE);
00117 GL11.glDisable(GL11.GL_TEXTURE_2D);
00118
00119 GL11.glColor4f(1,1,1,.5f);
00120 for (List<Vector3f>wall : walls){
00121
00122 if (wall.size()>4)
00123 {
00124 GL11.glBegin(GL11.GL_LINE_STRIP);
00125
00126
00127 for (Vector3f segment: wall)
00128 GL11.glVertex3f(segment.x,segment.z,0);
00129 GL11.glEnd();
00130 }
00131
00132 }
00133
00134 GL11.glBegin(GL11.GL_LINES);
00135 for (Vector3f segment: markers){
00136 GL11.glVertex3f(segment.x, segment.y,segment.z);
00137 GL11.glVertex3f(segment.x, segment.y+50,segment.z);
00138 }
00139 GL11.glEnd();
00140
00141
00142
00143
00144 GL11.glDisable(GL11.GL_LIGHTING);
00145 GL11.glEndList();
00146 }
00147 GL11.glCallList(dl);
00148 }
00149 }