/**
* Returns the actual position of the camera.
* @return Array containing the x-, y- and z-coordinate if the cameraposition
*/
public double[] getCamPos()
{
return this.camPos;
}
/**
* Locates the actual centerpoint and stores it in centerX, centerY and centerZ.
*/
public void locateCenterPoint()
{
this.glu = this.drawable.getGLU();
glu.gluProject(this.worldX[0],this.worldY[0],this.worldZ[0],model_view,projection,viewport,this.centerX,this.centerY,this.centerZ);
}
public void setMousePosition(int x, int y)
{
this.mouseX = x;
this.mouseY = y;
}
private void drawTargets()
{
if(!(this.targetContainerList.isEmpty())) //container available
{
for(int j=0;j<this.targetContainerList.size();j++) //display content of every targetcontainer
{
this.targetContainer = (TargetContainer) this.targetContainerList.get(j);
for (int targetNr=0;targetNr<this.targetContainer.getContainerSize();targetNr++) //display every target contained in the targetcontainer
{
this.target = (Target)this.targetContainer.getData(targetNr);
this.range = target.getRange()/maxRange;
this.azimuth = 360-target.getAzimut()/(65535/360);
this.color = target.getColor();
this.elevation = target.getElevationnumber();
target.setTimeToLive(target.getTimeToLive()-1);
this.ttl = target.getTimeToLive();
gl.glLoadIdentity();
gl.glTranslated(sceneCenterPoint[0],sceneCenterPoint[1],sceneCenterPoint[2]);
gl.glRotated(this.azimuth, 0, 0, 1.0);
gl.glTranslated(this.range, 0.0,elevation);
this.color[3] = this.color[3]-this.color[3]/ttl;
gl.glLoadName(this.id);
this.id++;
gl.glBegin(GL.GL_QUADS);
//gl.glColor3dv(color);
gl.glColor4d(0.0,0.0,1.0,color[3]);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.015*clipSize,-0.005*clipSize);
//**************************************
gl.glColor4d(0.0,1.0,0.0,color[3]);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,-0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,-0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,+0.005*clipSize,0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,-0.005*clipSize);
gl.glVertex3d(-0.015*clipSize,-0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,+0.005*clipSize);
gl.glVertex3d(+0.015*clipSize,+0.005*clipSize,-0.005*clipSize);
//**************************************
gl.glColor4d(1.0,0.0,0.0,color[3]);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,+0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,-0.015*clipSize);
gl.glVertex3d(+0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glVertex3d(-0.005*clipSize,-0.005*clipSize,+0.015*clipSize);
gl.glEnd();
gl.glFlush();
if (this.ttl < 500)
{
this.targetContainer.removeData(target);
}
}
}
}
}
private void processHits()
{
}
public void select()
{
if (this.pick)
{
int selectBuf[] = new int[BUFSIZE];
this.gl.glGetIntegerv(GL.GL_VIEWPORT,this.viewport);
this.gl.glSelectBuffer(BUFSIZE,selectBuf);
//Puts OpenGL In Selection Mode. Nothing Will Be Drawn. Object ID's and Extents Are Stored In The Buffer.
this.gl.glRenderMode(GL.GL_SELECT);
this.gl.glInitNames(); // Initializes The Name Stack
this.gl.glPushName(0); // Push 0 (At Least One Entry) Onto The Stack
this.gl.glMatrixMode(GL.GL_PROJECTION); // Selects The Projection Matrix
this.gl.glPushMatrix(); // Push The Projection Matrix
this.gl.glLoadIdentity(); // Resets The Matrix
//This Creates A Matrix That Will Zoom Up To A Small Portion Of The Screen, Where The Mouse Is.
this.glu.gluPickMatrix( this.mouseX, (viewport[3]-this.mouseY), 5.0, 5.0, viewport);
//Apply The ortho Matrix
this.gl.glOrtho(-clipSize,+clipSize,-clipSize,+clipSize,-clipSize*100,+clipSize*100);
this.id = 0;
drawTargets();
this.gl.glPopMatrix();
this.gl.glFlush();
hits = gl.glRenderMode(GL.GL_RENDER);
System.out.println("HITS = " + hits);
}
setPick(false);
}