1-In This Project You Will Create A Unique 3 Scene
1-In This Project You Will Create A Unique 3 Scene
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
home / study / engineering / computer science / computer science questions and answers / in this project you will create a unique 3 scene compo…
Question: In this project you will create a unique 3 scene composed of O… Post a question
Answers from our experts for your tough
homework questions
See this question in the app
Enter question
(3 bookmarks)
In this project you will create a unique 3 scene composed of OpenGL graphic components using
transformation methods.
Requirements: Continue to post
1. Using Netbeans or Eclipse, develop a JOGL application that displays a unique 3D scene. The scene has
20 questions remaining
the following speci cations:
a. Size: 640x480
b. Includes at least 6 different shapes
c. Uses at least 6 different transformation methods My Textbook Solutions
2. Use Java and JOGL for your implementation of OpenGL
3. All Java source code should be written using Google Java style guide.
4. Prepare, conduct and document a test plan verifying each method is functioning properly. (Hint: Using
JUNIT tests are recommended)
Introductio... The...
Expert Answer 2nd Edition 4th Edition
My3DScene.java:
Matthew Z.
967
University of Colora…
Nivita A.
10
Columbia University
Piyush A.
456
Indian Institute Of E…
Find me a tutor
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
MyShapes.java
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
Output:
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
TUTORS CHAT /
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
Code to copy:
MY3DScene.java:
// My3DScene.java
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.GLJPanel;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@SuppressWarnings("serial")
public class My3DScene extends JPanel implements GLEventListener
{
private MyShapes myShapes = new MyShapes(); // An instance of the MyShpaes class containing all the
shapes that I have drawn.
private int frameNumber; // Current frame number, increases by 1 in each frame.
private Timer animationTimer;
public My3DScene()
{
GLCapabilities caps = new GLCapabilities(null);
gl2.glClearDepth(1.0f);
gl2.glDepthFunc(GL2.GL_LEQUAL);
gl2.glHint(GL2.GL_PERSPECTIVE_CORRECTION_HINT, GL2.GL_NICEST);
//turn transparency on
gl2.glEnable(GL2.GL_BLEND);
gl2.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
@SuppressWarnings("static-access")
public void display(GLAutoDrawable drawable)
{
GL2 gl2 = drawable.getGL().getGL2();
gl2.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); // need depth buffer for 3D.
gl2.glLoadIdentity();
/* Draw the 3D Triangle. The drawTriangle method draws the shape with the center at (0,0).
* The image will be rotating in an in nite loop about the z-axis
* It will be uniformly scaled by 1.5 so that it's displayed proportionally on the window.
* It will be rotated 90 degrees about the line through the points (0,0,0) and (5,5,5).
* A translation is applied to move the triangle to the coordinate (-6,5,0).
*/
gl2.glPushMatrix();
gl2.glLineWidth(2);
gl2.glTranslated(-6.0,5.0,0);
gl2.glRotated(90,1.5,2,-3);
gl2.glScaled(1.5,1.5,1.5);
gl2.glRotated(frameNumber*0.7,0,0,1);
myShapes.drawTriangle(gl2);
gl2.glPopMatrix();
gl2.glPushMatrix();
gl2.glLineWidth(2);
gl2.glTranslated(-12 + 24*(frameNumber % 500) / 500.0, 0, 0);
gl2.glRotated(45,1.5,-2,3);
gl2.glScaled(.275,.275,.275);
gl2.glRotated(-frameNumber*0.7,0,1,0);
myShapes.drawPlusSymbol(gl2);
gl2.glPopMatrix();
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height){
MyShapes.java:
//MyShapes.java
import com.jogamp.opengl.GL2;
// Front side
gl2.glColor3f( 1.0f, 0.0f, 0.0f ); // Red
gl2.glVertex3f( 0f, 1.5f, 0.0f ); // Top Of Triangle (Front)
// Back side
gl2.glColor3f( 1.0f, 0.0f, 0.0f ); // Red
gl2.glVertex3f( 0f, 1.5f, 0.0f ); // Top Of Triangle (Back)
//Left side
gl2.glColor3f( 1.0f, 0.0f, 0.0f ); // Red
gl2.glVertex3f( 0f, 1.5f, 0.0f ); // Top Of Triangle (Left)
//Will use a GL_LINE_LOOP in order to outline the edges of the square in black
gl2.glColor3d(0,0,0); //black
gl2.glBegin(GL2.GL_LINE_LOOP);
gl2.glVertex3d(-0.5, -0.5, 0.5);
gl2.glVertex3d(0.5, -0.5, 0.5);
gl2.glVertex3d(0.5, 0.5, 0.5);
gl2.glVertex3d(-0.5, 0.5, 0.5);
gl2.glEnd();
}
// Creates a 3D cube using the square method to create each of the 6 sides.
gl2.glPushMatrix();
gl2.glRotated(90, 0, 1, 0); //Right face
square(gl2);
gl2.glPopMatrix();
gl2.glPushMatrix();
gl2.glRotated(-90, 1, 0, 0); //Top face
square(gl2);
TUTORS CHAT /
gl2.glPopMatrix();
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
gl2.glPushMatrix();
gl2.glRotated(180, 0, 1, 0); //Back face
square(gl2);
gl2.glPopMatrix();
gl2.glPushMatrix();
gl2.glRotated(-90, 0, 1, 0); //Left face
square(gl2);
gl2.glPopMatrix();
gl2.glPushMatrix();
gl2.glRotated(90, 1, 0, 0); //Bottom face
square(gl2);
gl2.glPopMatrix();
gl2.glFlush();
}
//Creates a transparent 3D cylinder with a given radius, number of slices, number of stacks, and number of
rings.
public static void drawCylinder(GL2 gl2, double radius, double height, int slices, int stacks, int rings)
{
for (int j = 0; j < stacks; j++)
{
double z1 = (height/stacks) * j;
double z2 = (height/stacks) * (j+1);
gl2.glBegin(GL2.GL_QUAD_STRIP);
for (int i = 0; i <= slices; i++)
{
double longitude = (2*Math.PI/slices) * i;
double sinLong = Math.sin(longitude);
double cosLong = Math.cos(longitude);
double x = cosLong;
double y = sinLong;
gl2.glNormal3d(x,y,0);
gl2.glNormal3d(0,0,-1);
for (int j = 0; j < rings; j++)
{
double d1 = (1.0/rings) * j;
double d2 = (1.0/rings) * (j+1);
gl2.glBegin(GL2.GL_QUAD_STRIP);
for (int i = 0; i <= slices; i++)
{
double angle = (2*Math.PI/slices) * i;
double sin = Math.sin(angle);
double cos = Math.cos(angle);
gl2.glVertex3d(radius*cos*d1,radius*sin*d1,0);
} TUTORS CHAT /
gl2.glEnd();
}
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
}
gl2.glFlush();
}
gl2.glPushMatrix();
gl2.glBegin(GL2.GL_TRIANGLE_FAN);
for (int j = 0; j < faces[i].length; j++)
{
int vertexNum = faces[i][j];
gl2.glVertex3dv( vertices[vertexNum], 0 );
}
gl2.glEnd();
}
gl2.glPopMatrix();
gl2.glFlush();
}
gl2.glPushMatrix();
gl2.glBegin(GL2.GL_TRIANGLE_FAN);
for (int j = 0; j < faces[i].length; j++)
{
int vertexNum = faces[i][j];
gl2.glVertex3dv( vertices[vertexNum], 0 );
}
gl2.glEnd();
}
// each face color will have a 4th column to indicate the level of transparency.
double[][] faceColors = new double[][] {
{1, 0, 0, 0.4},
{0, 1, 0, 0.4},
{0, 0, 1, 0.4},
{1, 1, 0, 0.4},
{0, 1, 1, 0.4},
{1, 0, 0, 0.4},
{0, 1, 0, 0.4},
{0, 0, 1, 0.4},
{1, 1, 0, 0.4},
{0, 1, 1, 0.4},
{1, 0, 0, 0.4},
{0, 1, 0, 0.4},
{0, 0, 1, 0.4},
{1, 1, 0, 0.4},
{0, 1, 1, 0.4},
{1, 0, 0, 0.4},
{0, 1, 0, 0.4},
{0, 0, 1, 0.4},
{1, 1, 0, 0.4},
{0, 1, 1, 0.4},
{0, 0, 1, 0.4},
};
gl2.glPushMatrix();
//color the faces of the tetrahedron
for (int i = 0; i < faces.length; i++)
{
gl2.glColor4dv(faceColors[i], 0 );
TUTORS CHAT /
gl2.glBegin(GL2.GL_TRIANGLE_FAN);
for (int j = 0; j < faces[i].length; j++) Solutions
NEW!
Textbook Expert Q&A Study Pack Practice Search
{
int vertexNum = faces[i][j];
gl2.glVertex3dv( vertices[vertexNum], 0 );
}
gl2.glEnd();
}
gl2.glPopMatrix();
gl2.glFlush();
}
};
gl2.glPushMatrix();
//color the faces of the diamond shape
for (int i = 0; i < faces.length; i++)
{
gl2.glColor3dv(faceColors[i], 0 );
TUTORS CHAT /
gl2.glBegin(GL2.GL_TRIANGLE_FAN);
NEW!
Textbook Solutions Expert Q&A Study Pack Practice Search
for (int j = 0; j < faces[i].length; j++)
{
int vertexNum = faces[i][j];
gl2.glVertex3dv( vertices[vertexNum], 0 );
}
gl2.glEnd();
}
gl2.glPopMatrix();
gl2.glFlush();
}
}
Comment
Q: In this project you will create a unique 3 graphics scene composed of OpenGL graphic components using
transformation methods. Requirements: 1. Using Netbeans or Eclipse, develop a JOGL application that displays a
unique 3D scene. The scene has the following speci cations: a. Size: minimum 640x480 b. Includes at least 6 different
shapes c. Uses at least 6 different transformation...
A: See answer
Q: Project 3 Three js Project Overview In this project you will create a unique 3D animated scene composed of Three.js
graphic components. The scene should include animation, lighting and multiple objects. Requirements: 1. Using
Three.js create a unique 3D animated scene. The scene has the following speci cations: a. Size: minimum of 640x480
b. Includes at least 6 different shapes c...
A: See answer
Q: home / study / engineering / computer science / computer science questions and answers / In This Project You Will
Create A Unique 3 Graphics Scene Composed Of OpenGL Graphic Components ... Your question has been answered
Let us know if you got a helpful answer. Rate this answer Question: In this project you will create a unique 3 graphics
scene composed of OpenGL graphic components...
Show more
ABOUT CHEGG
CUSTOMER SERVICE
TUTORS CHAT /