Question: Learn the basics of how to use Blender to create a 3D object of your own. To make full use of Blender with your OpenGL

Learn the basics of how to use Blender to create a 3D object of your own. To make full use of Blender with your OpenGL applications, you’ll want to learn how to use Blender’s UV-unwrapping tools to generate texture coordinates and an associated texture image. You can then export your object as an OBJ file and load it using the code from Program 6.3.

Program 6.3ImportedModel class public class ImportedModel { private Vector3f[] vertices; private Vector2f[] texCoords;for(int i=0; iModellmporter nested class private class Modellmporter { // values as read in from OBJ file private ArrayList// values stored for later use as vertex attributes private ArrayList triangle Verts = new ArrayList ();{ for(Strings: (line.substring(3)).split("")) } } else if(line.startsWith("f"))} normals.add(normVals.get(normRef)); normals.add(normVals.get(normRef+1));// accessors for retrieving the number of vertices, the vertices themselves, // and the corresponding textureUsing the Model Importer myModel = new Imported Model("shuttle.obj"); private void setupVertices() { GL4 gl=for (int i=0; i} // VBO for vertex locations gl.glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); FloatBuffer vertBuf =in display(): gl.glDrawArrays(GL_TRIANGLES, 0, myModel.getNumVertices());

ImportedModel class public class ImportedModel { private Vector3f[] vertices; private Vector2f[] texCoords; private Vector3f[] normals; private int numVertices; public Imported Model(String filename) { Modellmporter modellmporter = new Modellmporter(); try {modellmporter.parseOBJ(filename); // uses modellmporter to get vertex information numVertices = modellmporter.getNumVertices(); float[] verts = modellmporter.getVertices(); float[] tcs = modellmporter.getTextureCoordinates(); float[] normals = modellmporter.getNormals(); vertices = new Vector3f[numVertices]; texCoords = new Vector2f[numVertices]; normals = new Vector3f[numVertices];

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Graphics Programming Questions!