Java Code Examples for com.jogamp.opengl.GL2#glVertex3d()
The following examples show how to use
com.jogamp.opengl.GL2#glVertex3d() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
protected void renderTranslationHandle(GL2 gl2,Vector3d n) { // draw line to box gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(0,0,0); gl2.glVertex3d(n.x,n.y,n.z); gl2.glEnd(); // draw box Point3d b0 = new Point3d(+0.05,+0.05,+0.05); Point3d b1 = new Point3d(-0.05,-0.05,-0.05); b0.scale(1); b1.scale(1); b0.add(n); b1.add(n); PrimitiveSolids.drawBox(gl2, b0,b1); }
Example 2
Source File: Skycam.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
@Override public void render(GL2 gl2) { gl2.glPushMatrix(); MatrixHelper.applyMatrix(gl2, pose); Vector3d s = size.get(); Vector3d pos = getPosition(); Point3d bottom = new Point3d(pos.x-s.x/2,pos.y-s.y/2,pos.z); Point3d top = new Point3d(pos.x+s.x/2,pos.y+s.y/2,pos.z+s.z); PrimitiveSolids.drawBoxWireframe(gl2, bottom,top); Vector3d ep = ee.getPosition(); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(ep.x,ep.y,ep.z); gl2.glVertex3d(bottom.x,bottom.y,top.z); gl2.glVertex3d(ep.x,ep.y,ep.z); gl2.glVertex3d(bottom.x,top .y,top.z); gl2.glVertex3d(ep.x,ep.y,ep.z); gl2.glVertex3d(top .x,top .y,top.z); gl2.glVertex3d(ep.x,ep.y,ep.z); gl2.glVertex3d(top .x,bottom.y,top.z); gl2.glEnd(); gl2.glPopMatrix(); super.render(gl2); }
Example 3
Source File: MatrixHelper.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
/** * See drawMatrix(gl2,p,u,v,w,1) * @param gl2 * @param m * @param scale */ public static void drawMatrix2(GL2 gl2,Matrix4d m,double scale) { boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST); gl2.glDisable(GL2.GL_DEPTH_TEST); boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_LIGHTING); gl2.glPushMatrix(); gl2.glTranslated(m.m03,m.m13,m.m23); gl2.glScaled(scale, scale, scale); gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(1,1,0); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m00,m.m10,m.m20); // 1,1,0 = yellow gl2.glColor3f(0,1,1); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m01,m.m11,m.m21); // 0,1,1 = teal gl2.glColor3f(1,0,1); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m02,m.m12,m.m22); // 1,0,1 = magenta gl2.glEnd(); gl2.glPopMatrix(); if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING); if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST); }
Example 4
Source File: MatrixHelper.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
/** * See drawMatrix(gl2,p,u,v,w,1) * @param gl2 * @param m * @param scale */ public static void drawMatrix(GL2 gl2,Matrix4d m,double scale) { boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST); gl2.glDisable(GL2.GL_DEPTH_TEST); boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_LIGHTING); gl2.glPushMatrix(); gl2.glTranslated(m.m03,m.m13,m.m23); gl2.glScaled(scale, scale, scale); gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(1,0,0); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m00,m.m10,m.m20); // 1,0,0 = red gl2.glColor3f(0,1,0); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m01,m.m11,m.m21); // 0,1,0 = green gl2.glColor3f(0,0,1); gl2.glVertex3f(0,0,0); gl2.glVertex3d(m.m02,m.m12,m.m22); // 0,0,1 = blue gl2.glEnd(); gl2.glPopMatrix(); if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING); if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST); }
Example 5
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
static public void drawStar(GL2 gl2,Vector3d p,double size) { // save the current color double [] params = new double[4]; gl2.glGetDoublev(GL2.GL_CURRENT_COLOR, params, 0); boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2); int depth = OpenGLHelper.drawAtopEverythingStart(gl2); size/=2.0f; gl2.glPushMatrix(); gl2.glTranslated(p.x, p.y, p.z); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1, 0, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(size, 0, 0); gl2.glColor3d(0, 1, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, size, 0); gl2.glColor3d(0, 0, 1); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 0, size); gl2.glEnd(); gl2.glPopMatrix(); OpenGLHelper.drawAtopEverythingEnd(gl2,depth); OpenGLHelper.disableLightingEnd(gl2,lightWasOn); // restore color gl2.glColor4dv(params,0); }
Example 6
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 6 votes |
/** * draw box based on two corners * @param gl2 * @param bottom minimum bounds * @param top maximum bounds */ static public void drawBoxWireframe(GL2 gl2,Point3d bottom,Point3d top) { gl2.glDisable(GL2.GL_TEXTURE_2D); boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2); double x0=bottom.x; double y0=bottom.y; double z0=bottom.z; double x1=top.x; double y1=top.y; double z1=top.z; gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f( 0, 0,-1); gl2.glVertex3d(x0,y1,z0); gl2.glVertex3d(x1,y1,z0); gl2.glVertex3d(x1,y0,z0); gl2.glVertex3d(x0,y0,z0); gl2.glEnd(); // bottom gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f( 0, 0, 1); gl2.glVertex3d(x1,y1,z1); gl2.glVertex3d(x0,y1,z1); gl2.glVertex3d(x0,y0,z1); gl2.glVertex3d(x1,y0,z1); gl2.glEnd(); // top gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f( 0, 1, 0); gl2.glVertex3d(x0,y1,z1); gl2.glVertex3d(x1,y1,z1); gl2.glVertex3d(x1,y1,z0); gl2.glVertex3d(x0,y1,z0); gl2.glEnd(); // side gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f( 0,-1, 0); gl2.glVertex3d(x1,y0,z1); gl2.glVertex3d(x0,y0,z1); gl2.glVertex3d(x0,y0,z0); gl2.glVertex3d(x1,y0,z0); gl2.glEnd(); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f( 1, 0, 0); gl2.glVertex3d(x1,y1,z0); gl2.glVertex3d(x1,y1,z1); gl2.glVertex3d(x1,y0,z1); gl2.glVertex3d(x1,y0,z0); gl2.glEnd(); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glNormal3f(-1, 0, 0); gl2.glVertex3d(x0,y0,z1); gl2.glVertex3d(x0,y1,z1); gl2.glVertex3d(x0,y1,z0); gl2.glVertex3d(x0,y0,z0); gl2.glEnd(); OpenGLHelper.disableLightingEnd(gl2,lightWasOn); }
Example 7
Source File: Sixi2Live.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderCartesianForce(GL2 gl2) { double len = Math.sqrt( cartesianForceDetected[0]*cartesianForceDetected[0]+ cartesianForceDetected[1]*cartesianForceDetected[1]+ cartesianForceDetected[2]*cartesianForceDetected[2]); if(len<1) return; //System.out.println(len); int previousState = OpenGLHelper.drawAtopEverythingStart(gl2); boolean lightWasOn = OpenGLHelper.disableLightingStart(gl2); gl2.glLineWidth(4); double scale=1; gl2.glPushMatrix(); Matrix4d m4 = endEffector.getPoseWorld(); gl2.glTranslated(m4.m03, m4.m13, m4.m23); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(0, 0.6, 1); gl2.glVertex3d(0,0,0); gl2.glVertex3d( cartesianForceDetected[0]*scale, cartesianForceDetected[1]*scale, cartesianForceDetected[2]*scale); gl2.glColor3d(1.0, 0.5, 0.5); PrimitiveSolids.drawCircleYZ(gl2, cartesianForceDetected[3]*scale, 20); gl2.glColor3d(0.5, 1.0, 0.5); PrimitiveSolids.drawCircleXZ(gl2, cartesianForceDetected[4]*scale, 20); gl2.glColor3d(0.5, 0.5, 1.0); PrimitiveSolids.drawCircleXY(gl2, cartesianForceDetected[5]*scale, 20); gl2.glPopMatrix(); gl2.glLineWidth(1); OpenGLHelper.disableLightingEnd(gl2, lightWasOn); OpenGLHelper.drawAtopEverythingEnd(gl2, previousState); }
Example 8
Source File: Ray.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void render(GL2 gl2) { gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1,0,0); gl2.glVertex3d(start.x, start.y, start.z); gl2.glColor3d(0,1,0); gl2.glVertex3d( start.x+direction.x*50, start.y+direction.y*50, start.z+direction.z*50); }
Example 9
Source File: PoseEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
public void renderLineage(GL2 gl2) { boolean isTex = gl2.glIsEnabled(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_TEXTURE_2D); // save the lighting mode boolean lightWasOn = gl2.glIsEnabled(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_LIGHTING); IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); //boolean depthWasOn = gl2.glIsEnabled(GL2.GL_DEPTH_TEST); //gl2.glDisable(GL2.GL_DEPTH_TEST); gl2.glColor4d(1,1,1,1); gl2.glBegin(GL2.GL_LINES); // connection to children for(Entity e : children ) { if(e instanceof PoseEntity) { Vector3d p = ((PoseEntity)e).getPosition(); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(p.x,p.y,p.z); } } gl2.glEnd(); //if(depthWasOn) gl2.glEnable(GL2.GL_DEPTH_TEST); gl2.glDepthFunc(depthFunc.get()); // restore lighting if(lightWasOn) gl2.glEnable(GL2.GL_LIGHTING); if(isTex) gl2.glDisable(GL2.GL_TEXTURE_2D); }
Example 10
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
static public void drawCircleXZ(GL2 gl2,double radius,int steps) { double stepSize = Math.PI*2 / (double)(steps+1); gl2.glBegin(GL2.GL_LINE_LOOP); for(double n=0;n<Math.PI*2;n+=stepSize) { double c = Math.cos(n); double s = Math.sin(n); gl2.glVertex3d(c*radius,0, s*radius); } gl2.glEnd(); }
Example 11
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 5 votes |
static public void drawCircleYZ(GL2 gl2,double radius,int steps) { double stepSize = Math.PI*2 / (double)(steps+1); gl2.glBegin(GL2.GL_LINE_LOOP); for(double n=0;n<Math.PI*2;n+=stepSize) { double c = Math.cos(n); double s = Math.sin(n); gl2.glVertex3d(0,c*radius, s*radius); } gl2.glEnd(); }
Example 12
Source File: JPaddle.java From MeteoInfo with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0f, 0f, -2.0f); gl.glRotatef(rotation, 1f, 0f, 0f); gl.glColor3f(1f, 0f, 0f); gl.glBegin(GL2.GL_POLYGON); gl.glVertex3d(-0.5, 0.3, 0.8); gl.glVertex3d(0.5, 0.3, 0.8); gl.glVertex3d(0.8, 0.7, 0.8); gl.glVertex3d(-0.8, 0.7, 0.8); gl.glEnd(); int paddles = 40; for (int i = 0; i < paddles; i++) { gl.glRotated(360.0 / paddles, 1, 0, 0); gl.glBegin(GL2.GL_POLYGON); gl.glVertex3d(-0.5, 0.3, 0.8); gl.glVertex3d(0.5, 0.3, 0.8); gl.glVertex3d(0.8, 0.7, 0.8); gl.glVertex3d(-0.8, 0.7, 0.8); gl.glEnd(); } rotation -= 0.2f; }
Example 13
Source File: PrimitiveSolids.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
/** * draw box based on depth,width, and height with the origin in the bottom center. * @param gl2 * @param depth * @param width * @param height */ static public void drawBox(GL2 gl2,double depth,double width,double height) { width/=2; depth/=2; gl2.glPushMatrix(); gl2.glBegin(GL2.GL_QUADS); // bottom gl2.glNormal3f( 0, 0,-1); gl2.glVertex3d(-width, depth,0); gl2.glVertex3d( width, depth,0); gl2.glVertex3d( width,-depth,0); gl2.glVertex3d(-width,-depth,0); // top gl2.glNormal3f( 0, 0, 1); gl2.glVertex3d( width, depth,height); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d( width,-depth,height); // side gl2.glNormal3f( 0, 1, 0); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d( width, depth,height); gl2.glVertex3d( width, depth,0); gl2.glVertex3d(-width, depth,0); gl2.glNormal3f( 0,-1, 0); gl2.glVertex3d( width,-depth,height); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d(-width,-depth,0); gl2.glVertex3d( width,-depth,0); gl2.glNormal3f( 1, 0, 0); gl2.glVertex3d( width, depth,0); gl2.glVertex3d( width, depth,height); gl2.glVertex3d( width,-depth,height); gl2.glVertex3d( width,-depth,0); gl2.glNormal3f(-1, 0, 0); gl2.glVertex3d(-width,-depth,height); gl2.glVertex3d(-width, depth,height); gl2.glVertex3d(-width, depth,0); gl2.glVertex3d(-width,-depth,0); gl2.glEnd(); gl2.glPopMatrix(); }
Example 14
Source File: ViewCubeEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void render(GL2 gl2) { RobotOverlord ro = (RobotOverlord)getRoot(); ViewportEntity cameraView = ro.viewport; gl2.glClear(GL2.GL_DEPTH_BUFFER_BIT); gl2.glEnable(GL2.GL_DEPTH_TEST); gl2.glEnable(GL2.GL_CULL_FACE); gl2.glBlendFunc(GL2.GL_SRC_ALPHA,GL2.GL_ONE_MINUS_SRC_ALPHA); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glPushMatrix(); cameraView.renderOrtho(gl2,1); gl2.glMatrixMode(GL2.GL_MODELVIEW); gl2.glPushMatrix(); double c = cubeSize.get(); PoseEntity camera = cameraView.getAttachedTo(); Matrix4d m = camera.getPoseWorld(); Vector3d p = camera.getPosition(); Vector3d vx = MatrixHelper.getXAxis(m); Vector3d vy = MatrixHelper.getYAxis(m); Vector3d vz = MatrixHelper.getZAxis(m); vz.scale(-100); vx.scale(cameraView.getCanvasWidth() /10 -c*2); vy.scale(cameraView.getCanvasHeight()/10 -c*2); p.add(vx); p.add(vy); p.add(vz); gl2.glTranslated(p.x, p.y, p.z); gl2.glScaled(c,c,c); model.render(gl2); gl2.glDisable(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_COLOR_MATERIAL); gl2.glDisable(GL2.GL_TEXTURE_2D); // the big lines gl2.glLineWidth(4); gl2.glPushMatrix(); gl2.glTranslated(-1.05,-1.05,-0.95); gl2.glBegin(GL2.GL_LINES); gl2.glColor3d(1, 0, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(2.5, 0, 0); gl2.glColor3d(0, 1, 0); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 2.5, 0); gl2.glColor3d(0, 0, 1); gl2.glVertex3d(0, 0, 0); gl2.glVertex3d(0, 0, 2.5); gl2.glEnd(); gl2.glPopMatrix(); gl2.glLineWidth(1); gl2.glPopMatrix(); gl2.glMatrixMode(GL2.GL_PROJECTION); gl2.glPopMatrix(); gl2.glMatrixMode(GL2.GL_MODELVIEW); }
Example 15
Source File: DrawingPlugin.java From depan with Apache License 2.0 | 4 votes |
/** * Draw a node. */ @Override public boolean apply(NodeRenderingProperty property) { if (!property.isVisible) { return false; } GL2 gl = scene.gl; gl.glPushMatrix(); gl.glPushName(property.shapeId); // move property.shape.setTranslation(property.positionX * GLConstants.FACTOR, property.positionY * GLConstants.FACTOR, 0f); // scale property.shape.setScale(property.size, property.size * property.ratio, property.size); // fill the shape if (property.isFilled) { gl.glColor4f(property.fillColor.getRed() / 255f, property.fillColor.getGreen() / 255f, property.fillColor.getBlue() / 255f, property.fillColor.getAlpha() / 255f); property.shape.fill(gl); } // draw the border if (property.strokeWidth > 0.0f) { gl.glLineWidth(property.strokeWidth); gl.glColor4f(property.strokeColor.getRed() / 255f, property.strokeColor.getGreen() / 255f, property.strokeColor.getBlue() / 255f, property.strokeColor.getAlpha() / 255f); property.shape.draw(gl); } Rectangle2D bounds = property.shape.getDrawingBounds(); updateDrawingBounds(bounds); // we don't want the label to be clickable, // so we just pop the name before drawing it. gl.glPopName(); // draw the label if (property.isTextVisible) { paintLabel(property); } // draw a little "+" on the top right corner of the node if it has // nodes collapsed under. if (property.hasCollapsedNodeUnder) { double centerX = property.positionX+property.size/2; double centerY = property.positionY+property.size/2; double halfWidth = 0.7; double halfHeight = 4; gl.glBegin(GL2.GL_QUADS); gl.glColor4f(1f, 1f, 1f, 0.5f); // vertical line gl.glVertex2d(centerX - halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY + halfHeight); gl.glVertex2d(centerX + halfWidth, centerY - halfHeight); gl.glVertex2d(centerX - halfWidth, centerY - halfHeight); // left part of horizontal line gl.glVertex2d(centerX - halfHeight, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY + halfWidth); gl.glVertex2d(centerX - halfWidth, centerY - halfWidth); gl.glVertex2d(centerX - halfHeight, centerY - halfWidth); // right part. gl.glVertex2d(centerX + halfWidth, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY + halfWidth); gl.glVertex2d(centerX + halfHeight, centerY - halfWidth); gl.glVertex2d(centerX + halfWidth, centerY - halfWidth); gl.glVertex3d(0, 0, 0); gl.glEnd(); } gl.glPopMatrix(); return true; }
Example 16
Source File: SpideeLeg.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
void render(GL2 gl2,int color_index) { float [] colors = { 1,0,0, 0,1,0, 0,0,1, 1,1,0, 0,1,1, 1,0,1 }; //* gl2.glDisable(GL2.GL_LIGHTING); gl2.glColor3f(colors[color_index*3], colors[color_index*3+1], colors[color_index*3+2]); // last point of contact gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(lpoc.x+0.5f, lpoc.y-0.5f, 0); gl2.glVertex3d(lpoc.x+0.5f, lpoc.y+0.5f, 0); gl2.glVertex3d(lpoc.x-0.5f, lpoc.y+0.5f, 0); gl2.glVertex3d(lpoc.x-0.5f, lpoc.y-0.5f, 0); gl2.glEnd(); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(npoc.x-1.0f, npoc.y, 0); gl2.glVertex3d(npoc.x+1.0f, npoc.y, 0); gl2.glVertex3d(npoc.x, npoc.y-1.0f, 0); gl2.glVertex3d(npoc.x, npoc.y+1.0f, 0); gl2.glEnd(); // next point of contact gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(npoc.x+0.75f, npoc.y-0.75f, 0); gl2.glVertex3d(npoc.x+0.75f, npoc.y+0.75f, 0); gl2.glVertex3d(npoc.x-0.75f, npoc.y+0.75f, 0); gl2.glVertex3d(npoc.x-0.75f, npoc.y-0.75f, 0); gl2.glEnd(); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(ankle_joint.pos.x,ankle_joint.pos.y,ankle_joint.pos.z); gl2.glVertex3d(ankle_joint.pos.x,ankle_joint.pos.y,0); gl2.glEnd(); pan_joint.Draw(gl2,2); tilt_joint.Draw(gl2,1); knee_joint.Draw(gl2,3); gl2.glEnable(GL2.GL_LIGHTING); }
Example 17
Source File: DHBuilderApp.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
@Override public void render(GL2 gl2) { gl2.glPushMatrix(); MatrixHelper.applyMatrix(gl2, pose); anchor.render(gl2); if(!inTest) { for( int i=0;i<BONE_NAMES.length;++i) { models[i].render(gl2); } } else { links.get(0).render(gl2); } boolean showBones=false; if(showBones==true) { Vector3d p0 = MatrixHelper.getPosition(this.getPoseWorld()); for( int i=0;i<BONE_NAMES.length;++i) { Matrix4d m = links.get(i).getPoseWorld(); Vector3d p1 = MatrixHelper.getPosition(m); IntBuffer depthFunc = IntBuffer.allocate(1); gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc); gl2.glDepthFunc(GL2.GL_ALWAYS); gl2.glDisable(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_LIGHTING); gl2.glPushMatrix(); gl2.glColor3d(1, 1, 1); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(p0.x,p0.y,p0.z); gl2.glVertex3d(p1.x,p1.y,p1.z); gl2.glEnd(); p0=p1; gl2.glDepthFunc(depthFunc.get()); MatrixHelper.applyMatrix(gl2, m); PrimitiveSolids.drawStar(gl2, 15); gl2.glPopMatrix(); } } gl2.glPopMatrix(); // don't call super.render() }
Example 18
Source File: SkyBoxEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void render(GL2 gl2,CameraEntity camera) { //gl2.glDisable(GL2.GL_DEPTH_TEST); gl2.glDisable(GL2.GL_LIGHTING); gl2.glDisable(GL2.GL_COLOR_MATERIAL); gl2.glEnable(GL2.GL_TEXTURE_2D); gl2.glPushMatrix(); gl2.glColor3f(1, 1, 1); Vector3d p = camera.getPosition(); gl2.glTranslated(-p.x,-p.y,-p.z); skyboxtextureXPos.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,1); gl2.glVertex3d(10, 10, 10); gl2.glTexCoord2d(1,1); gl2.glVertex3d(10, -10, 10); gl2.glTexCoord2d(1,0); gl2.glVertex3d(10, -10, -10); gl2.glTexCoord2d(0,0); gl2.glVertex3d(10, 10, -10); gl2.glEnd(); skyboxtextureXNeg.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,1); gl2.glVertex3d(-10, -10, 10); gl2.glTexCoord2d(1,1); gl2.glVertex3d(-10, 10, 10); gl2.glTexCoord2d(1,0); gl2.glVertex3d(-10, 10, -10); gl2.glTexCoord2d(0,0); gl2.glVertex3d(-10, -10, -10); gl2.glEnd(); skyboxtextureYPos.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,1); gl2.glVertex3d(-10, 10, 10); gl2.glTexCoord2d(1,1); gl2.glVertex3d(10, 10, 10); gl2.glTexCoord2d(1,0); gl2.glVertex3d(10, 10, -10); gl2.glTexCoord2d(0,0); gl2.glVertex3d(-10, 10, -10); gl2.glEnd(); skyboxtextureYNeg.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,1); gl2.glVertex3d(10, -10, 10); gl2.glTexCoord2d(1,1); gl2.glVertex3d(-10, -10, 10); gl2.glTexCoord2d(1,0); gl2.glVertex3d(-10, -10, -10); gl2.glTexCoord2d(0,0); gl2.glVertex3d(10, -10, -10); gl2.glEnd(); skyboxtextureZPos.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,0); gl2.glVertex3d(-10, 10, 10); gl2.glTexCoord2d(1,0); gl2.glVertex3d( 10, 10, 10); gl2.glTexCoord2d(1,1); gl2.glVertex3d( 10,-10, 10); gl2.glTexCoord2d(0,1); gl2.glVertex3d(-10,-10, 10); gl2.glEnd(); skyboxtextureZNeg.render(gl2); gl2.glBegin(GL2.GL_TRIANGLE_FAN); gl2.glTexCoord2d(0,0); gl2.glVertex3d(-10,-10, -10); gl2.glTexCoord2d(1,0); gl2.glVertex3d( 10,-10, -10); gl2.glTexCoord2d(1,1); gl2.glVertex3d( 10, 10, -10); gl2.glTexCoord2d(0,1); gl2.glVertex3d(-10, 10, -10); gl2.glEnd(); gl2.glPopMatrix(); gl2.glEnable(GL2.GL_DEPTH_TEST); }
Example 19
Source File: DragBallEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void renderTranslation(GL2 gl2) { // camera forward is -z axis RobotOverlord ro = (RobotOverlord)getRoot(); PoseEntity camera = ro.viewport.getAttachedTo(); Vector3d lookAtVector = subject.getPosition(); lookAtVector.sub(camera.getPosition()); lookAtVector.normalize(); float r = (majorAxis==Axis.X) ? 1 : 0.5f; float g = (majorAxis==Axis.Y) ? 1 : 0.5f; float b = (majorAxis==Axis.Z) ? 1 : 0.5f; Vector3d fx = MatrixHelper.getXAxis(FOR); Vector3d fy = MatrixHelper.getYAxis(FOR); Vector3d fz = MatrixHelper.getZAxis(FOR); // should we hide an axis if it points almost the same direction as the camera? boolean drawX = (Math.abs(lookAtVector.dot(fx))<0.95); boolean drawY = (Math.abs(lookAtVector.dot(fy))<0.95); boolean drawZ = (Math.abs(lookAtVector.dot(fz))<0.95); if(drawX) { gl2.glColor3f(r,0,0); renderTranslationHandle(gl2,new Vector3d(1,0,0)); } if(drawY) { gl2.glColor3f(0,g,0); renderTranslationHandle(gl2,new Vector3d(0,1,0)); } if(drawZ) { gl2.glColor3f(0,0,b); renderTranslationHandle(gl2,new Vector3d(0,0,1)); } if(isActivelyMoving) { // the distance moved. gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(255,255,255); gl2.glVertex3d(0,0,0); gl2.glVertex3d( (startMatrix.m03-resultMatrix.m03)/ballSize.get(), (startMatrix.m13-resultMatrix.m13)/ballSize.get(), (startMatrix.m23-resultMatrix.m23)/ballSize.get()); gl2.glEnd(); } }
Example 20
Source File: ViewportEntity.java From Robot-Overlord-App with GNU General Public License v2.0 | 4 votes |
public void showPickingTest(GL2 gl2) { renderChosenProjection(gl2); gl2.glPushMatrix(); Ray r = rayPick(); double cx=cursorX; double cy=cursorY; int w = canvasWidth; int h = canvasHeight; setCursor(0,0); Ray tl = rayPick(); setCursor(w,0); Ray tr = rayPick(); setCursor(0,h); Ray bl = rayPick(); setCursor(w,h); Ray br = rayPick(); cursorX=cx; cursorY=cy; double scale=20; tl.direction.scale(scale); tr.direction.scale(scale); bl.direction.scale(scale); br.direction.scale(scale); r.direction .scale(scale); Vector3d tl2 = new Vector3d(tl.direction); Vector3d tr2 = new Vector3d(tr.direction); Vector3d bl2 = new Vector3d(bl.direction); Vector3d br2 = new Vector3d(br.direction); Vector3d r2 = new Vector3d(r.direction ); tl2.add(tl.start); tr2.add(tr.start); bl2.add(bl.start); br2.add(br.start); r2.add(r.start); gl2.glDisable(GL2.GL_TEXTURE_2D); gl2.glDisable(GL2.GL_LIGHTING); gl2.glColor3d(1, 0, 0); gl2.glBegin(GL2.GL_LINES); gl2.glVertex3d(tl.start.x, tl.start.y, tl.start.z); gl2.glVertex3d(tl2.x, tl2.y, tl2.z); gl2.glVertex3d(tr.start.x, tr.start.y, tr.start.z); gl2.glVertex3d(tr2.x, tr2.y, tr2.z); gl2.glVertex3d(bl.start.x, bl.start.y, bl.start.z); gl2.glVertex3d(bl2.x, bl2.y, bl2.z); gl2.glVertex3d(br.start.x, br.start.y, br.start.z); gl2.glVertex3d(br2.x, br2.y, br2.z); gl2.glColor3d(1, 1, 1); gl2.glVertex3d(r.start.x, r.start.y, r.start.z); gl2.glVertex3d(r2.x,r2.y,r2.z); gl2.glEnd(); gl2.glColor3d(0, 1, 0); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(tl2.x, tl2.y, tl2.z); gl2.glVertex3d(tr2.x, tr2.y, tr2.z); gl2.glVertex3d(br2.x, br2.y, br2.z); gl2.glVertex3d(bl2.x, bl2.y, bl2.z); gl2.glEnd(); gl2.glColor3d(0, 0, 1); gl2.glBegin(GL2.GL_LINE_LOOP); gl2.glVertex3d(tl.start.x, tl.start.y, tl.start.z); gl2.glVertex3d(tr.start.x, tr.start.y, tr.start.z); gl2.glVertex3d(br.start.x, br.start.y, br.start.z); gl2.glVertex3d(bl.start.x, bl.start.y, bl.start.z); gl2.glEnd(); PrimitiveSolids.drawStar(gl2,r2,5); gl2.glPopMatrix(); }