Icetigris

Member
  • Content count

    14
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Icetigris

  • Rank
    Member
  1. Hi, I'm trying to do some image processing type stuff (Gaussian blur) on some 1024x1024 textures, but my back buffer is 800x600. I'm not sure what the rules are on how to do this, so at the moment I either get distorted textures or render targets that clear, but don't get drawn to. Can someone give me a step-by-step process of how to do this? I've read that all active render targets have to be the same type and dimensions, but I feel like I'm missing something.
  2. Help fixing tangents

    Here's the link to the model, color map, and normal map I'm using: http://www.mediafire.com/?pjb9x2zig4qimnm,n2aiqqnuluuzx8u,u5rykzra1x8tsxz As an interesting sidenote, I tried loading this model in 3ds Max and using their implementation of a tangent-space normal map shader and it too had the same faceting issue.
  3. Help fixing tangents

    [quote name='mmikkelsen' timestamp='1322096598' post='4887079'] I know you weren't saying the model was proprietary work. I was just pulling your chain Perhaps you could show the unwrap? I'd like to see the texture coordinates to that model (visually). One thing you are doing wrong is you are assuming that triangles with different winding in UV-space never share texture coordinates (since you don't generate any splits). But this is clearly not the only issue. [/quote] Here's the texture that came with the model: [img]http://www.majhost.com/gallery/Icetigris/crap/zheadcolor.png[/img] When you talk about the winding issue, is that part of the facet problem, or the texture seam problem? I'm not especially worried about the texture seams blending nicely at the moment, I just want to get rid of the random facets.
  4. Help fixing tangents

    [quote name='mmikkelsen' timestamp='1322071521' post='4886952'] [quote name='Icetigris' timestamp='1322005660' post='4886714'] I'm working on a DirectX engine that is basically a testbed for some shaders and I've got a problem with my tangents on a model I exported from Zbrush. [/quote] You just exported that from zbrush? amazing how much it looks like the one that was donated here --> [url="http://www.ir-ltd.net/infinite-3d-head-scan-released"]http://www.ir-ltd.ne...d-scan-released[/url] Anyway, you could try out using an existing tangent space generator such as the one that is used in xNormal? The code is in the examples folder of the sdk but also available and described here --> [url="http://wiki.blender.org/index.php/Dev:Shading/Tangent_Space_Normal_Maps"]http://wiki.blender....ace_Normal_Maps[/url] It's very easy to integrate one .h and one .c file. No dependencies. [/quote] Yeah, I used that model, I needed to decimate it though, so I used their Zbrush file and exported an obj file. I'm not trying to claim it as my own work. I edited my original post to make that more clear. I will try using xNormal, though I would really like to know what I'm doing wrong.
  5. I'm working on a DirectX engine that is basically a testbed for some shaders and I've got a problem with my tangents on this [url="http://www.ir-ltd.net/infinite-3d-head-scan-released"]model[/url]. I decimated it in Zbrush and exported an obj file. Here's what it looks like with a color and normal map: [img]http://www.majhost.com/gallery/Icetigris/crap/colorhead2.png[/img] Here's what the tangents look like when drawn to the color channel: [img]http://www.majhost.com/gallery/Icetigris/crap/tangenthead2.png[/img] And here's what my tangent generation code looks like: [code] //do the bitangent and tangent crap VectorType sdir, tdir; TempVertexType vertex1, vertex2, vertex3; int counter = 0; unsigned long i1 = 0, i2 = 0, i3 = 0; //this is all for the tangents VectorType* tan1 = new VectorType[m_vertexCount * 2]; VectorType* tan2 = tan1 + m_vertexCount; ZeroMemory(tan1, m_vertexCount * sizeof(VectorType) * 2); for(unsigned int i = 0; i < m_indexCount; i++) { // get vertex1, vertex2 & vertex3 // Get the three vertices for this face from the model. i1 = indices[i]; i++; i2 = indices[i]; i++; i3 = indices[i]; vertex1.x = m_model[i1].x; vertex1.y = m_model[i1].y; vertex1.z = m_model[i1].z; vertex1.tu = m_model[i1].tu; vertex1.tv = m_model[i1].tv; vertex1.nx = m_model[i1].nx; vertex1.ny = m_model[i1].ny; vertex1.nz = m_model[i1].nz; vertex2.x = m_model[i2].x; vertex2.y = m_model[i2].y; vertex2.z = m_model[i2].z; vertex2.tu = m_model[i2].tu; vertex2.tv = m_model[i2].tv; vertex2.nx = m_model[i2].nx; vertex2.ny = m_model[i2].ny; vertex2.nz = m_model[i2].nz; vertex3.x = m_model[i3].x; vertex3.y = m_model[i3].y; vertex3.z = m_model[i3].z; vertex3.tu = m_model[i3].tu; vertex3.tv = m_model[i3].tv; vertex3.nx = m_model[i3].nx; vertex3.ny = m_model[i3].ny; vertex3.nz = m_model[i3].nz; sdir.x = 0; sdir.y = 0; sdir.z = 0; tdir.x = 0; tdir.y = 0; tdir.z = 0; // Calculate the tangent and bitangent of that face. CalculateTangentBitangent(vertex1, vertex2, vertex3, sdir, tdir); tan1[i1].x += sdir.x; tan1[i1].y += sdir.y; tan1[i1].z += sdir.z; tan1[i2].x += sdir.x; tan1[i2].y += sdir.y; tan1[i2].z += sdir.z; tan1[i3].x += sdir.x; tan1[i3].y += sdir.y; tan1[i3].z += sdir.z; tan2[i1].x += tdir.x; tan2[i1].y += tdir.y; tan2[i1].z += tdir.z; tan2[i2].x += tdir.x; tan2[i2].y += tdir.y; tan2[i2].z += tdir.z; tan2[i3].x += tdir.x; tan2[i3].y += tdir.y; tan2[i3].z += tdir.z; } vector<int> handedness; for (unsigned long a = 0; a < m_vertexCount; a++) { VectorType n; n.x = vertexList[a].nx; n.y = vertexList[a].ny; n.z = vertexList[a].nz; const VectorType& t = tan1[a]; // Gram-Schmidt orthogonalize tempTangents.push_back(normalize((t - n * dot(n, t)))); // Calculate handedness handedness.push_back( (dot(cross(n, t), tan2[a]) < 0.0F) ? -1.0F : 1.0F ); } //calculate bitangents for (unsigned long a = 0; a < m_vertexCount; a++) { //B' = m(N × T') VectorType tempN; tempN.x = vertexList[a].nx; tempN.y = vertexList[a].ny; tempN.z = vertexList[a].nz; tempBitangent.push_back(cross(tempN,tempTangents[a]) * handedness[a]); } [/code] Here's the CalculateTangentBitangent function: [code] void ModelClass::CalculateTangentBitangent(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& sdir, VectorType& tdir) { float x1 = vertex2.x - vertex1.x; float y1 = vertex2.y - vertex1.y; float z1 = vertex2.z - vertex1.z; float x2 = vertex3.x - vertex1.x; float y2 = vertex3.y - vertex1.y; float z2 = vertex3.z - vertex1.z; float s1 = vertex2.tu - vertex1.tu; float t1 = vertex2.tv - vertex1.tv; float s2 = vertex3.tu - vertex1.tu; float t2 = vertex3.tv - vertex1.tv; float r = 1.0f / (s1 * t2 - s2 * t1); sdir.x = (t2 * x1 - t1 * x2) * r; sdir.y = (t2 * y1 - t1 * y2) * r; sdir.z = (t2 * z1 - t1 * z2) * r; tdir.x = (s1 * x2 - s2 * x1) * r; tdir.y = (s1 * y2 - s2 * y1) * r; tdir.z = (s1 * z2 - s2 * z1) * r; } [/code] Any ideas on how I can fix this? Edit: The tangents looked a lot worse before, but I deleted some internal geometry in the model that didn't need to be there and for some reason this fixed a lot of the problems with the tangents. They still aren't that smooth though, and there are some artifacts I'd like to get rid of if possible.
  6. My copy of Skyward Sword has shipped. EEHEEE
  7. Game Engine Senior Design Project

    I do already know all this stuff, but pointing it out is warranted nonetheless. I have to plan it all out first anyway, but since I need to generate some numbers and make sure I have something working by April it'd be nice to know what's going to take the longest. I'm guessing it's going to be graphics or collision detection that's going to eat up the majority of my time. Anyway here's a basic layout of what I'd like to make (in no particular order): Graphics: -texture, environment mapping -normal mapping -particles -transparency -bone chain animation -lighting Collision Detection -bounding spheres? Sound -3D sound fx -Background music UI -HUDs, menus -level editor? I/O -Xbox controller input -Keyboard, mouse input Misc -texture fonts -networking? I can't think of anything else off the top of my head. I'd rather not do scripting since I probably don't have time for it and something can just as easily be coded as scripted (at least I think). Anyway, does this seem plausible? Are there any items that could potentially take a jillion years?
  8. I am starting my senior design project for my senior year of university and I want to make a 3D game engine using XNA. I have about a year to make this, so I think I can get at least basic functionality implemented. The problem is I'm not entirely sure where to start. I have a lot of experience with Java, C, and OpenGL. The way I'm thinking about going about it is to make a really basic game and abstract up from it. I'm taking a game design class this semester, so that gives me time to work on that too. I want to have 3D rendering, sound, collision detection, particles, keyboard, mouse, and Xbox controller input, and hooks for AI. If I still have time, I'd like to implement networking and nicer graphics. Does this sound plausible? Can anyone give me pointers on where to start?
  9. Picking problems - bad return values

    I figured out why it was returning -1. I had is as gl.glSelectBuffer(hits, selectionBuffer); //setup hits buffer hits is 0 here but it needed to be: gl.glSelectBuffer(BUFSIZE, selectionBuffer); //setup hits buffer That said, it's acting wacky, not returning ids properly and sometimes not returning a hit when I don't click a cube straight on (in the case of the 1 cube)
  10. Picking problems - bad return values

    I expanded the pick buffer to the size you said, checked to see if it was drawing improperly (it is drawing fine; I checked by commenting out glRenderMode(GL_SELECT) and only drawing the scene on click), and commented out that first glPopName. I'm not sure if I'm using glGetError() right, but that returned null. Here is my current pick function: public void pick(GL gl) { if(mouseLeftClicked) { System.out.println("you clicked your mouse and are attempting to pick something"); IntBuffer selectionBuffer = BufferUtil.newIntBuffer(BUFSIZE); int hits = 0; double[] worldCoords = new double[3]; IntBuffer viewport = BufferUtil.newIntBuffer(4); DoubleBuffer modelview = BufferUtil.newDoubleBuffer(16); DoubleBuffer projection = BufferUtil.newDoubleBuffer(16); DoubleBuffer objectPosition = BufferUtil.newDoubleBuffer(3); gl.glGetIntegerv(GL.GL_VIEWPORT, viewport); //save viewport into buffer gl.glGetDoublev(GL.GL_PROJECTION, projection); //save projection matrix into buffer gl.glGetDoublev(GL.GL_PROJECTION, modelview); //save modelview matrix into buffer viewport.rewind(); projection.rewind(); modelview.rewind(); objectPosition.rewind(); gl.glSelectBuffer(hits, selectionBuffer); //setup hits buffer //int realY = viewport.get(3) - winHeight -1; gl.glRenderMode(GL.GL_SELECT); //put gl context into selection mode gl.glInitNames(); //initialise name stack gl.glPushName(0); //push crap name onto stack to avoid error //gl.glPopName(); //pop crap name off name stack gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluPickMatrix(winWidth/2, winHeight/2, winWidth, winHeight, viewport); //glu.gluPickMatrix(mouseX, viewport.get(3) - mouseY, pickWidth, pickHeight, viewport); glu.gluPerspective(45.0f, ((float)winWidth/(float)winHeight), 1.0, 50.0); gl.glMatrixMode(GL.GL_MODELVIEW); //cube.drawCubes(gl); c.draw(gl); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glFlush(); hits = gl.glRenderMode(GL.GL_RENDER); //glu.gluUnProject(winWidth, realY, 10.0f, modelview, projection, viewport, objectPosition); processHits(hits, selectionBuffer); mouseLeftClicked = false; System.out.println(gl.glGetString(gl.glGetError())); System.out.println("oh we got to the end of picking; selectionBuffer has " + selectionBuffer.capacity() + " elements"); //System.out.println("gluUnProject results: x: " + objectPosition.get(0) + " y: " + objectPosition.get(1) + " z: " + objectPosition.get(2)); } } public void processHits(int hits, IntBuffer buffer) { cube.deselectAll(); System.out.println("in processHits; hits = " + hits); if(hits > 0) { int aHit = buffer.get(3); //gotta figure out how to select the cube with name buffer.get(3) System.out.println("Your id: " + aHit); } } Here is my current draw function: public void draw(GL gl) { gl.glPushMatrix(); gl.glTranslatef(location.getX(), location.getY(), location.getZ()); if(amISelected) {//have to put a glBegin and glEnd in here gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glut.glutWireCube(size + 0.1f); System.out.println("You picked cube #" + name); } //ONLY WORKS WHEN IN GL_SELECT RENDER MODE gl.glPushName(name); gl.glEnableClientState(gl.GL_VERTEX_ARRAY); gl.glEnableClientState(gl.GL_COLOR_ARRAY); gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertexBuffer); gl.glColorPointer(4, gl.GL_FLOAT, 0, colorBuffer); gl.glDrawElements(gl.GL_TRIANGLES, 36, gl.GL_UNSIGNED_INT, indicies); gl.glDisableClientState(gl.GL_COLOR_ARRAY); gl.glDisableClientState(gl.GL_VERTEX_ARRAY); gl.glPopName(); gl.glPopMatrix(); }
  11. Picking problems - bad return values

    I tried using glPushName and glPopName inititally and when I put them back nothing changed. I expanded the pick buffer to 4096 and I'm still getting -1 returns, even with 1 cube being drawn.
  12. Picking problems - bad return values

    I think it might be a problem with naming, but I'm not sure. When I commented out the glRenderMode(GL_SELECT) and clicked around, colours from the wrong parts of my rainbow debug cube flashed. I'm not sure why they would do that unless it's a translation or z-buffer issue. I also don't think my pick buffer is too small, since there are 54 cubes on screen and the buffer is 512 elements in size. The way I have it set up is that I have a class called CubeFactory which makes a list of Cube objects, each of which have their own name (i.e. int name). Each cube draws itself and so does glLoadName when drawn in selection mode. Here is the draw function in Cube: /** * Draws a single cube * @param gl */ public void draw(GL gl) { gl.glPushMatrix(); gl.glTranslatef(location.getX(), location.getY(), location.getZ()); if(amISelected) {//have to put a glBegin and glEnd in here gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glut.glutWireCube(size + 0.1f); System.out.println("You picked cube #" + name); } //ONLY WORKS WHEN IN GL_SELECT RENDER MODE gl.glLoadName(name); gl.glEnableClientState(gl.GL_VERTEX_ARRAY); gl.glEnableClientState(gl.GL_COLOR_ARRAY); gl.glVertexPointer(3, gl.GL_FLOAT, 0, vertexBuffer); gl.glColorPointer(4, gl.GL_FLOAT, 0, colorBuffer); gl.glDrawElements(gl.GL_TRIANGLES, 36, gl.GL_UNSIGNED_INT, indicies); gl.glDisableClientState(gl.GL_COLOR_ARRAY); gl.glDisableClientState(gl.GL_VERTEX_ARRAY); gl.glPopMatrix(); }
  13. I'm trying to select a cube by clicking on it using GL_SELECT render mode type selection, but it keeps returning -1 or 0 arbitrarily. I've been told to write my own picking code, but I'm not really sure how to do it. I am using jogl in CentOS 5 (RedHat). Here's my picking function: public void pick(GL gl) { if(mouseLeftClicked) { System.out.println("you clicked your mouse and are attempting to pick something"); IntBuffer selectionBuffer = BufferUtil.newIntBuffer(BUFSIZE); int hits = 0; IntBuffer viewport = BufferUtil.newIntBuffer(4); gl.glGetIntegerv(GL.GL_VIEWPORT, viewport); //setup viewport gl.glSelectBuffer(hits, selectionBuffer); //setup hits buffer gl.glRenderMode(GL.GL_SELECT); //put gl context into selection mode gl.glInitNames(); //initialise name stack gl.glPushName(0); //push crap name onto stack to avoid error gl.glPopName(); //pop crap name off name stack gl.glMatrixMode(GL.GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); glu.gluPickMatrix(mouseX, viewport.get(3) - mouseY, pickWidth, pickHeight, viewport); glu.gluPerspective(45.0f, ((float)winWidth/(float)winHeight), 1.0, 50.0); gl.glMatrixMode(GL.GL_MODELVIEW); cube.drawCubes(gl); gl.glMatrixMode(GL.GL_PROJECTION); gl.glPopMatrix(); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glFlush(); hits = gl.glRenderMode(GL.GL_RENDER); processHits(hits, selectionBuffer); mouseLeftClicked = false; System.out.println("oh we got to the end of picking; selectionBuffer has " + selectionBuffer.capacity() + " elements"); } }
  14. Drawing and culling issues

    Well, since the drawing issue has been solved, can anyone point out what I'm doing wrong with the colouring? Only 2 faces are the colour they're supposed to be while the rest of the cube is black.
  15. Hi everyone. I'm building a 3D graph with lots of little cubes, but right now my cubes aren't drawing properly. I know it's an issue with the drawing order, but I'm not sure if it's of the verts, triangles, faces, or all of the above. I tried a few different orders, but in all cases, there are missing triangles, even when culling is off. Can anyone see where my order is screwed up? public Cube() { lowLeftFront = new Point3D(0, 0, 0); lowLeftBack = new Point3D(0, 0, 1); upLeftFront = new Point3D(0, 1, 0); upLeftBack = new Point3D(0, 1, 1); lowRightFront = new Point3D(1, 0, 0); lowRightBack = new Point3D(1, 0, 1); upRightFront = new Point3D(1, 1, 0); upRightBack = new Point3D(1, 1, 1); color = new Color(1.0f, 1.0f, 1.0f, 1.0f); location = new Point3D(0, 0, 0); name = 0; } . . . public FloatBuffer makeVertexBuffer() { //2 triangles per face * 6 faces * 3 verts per triangle * 3 coords per vert vertexBuffer = BufferUtil.newFloatBuffer(108); float[] verts = {//front upLeftFront.getX(), upLeftFront.getY(), upLeftFront.getZ(), lowLeftFront.getX(), lowLeftFront.getY(), lowLeftFront.getZ(), upRightFront.getX(), upRightFront.getY(), upRightFront.getZ(), lowLeftFront.getX(), lowLeftFront.getY(), lowLeftFront.getZ(), lowRightFront.getX(), lowRightFront.getY(), lowRightFront.getZ(), upRightFront.getX(), upRightFront.getY(), upRightFront.getZ(), //top upLeftBack.getX(), upLeftBack.getY(), upLeftBack.getZ(), upLeftFront.getX(), upLeftFront.getY(), upLeftFront.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), upLeftFront.getX(), upLeftFront.getY(),upLeftFront.getZ(), upRightFront.getX(),upRightFront.getY(),upRightFront.getZ(), //left upLeftFront.getX(), upLeftFront.getY(), upLeftFront.getZ(), upLeftBack.getX(), upLeftBack.getY(), upLeftBack.getZ(), lowLeftFront.getX(), lowLeftFront.getY(), lowLeftFront.getZ(), lowLeftFront.getX(), lowLeftFront.getY(), lowLeftFront.getZ(), upLeftBack.getX(), upLeftBack.getY(), upLeftBack.getZ(), lowLeftBack.getX(), lowLeftBack.getY(), lowLeftBack.getZ(), //bottom lowLeftFront.getX(), lowLeftFront.getY(), lowLeftFront.getZ(), lowLeftBack.getX(), lowLeftBack.getY(), lowLeftBack.getZ(), lowRightFront.getX(), lowRightFront.getY(), lowRightFront.getZ(), lowRightFront.getX(), lowRightFront.getY(), lowRightFront.getZ(), lowLeftBack.getX(), lowLeftBack.getY(), lowLeftBack.getZ(), lowRightBack.getX(), lowRightBack.getY(), lowRightBack.getZ(), //right upRightFront.getX(), upRightFront.getY(), upRightFront.getZ(), lowRightFront.getX(), lowRightFront.getY(), lowRightFront.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), lowRightFront.getX(), lowRightFront.getY(), lowRightFront.getZ(), lowRightBack.getX(), lowRightBack.getY(), lowRightBack.getZ(), //back upLeftBack.getX(), upLeftBack.getY(), upLeftBack.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), lowLeftBack.getX(), lowLeftBack.getY(), lowLeftBack.getZ(), lowLeftBack.getX(), lowLeftBack.getY(), lowLeftBack.getZ(), upRightBack.getX(), upRightBack.getY(), upRightBack.getZ(), lowRightBack.getX(), lowRightBack.getY(), lowRightBack.getZ() }; vertexBuffer.put(verts, 0, verts.length); vertexBuffer.rewind(); return vertexBuffer; } Here's what it looks like; I've colored all the triangles differently: http://s2.photobucket.com/albums/y5/Icetigris/colourinitial.png http://s2.photobucket.com/albums/y5/Icetigris/Screenshot3.png http://i2.photobucket.com/albums/y5/Icetigris/Screenshot4.png Here's the colour function: public FloatBuffer makeColorBuffer() { colorBuffer = BufferUtil.newFloatBuffer(144); // float[] rgbaArray = new float[144]; float[] rgbaArray = {//red 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, //yellow 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, //green 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, //cyan 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, //blue 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, //magenta 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, //purple 0.5f, 0.2f, 1.0f, 1.0f, 0.5f, 0.2f, 1.0f, 1.0f, 0.5f, 0.2f, 1.0f, 1.0f, //grey 0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, //orange 1.0f, 0.2f, 0.2f, 1.0f, 1.0f, 0.2f, 0.2f, 1.0f, 1.0f, 0.2f, 0.2f, 1.0f, //maroon 0.3f, 0.0f, 0.0f, 1.0f, 0.3f, 0.0f, 0.0f, 1.0f, 0.3f, 0.0f, 0.0f, 1.0f, //pink 1.0f, 0.7f, 0.7f, 1.0f, 1.0f, 0.7f, 0.7f, 1.0f, 1.0f, 0.7f, 0.7f, 1.0f, //white 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f}; //12 verts * 4 colour component values (i.e. rgba) for(int i = 0; i < 48; i+=4) { rgbaArray[i] = (color.getRed())/255; rgbaArray[i + 1] = (color.getGreen())/255; rgbaArray[i + 2] = (color.getBlue())/255; rgbaArray[i + 3] = (color.getAlpha())/255; } colorBuffer.put(rgbaArray, 0, rgbaArray.length); colorBuffer.rewind(); return colorBuffer; } EDIT: I changed my draw function a little bit, so it works a little better, but not a whole lot better. public void draw(GL gl) { gl.glEnableClientState(gl.GL_VERTEX_ARRAY); gl.glEnableClientState(gl.GL_COLOR_ARRAY); gl.glVertexPointer(3, gl.GL_FLOAT, 0, makeVertexBuffer()); gl.glColorPointer(4, gl.GL_FLOAT, 0, makeColorBuffer()); gl.glDrawArrays(gl.GL_TRIANGLES, 0, vertexBuffer.capacity() / 3); gl.glDrawArrays(gl.GL_COLOR, 0, colorBuffer.capacity()/ 4); gl.glDisableClientState(gl.GL_COLOR_ARRAY); gl.glDisableClientState(gl.GL_VERTEX_ARRAY); } New pictures: http://i2.photobucket.com/albums/y5/Icetigris/Screenshot1.png http://i2.photobucket.com/albums/y5/Icetigris/Screenshot2.png EDIT 2: I fixed it a little more. I reversed all the z-coordinates so now it draws and culls properly, but doesn't colour properly. [Edited by - Icetigris on July 23, 2008 2:12:16 PM]