Jump to content
  • Advertisement

raffaele181188

Member
  • Content Count

    10
  • Joined

  • Last visited

Community Reputation

100 Neutral

About raffaele181188

  • Rank
    Member
  1. raffaele181188

    My object isn't entirely drawn

    In the code pasted cull facing isn't disabled, but I can assure I played with it and nothing changes. Obviously there could be something wrong with my Blender exporter or my model importer; but actually how can one test it? The code is GL ES 1.x (fixed pipeline)
  2. raffaele181188

    My object isn't entirely drawn

    [color=#666666][font=Arial, Helvetica, sans-serif]Here is the whole Eclipse project[/font] This is the renderer code. Quite basic. Obviusly this is specific to Java language and Android development public class TwoRobotsRenderer implements Renderer { ShortBuffer mIndexBuffer; FloatBuffer mVertexBuffer; int triangleCount; float seek; public TwoRobotsRenderer(Context ctx) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(ctx.getAssets().open("two_robots.txt"))); int vertsLines = Integer.parseInt(in.readLine()); int indicesLines = Integer.parseInt(in.readLine()); triangleCount = indicesLines; float[] vertsArray = new float[vertsLines * 3]; for (int i = 0; i < vertsLines; i++) { String[] lines = in.readLine().split("\\s+"); vertsArray[i * 3] = Float.parseFloat(lines[0]); vertsArray[i * 3 + 1] = Float.parseFloat(lines[1]); vertsArray[i * 3 + 2] = Float.parseFloat(lines[2]); } /* ByteBuffer bb = ByteBuffer.allocateDirect(vertsArray.length * 4); bb.order(ByteOrder.nativeOrder()); mVertexBuffer = bb.asFloatBuffer(); mVertexBuffer.put(vertsArray); mVertexBuffer.position(0); */ mVertexBuffer = FloatBuffer.wrap(vertsArray); short[] indicesArray = new short[indicesLines * 3]; for (int i = 0; i < indicesLines; i++){ String[] lines = in.readLine().split("\\s+"); indicesArray[i * 3] = Short.parseShort(lines[0]); indicesArray[i * 3 + 1] = Short.parseShort(lines[1]); indicesArray[i * 3 + 2] = Short.parseShort(lines[2]); } /* bb = ByteBuffer.allocateDirect(indicesArray.length * 2); mIndexBuffer = bb.asShortBuffer(); mIndexBuffer.put(indicesArray); mIndexBuffer.position(0); */ mIndexBuffer = ShortBuffer.wrap(indicesArray); in.close(); } float mAngle = 0.0f; float mAngleX = 0.0f; float mAngleY = 0.0f; float mAngleZ = 0.0f; @Override public void onDrawFrame(GL10 gl) { gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0, 0, seek); gl.glRotatef(mAngle += 6, mAngleX += 5, mAngleY +=7, mAngleZ += 10); gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); // Draw calls //gl.glFrontFace(GL10.GL_CW); gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer); gl.glDrawElements(GL10.GL_TRIANGLES, triangleCount, GL10.GL_UNSIGNED_SHORT, mIndexBuffer); } public void onSurfaceChanged(GL10 gl, int width, int height) { gl.glViewport(0, 0, width, height); /* * Set our projection matrix. This doesn't have to be done * each time we draw, but usually a new projection needs to * be set when the viewport is resized. */ float ratio = (float) width / height; gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10); } public void onSurfaceCreated(GL10 gl, EGLConfig config) { /* * By default, OpenGL enables features that improve quality * but reduce performance. One might want to tweak that * especially on software renderer. */ gl.glDisable(GL10.GL_DITHER); /* * Some one-time OpenGL initialization can be made here * probably based on features of this particular context */ gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_FASTEST); gl.glClearColor(0,0,0,0); //gl.glDisable(GL10.GL_CULL_FACE); gl.glShadeModel(GL10.GL_SMOOTH); gl.glEnable(GL10.GL_DEPTH_TEST); } } Attached is the same Eclipse project if someone has problems accessing Filefactory
  3. raffaele181188

    My object isn't entirely drawn

    This happens if I draw a cube or a cylinder. Please help me
  4. I am doing simple experiments with GL on Android. I want to draw a Monkey (it's a Blender's primitive), without colors, lighting, etc only the triangles. Here is what I get Uploaded with ImageShack.us I turned backface culling off, but nothing changes. If I draw a cylinder, only the two faces are drawn - actually not entirely, they seem Pacman head Can somebody explain this? I can give the code, even if it's very simple and it's Android specific
  5. raffaele181188

    Beginner needs help

    Sorry guys, it's really driving me crazy Can someone explain this redbook excerpt about projection matrix With gluPerspective(), you need to pick appropriate values for the field of view, or the image may look distorted. For example, suppose you're drawing to the entire screen, which happens to be 11 inches high. If you choose a field of view of 90 degrees, your eye has to be about 7.8 inches from the screen for the image to appear undistorted. (This is the distance that makes the screen subtend 90 degrees.) If your eye is farther from the screen, as it usually is, the perspective doesn't look right. If your drawing area occupies less than the full screen, your eye has to be even closer. To get a perfect field of view, figure out how far your eye normally is from the screen and how big the window is, and calculate the angle the window subtends at that size and distance. It's probably smaller than you would guess. Another way to think about it is that a 94-degree field of view with a 35-millimeter camera requires a 20-millimeter lens, which is a very wide-angle lens. "Troubleshooting Transformations," gives more details on how to calculate the desired field of view[/quote] What the hell are those 11 inches??? And why does he state 7.8???(I guess it comes from 11*sin(90°/2) or maybe cosine, but what does it mean? Why may I have to figure the distance between user and screen? Also, I can't understand how a screen can subtend 90° - maybe because I'm not a native speaker but hey isn't the screen a 3D object? It's getting very confused... I understand the basic concept that projection matrix is used to transform vertices by projecting them to the screen, and -concerning gluPerspective- that the wider the angle becomes, the narrower my object is drawn. But all those terminology and examples are really adding frustr(um)ation
  6. raffaele181188

    Beginner needs help

    Thanks for the deep eplanation. So it is not a waste of memory to specify 12 length arrays for both vertices and normals
  7. raffaele181188

    Beginner needs help

    I guess I cannot share vertices having different normals. So for a tetrahedron I'd need 4*3 = 12 vertices and 4 normals. But drawing with glDrawElements forces me to specify 12 lenght arrays for both vertices and normals, so I cannot save memory (and typing). Am I wrong?
  8. raffaele181188

    Beginner needs help

    Thanks for your reply Now I'm playing with a code-generated tetrahegon (the simplest 3D model) and cannot setup lighting correctly. More precisely I don't understand the openGL API regarding glDrawElements and normal arrays. I mean, I use a vertices array to hold the vertices, then I should use a normals array. A tetrahegon has four vertices, but what about normals? Do I need 4 normals (maybe averaging the planes) or 12 normals since each vertex is shared among 3 triangles?
  9. raffaele181188

    Beginner needs help

    Of course, I read those tutorials. Well, not all of them because they are poorly organized and the graphic style makes them difficult to read If only you could state "you are in the right direction" or "this is the way we do it" it would help more For example, playing with my model min anx max values for x, y e z, I could translate and scale my MODELVIEW matrix so that the object is placed in the middle of the screen and all its coordinates are < 1. Am I wrong? Drawing the quad background is simple a matter of how I parameterized the far frustrum's plane?
  10. raffaele181188

    OpenGL Beginner needs help

    I'm very new to openGL (ES) programming and 3D things, so I need some tips on how to do this: I want to show my model in the middle of the screen, with a fixed bitmap background and a revolving camera. Basically, imagine a fight game when you have to select your player. I really don't know where to start. I read some tutorials and the red book online version and I quite understood them, but when it comes to code I'm lost. I mean, it's easy to draw a cube and make it rotating, everything seems obvious. But when you have a real model it becomes much harder. My questions (among the others) are How do I place my character in the middle of the scene? The "center" of the model is not (0, 0, 0) -let's say it's (123.34, 26.56, 756.12): should I translate and scale the MODELVIEW matrix based on model min and max coords before drawing?How should I deal with something like projection matrix and glFrustrum?How can I draw the quad (actually, two triangles), textured it, and ensure it's the background? I know you can't give me the code Just point me in the right direction, show me the ideal workflow or maybe link me some accurate and deep paper Best regards
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!