Java Code Examples for com.jogamp.opengl.GL2#glColor3d()

The following examples show how to use com.jogamp.opengl.GL2#glColor3d() . 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: PrimitiveSolids.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: Cuboid.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public void render(GL2 gl2) {
	gl2.glPushMatrix();
		//MatrixHelper.applyMatrix(gl2, poseWorld);

		IntBuffer depthFunc = IntBuffer.allocate(1);
		gl2.glGetIntegerv(GL2.GL_DEPTH_FUNC, depthFunc);
		gl2.glDepthFunc(GL2.GL_ALWAYS);
		
		boolean isLit = gl2.glIsEnabled(GL2.GL_LIGHTING);
		gl2.glDisable(GL2.GL_LIGHTING);
		
		gl2.glColor3d(255,255,255);
		PrimitiveSolids.drawBoxWireframe(gl2, getBoundsBottom(),getBoundsTop());

		if (isLit) gl2.glEnable(GL2.GL_LIGHTING);
		
		gl2.glDepthFunc(depthFunc.get());
	gl2.glPopMatrix();
}
 
Example 3
Source File: Ray.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
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 4
Source File: Sixi2Live.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
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 5
Source File: DHBuilderApp.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
@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 6
Source File: ViewportEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
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();
}
 
Example 7
Source File: ViewCubeEntity.java    From Robot-Overlord-App with GNU General Public License v2.0 4 votes vote down vote up
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);
}