本文整理汇总了Java中com.jogamp.opengl.GL2.glTranslatef方法的典型用法代码示例。如果您正苦于以下问题:Java GL2.glTranslatef方法的具体用法?Java GL2.glTranslatef怎么用?Java GL2.glTranslatef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jogamp.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glTranslatef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void render(GL2 gl) {
final float alpha = .2f;
glu.gluQuadricDrawStyle(quad, GLU.GLU_FILL);
int off = (1 << (subunitSubsamplingBits)) / 2;
for (int x = 0; x < nx; x++) {
for (int y = 0; y < ny; y++) {
gl.glPushMatrix();
gl.glTranslatef((x << subunitSubsamplingBits) + off, (y << subunitSubsamplingBits) + off, 5);
if ((x == (nx / 2)) || (x == ((nx / 2) - 1))) {
gl.glColor4f(1, 0, 0, alpha);
} else {
gl.glColor4f(0, 1, 0, alpha);
}
glu.gluDisk(quad, 0, subunitActivityBlobRadiusScale *synapticWeight* subunits[x][y].computeInputToCell(), 16, 1);
gl.glPopMatrix();
}
}
renderer.begin3DRendering();
renderer.setColor(0, 1, 0, 1);
renderer.draw3D("Center", 0, chip.getSizeY(), 0, .5f);
renderer.setColor(1, 0, 0, 1);
renderer.draw3D("Surround", chip.getSizeX() / 2, chip.getSizeY(), 0, .5f);
renderer.end3DRendering();
}
示例2: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws the beat on the cluster location.
*
* @param drawable the GL drawable to draw on.
*/
public void draw(GLAutoDrawable drawable) {
if (isDoneRendering()) {
return;
}
GL2 gl = drawable.getGL().getGL2(); // when we get this we are already set up with scale 1=1 pixel, at LL corner
gl.glPushMatrix();
gl.glColor3f(0, 1, 0); // green
gl.glLineWidth(3); // will get scaled
final int pos = 10;
final String beatString = string;
// render string at location of cluster. size of string is sized to match cluster size
float sw = glut.glutStrokeLength(GLUT.STROKE_ROMAN, beatString); // length in model space
float cw = cluster.getRadius() ; // cluster size (actually radius, to make string half total width)
float scale = cw / sw; // scaling to make string come out size of cluster /2
// set origin to put string centered on cluster
gl.glTranslatef(location.x - (cw/2), location.y, 0);
gl.glScalef(scale, scale, 1); // scale transform to make string right size
glut.glutStrokeString(GLUT.STROKE_ROMAN, beatString); // stroke the string
gl.glPopMatrix();
framesLeftToRender--; // decrease counter for rendering
}
示例3: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
void draw(GL2 gl) {
gl.glPushMatrix();
gl.glTranslatef(location.x, location.y, 0);
gl.glLineWidth(2);
gl.glColor3f(1, 1, 1);
gl.glPointSize(4);
gl.glBegin(GL.GL_POINTS);
gl.glVertex2f(0, 0);
gl.glEnd();
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(0, 0);
Point2D.Float p = filter.getValue2d();
gl.glVertex2f(p.x * vectorScalingPixelsPerPPS, p.y * vectorScalingPixelsPerPPS);
gl.glEnd();
gl.glPopMatrix();
}
示例4: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2(); // get the OpenGL 2 graphics context
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
gl.glLoadIdentity(); // reset the model-view matrix
gl.glTranslatef(0.0f, 0.0f, -15.0f); // translate into the screen
gl.glScaled(15, 15, 15);
gl.glRotated(angleY, 0, 1, 0);
//Draw Bunny Model
bunny.draw(g);
//Draw Bounding Box
gl.glColor3f(0, 1, 1);
//g.drawBoundingBox(bunnyVBO.getBoundingBox());
renderOctree(g, octree);
//Rotate Model
if (rotate) {
angleY += 1;
}
}
示例5: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2(); // get the OpenGL 2 graphics context
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
gl.glLoadIdentity(); // reset the model-view matrix
gl.glTranslatef(0.0f, 0.0f, -5.0f); // translate into the screen
gl.glScaled(2, 2, 2);
gl.glRotated(angleY, 0, 1, 0);
g.drawFrustrum(frustrum);
//Draw Bunny Model
bunny.draw(g);
//Draw Bounding Box
gl.glColor3f(0, 1, 1);
renderOctree(g, octree);
//Rotate Model
if(rotate) {
angleY += 1;
}
}
示例6: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
GLUT cGLUT = chip.getCanvas().getGlut();
final int font = GLUT.BITMAP_HELVETICA_12;
gl.glColor3f(1, 1, 1);
cGLUT.glutBitmapString(font, toString()); // annotate
gl.glRasterPos3f(location.x, location.y, 0);
float amplitude = 1000 * getAmplitude();
float phase = getPhase(0);
gl.glPushMatrix();
gl.glTranslatef(location.x, location.y, 0);
gl.glLineWidth(3);
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(0, 0);
gl.glVertex2d(amplitude * Math.cos(phase), amplitude * Math.sin(phase));
gl.glEnd();
gl.glPopMatrix();
}
示例7: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) { //shows the class in the jAER window
if ((drawable == null) || (chip.getCanvas() == null) || !classifyEvents || model == null) {
return;
}
titleRenderer = new TextRenderer(new Font("Helvetica", Font.PLAIN, 40));
Rectangle2D bounds = titleRenderer.getBounds("Unkown");
titleArea = new Rectangle((int) bounds.getWidth(), (int) bounds.getHeight());
GL2 gl = drawable.getGL().getGL2();
gl.glColor3f(1, 1, 1);
gl.glRasterPos3f(10, 10, 0);
titleRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
titleRenderer.setColor(Color.WHITE);
titleRenderer.draw(String.format("Class: %d", labeledClass), titleArea.x, titleArea.y);
titleRenderer.endRendering();
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glTranslatef(drawable.getSurfaceWidth() / 2, drawable.getSurfaceHeight() / 2, 0);
gl.glColor3f(1, 1, 1);
float w = drawable.getSurfaceWidth() * lastdot * 5;
gl.glRectf(0, -10, w, 10);
gl.glPopMatrix();
}
示例8: glTransform
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public synchronized void glTransform(GLAutoDrawable drawable,GL2 gl) {
drawableWidth = drawable.getSurfaceWidth ();
drawableHeight= drawable.getSurfaceHeight();
//FIXME scale better when trace is wider than high
// move pixels to one side when traces are to be displayed
if (showTraces) {
if ((drawableWidth/chip.getSizeX()) > (drawableHeight/chip.getSizeY())) {
broaderThanHigh= true;
// draw chip canvas on the right
gl.glTranslatef( (.4f * (drawableWidth-drawableHeight) *
chip.getSizeY())/drawableHeight,0f,0f );
} else {
broaderThanHigh= false;
// not implemented (highly unlikely)
}
}
float dx= x2-x1;
float dy= y2-y1;
gl.glScalef(chip.getSizeX()/Math.max(dx, dy),
chip.getSizeY()/Math.max(dx, dy),1f);
gl.glTranslatef(currentX()-x1, currentY()-y1, 0f);
}
示例9: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
public void draw(GL2 gl) {
if ((maxvalue <= 0) || Float.isNaN(ballX) || Float.isNaN(ballY)) {
return;
}
gl.glColor4f(0, .4f, 0, .2f);
if (quad == null) {
quad = glu.gluNewQuadric();
}
gl.glPushMatrix();
gl.glTranslatef(ballX, ballY, 0);
glu.gluQuadricDrawStyle(quad, GLU.GLU_FILL);
gl.glLineWidth(2f);
glu.gluDisk(quad, 0, ballRadiusPixels, 16, 1);
gl.glPopMatrix();
}
示例10: showSpike
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/**
* draws a circle at pixel x,y of size+.5 radius. size is used to indicate
* number of spikes in this 'frame'
*/
protected void showSpike(final GL2 gl, final int x, final int y, int size) {
// circle
gl.glPushMatrix();
gl.glColor4f(0, 0, 1f, 0f);
if (size > (chip.getMinSize() / 3)) {
size = chip.getMinSize() / 3;
}
gl.glTranslatef(x, y, -1);
selectedQuad = glu.gluNewQuadric();
glu.gluQuadricDrawStyle(selectedQuad, GLU.GLU_FILL);
glu.gluDisk(selectedQuad, size, size + 1, 16, 1);
glu.gluDeleteQuadric(selectedQuad);
gl.glPopMatrix();
final int font = GLUT.BITMAP_HELVETICA_18;
gl.glPushMatrix();
final int FS = 1; // distance in pixels of text from selected pixel
gl.glRasterPos3f(x + FS, y + FS, 0);
glut.glutBitmapString(font, x + "," + y);
gl.glPopMatrix();
checkGLError(gl, glu, "showSpike");
}
示例11: display
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void display(Graphics3D graphics) {
AWTGraphics3D g = (AWTGraphics3D) graphics;
GL2 gl = g.getGL2(); // get the OpenGL 2 graphics context
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // clear color and depth buffers
gl.glLoadIdentity(); // reset the model-view matrix
gl.glTranslatef(0.0f, 0.0f, -6.0f); // translate into the screen
gl.glColor3f(1, 1, 1); //set the triangle color
gl.glBegin(GL.GL_TRIANGLES); // draw using triangles
gl.glVertex3f(0.0f, 1.0f, 0.0f);
gl.glVertex3f(-1.0f, -1.0f, 0.0f);
gl.glVertex3f(1.0f, -1.0f, 0.0f);
gl.glEnd();
}
示例12: annotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
@Override
public void annotate(GLAutoDrawable drawable) {
super.annotate(drawable);
GL2 gl = drawable.getGL().getGL2();
gl.glPushMatrix();
gl.glTranslatef(chip.getSizeX() / 2, chip.getSizeY() / 2, 10);
if (showOutputCell && (objectMotionCellModel.nSpikes > getIntegrateAndFireThreshold())) {
gl.glColor4f(1, 1, 1, .2f);
glu.gluQuadricDrawStyle(quad, GLU.GLU_FILL);
float radius = (chip.getMaxSize() * objectMotionCellModel.spikeRateHz) / maxSpikeRateHz / 2;
glu.gluDisk(quad, 0, radius, 32, 1);
objectMotionCellModel.resetSpikeCount();
}
gl.glPopMatrix();
if (showSubunits) {
gl.glColor4f(0, 1, 0, .3f);
gl.glRectf(-10, 0, -5, barsHeight*inhibition);
gl.glColor4f(1, 0, 0, .3f);
gl.glRectf(-20, 0, -15, barsHeight*centerExcitation);
renderer.begin3DRendering();
renderer.setColor(0, 1, 0, .3f);
renderer.draw3D("sur", -10, -3, 0, .4f);
renderer.setColor(1, 0, 0, .3f);
renderer.draw3D("cen", -20, -3, 0, .4f);
renderer.end3DRendering();
// render all the subunits now
subunits.render(gl);
}
}
示例13: drawReceptiveField
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Draws the neuron using OpenGL.
*
* @param drawable area to drawReceptiveField this.
*/
public void drawReceptiveField(GLAutoDrawable drawable) {
final float BOX_LINE_WIDTH = 2f; // in chip
GL2 gl = drawable.getGL().getGL2();
// set color and line width
gl.glColor3fv(rgb, 0);
gl.glLineWidth(BOX_LINE_WIDTH);
// draws the receptive field of a neuron
gl.glPushMatrix();
gl.glTranslatef((int) getLocation().x, (int) getLocation().y, 0);
if (filledReceptiveField) {
gl.glBegin(GL2.GL_QUADS);
} else {
gl.glBegin(GL.GL_LINE_LOOP);
}
int halfSize = receptiveFieldSize / 2;
gl.glVertex2i(-halfSize, -halfSize);
gl.glVertex2i(+halfSize, -halfSize);
gl.glVertex2i(+halfSize, +halfSize);
gl.glVertex2i(-halfSize, +halfSize);
gl.glEnd();
gl.glPopMatrix();
}
示例14: draw
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
private void draw(GLAutoDrawable drawable, GL2 gl, float linewidth) {
// if (getTargetLocation() != null && getTargetLocation().location == null) {
// textRenderer.beginRendering(drawable.getSurfaceWidth(), drawable.getSurfaceHeight());
// textRenderer.draw("Target not visible", chip.getSizeX() / 2, chip.getSizeY() / 2);
// textRenderer.endRendering();
// return;
// }
gl.glPushMatrix();
gl.glTranslatef(location.x, location.y, 0f);
float[] compArray = new float[4];
gl.glColor3fv(targetTypeColors[targetClassID % targetTypeColors.length].getColorComponents(compArray), 0);
// gl.glColor4f(0, 1, 0, .5f);
gl.glLineWidth(linewidth);
gl.glBegin(GL.GL_LINE_LOOP);
gl.glVertex2f(-width / 2, -height / 2);
gl.glVertex2f(+width / 2, -height / 2);
gl.glVertex2f(+width / 2, +height / 2);
gl.glVertex2f(-width / 2, +height / 2);
gl.glEnd();
// if (mouseQuad == null) {
// mouseQuad = glu.gluNewQuadric();
// }
// glu.gluQuadricDrawStyle(mouseQuad, GLU.GLU_LINE);
// //glu.gluDisk(mouseQuad, getTargetRadius(), getTargetRadius(), 32, 1);
// int maxDim = Math.max(width, height);
// glu.gluDisk(mouseQuad, maxDim / 2, (maxDim / 2) + 0.1, 32, 1);
//getTargetRadius(), getTargetRadius() + 1, 32, 1);
gl.glPopMatrix();
}
示例15: glAnnotate
import com.jogamp.opengl.GL2; //导入方法依赖的package包/类
/** Shows the transform on top of the rendered events.
*
* @param gl the OpenGL context.
*/
private void glAnnotate(GL2 gl) {
// this whole annotation is translated by the enclosing filter SceneStabilizer so that
// clusters appear on top of tracked features.
int sx2 = chip.getSizeX() / 2, sy2 = chip.getSizeY() / 2;
// draw translation
gl.glPushMatrix();
gl.glTranslatef(-translation.x + sx2, -translation.y + sy2, 0);
gl.glRotatef((float) ((-rotationAngle * 180) / Math.PI), 0, 0, 1);
// gl.glTranslatef(sx2, sy2, 0);
// draw translation
gl.glLineWidth(2f);
gl.glColor3f(0, 1, 1);
gl.glBegin(GL.GL_LINES);
gl.glVertex2f(-sx2, 0);
gl.glVertex2f(sx2, 0);
gl.glVertex2f(0, -sy2);
gl.glVertex2f(0, sy2);
gl.glEnd();
gl.glPopMatrix();
if (isUseVelocity()) {
gl.glBegin(GL.GL_LINES);
float x = (velocityPPt.x / 10) + sx2, y = (velocityPPt.y / 10) + sy2;
gl.glVertex2f(sx2, sy2);
gl.glVertex2f(x, y);
gl.glEnd();
}
}