Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: plz help me(opengl/fps game)

  1. #1

    plz help me(opengl/fps game)

    HI ppl...

    my 2 attached guns draw above the terrain ...with this happens? :cry:
    the guns is attached 2 camera ,fps style






    Code:
    
    function Convert_2D_To_3D(x,y:integer):TD3DVector;
    var
    modelM :   TMatrix4d;
    projectM:  TMatrix4d;
    bx,ex,ey,ez,
    by,
    bz: GLdouble;
    viewport:    TVector4i;
    NEAR_Z:gldouble;
    RayBegin:TD3DVector;
    begin
      NEAR_Z:=1.0;
    	glGetDoublev(GL_PROJECTION_MATRIX, @projectM );
      glGetDoublev(GL_MODELVIEW_MATRIX,  @modelM);
    	glGetIntegerv(GL_VIEWPORT, @viewport );
      gluUnProject(X, viewport[3]-y ,0.0,modelm, projectm, viewport,@bx,@by,@bz);
      raybegin:=Make3DVector(bx,by,bz);
      NEAR_Z:=0.965;// dist 2 camera
      gluUnProject(X, viewport[3]-y ,NEAR_Z,modelm, projectm, viewport,@ex,@ey,@ez);
      result:=Make3DVector(ex,ey,ez);
    end;
    
    --------------------------------------------------------
    //update camera
     DivCamera_Update(0);
     DivCamera_MouseLook(0);
    
    // get the ray from screen space to 3D Space
    gun1:=Convert_2D_To_3D(800 div 2+280,600 div 2+ 250);
    gun2:=Convert_2D_To_3D(800 div 2-280,600 div 2+ 250);
    
    //draw terrain and  water 
    DivTerrain_Render;
    DivWaterPlane_Draw(0);
    
    
    
    
    // draw gun 1
    DivEntities_Render(0,timegettime/1000);
    DivEntities_Yaw(0,  180-DivCamera_GetRX);
    DivEntities_Pitch(0,+(DivCamera_GetRY-90));
    DivEntities_Position(0,gun2.x,gun2.y,gun2.z);
    
    // draw gun 2
    DivEntities_Render(0,timegettime/1000);
    DivEntities_Yaw(0,  180-DivCamera_GetRX);
    DivEntities_Pitch(0,+(DivCamera_GetRY-90));
    DivEntities_Position(0,gun1.x,gun1.y,gun1.z);
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  2. #2
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    plz help me(opengl/fps game)

    Well I can't help you with your immediate problem, but I can certainly help you get help.

    :arrow: First thing, either use the 'Help!' forum for stuff you are absolutely stuck on. But don't just post stuff there that you can do with a little more effort. Experienced individual hate that and will not want to help you that much or simply ignore you altogether.

    :arrow: Also you might want to post to the forum category you are actually talking about. [size=9px](Graphics, Omega, MIDletPascal, etc)[/size] At first glance I had no idea what your problem was related to, so my ability to think that I could help you was swiftly taken away.

    :arrow: Lastly... "Help me" sounds like begging. It might as well be "please oh please dear god and all that is righteous save me" for all I'm concerned. I'll maybe then only look because it made me laugh. Give the subject line something descriptive. My biggest pet-peeve (irritant) is having to rename someone else's thread Subject line because they didn't give it even half a thought before posting. I think your subject line should be made as 'OpenGL sort order problem'. Or maybe 'guns being covered by terrain' or why not 'guns covered' at least.


    I hope this help you at least in your seeking of knowledge if nothing else. Please let me know what your intentions are and I'll move this thread to a move appropriate category.

    Cheers and good luck!
    Jason McMillen
    Pascal Game Development
    Co-Founder





  3. #3

    plz help me(opengl/fps game)

    ok ... sory and i fix the prob ops:
    i understand what you say .. i help lots of friends but this is
    get my nerves out im stuck on this prob about 3 days ...


    ps:sory about my inglish
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    plz help me(opengl/fps game)

    It's ok. The English is not a problem. Just what I mentioned above.

    Since you seem really stuck on this problem I'll place it in the Help forum. Just remember these things for next time you post.

    Oh and I was posting as you changed the subject title so didn't notice that. I'd not have made mention of that had I noticed.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5

    plz help me(opengl/fps game)

    tks dude but i solve the prob... i have 2 ways 2 do this


    1 way is set the gun very cose 2 the camera and
    the 2 way is trasform with Identity camera matrix

    when we are not relax do this kind of c****

    tks wil 1 more time
    Never underestimate the power of Delphi.
    <br />There's those who play games,...and then there's who make games...

  6. #6

    plz help me(opengl/fps game)

    Drawing the gun really close to the camera may not completely fix the problem. You may want to actually draw the gun in front of everything else, by changing the DepthRange.

    Mabye something like this:
    Code:
      glDepthRange&#40;0, 0.1&#41;; //Always draw on top of world
        DrawGunModel;
      glDepthRange&#40;0.1, 1&#41;;
    
      DrawScene;

  7. #7

    plz help me(opengl/fps game)

    or just disable depth test if if you draw the guns last

    DrawWorld;
    glDisable(gl_depth_test);
    DrawGun;
    glEnable(gl_depth_test);

    Kaz, I don't see how your solution makes sense. Wouldn't you sacrifice a heckload of depth precision doing that and clip the scene further away from the camera?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  8. #8

    plz help me(opengl/fps game)

    I use glDepthRange more so just for control, and allowing you to draw out of order .

    I just typed in the code that I wrote there, not sure the exact values, but in using glDepthRange, I havn't noticed any loss or clipping.

    But I guess just disabling the Depth Test would be a lot easier for a simple task

  9. #9

    plz help me(opengl/fps game)

    In DirectX you would just disable the z-buffer when drawing the gun... I think this gl_depth_test might be the same...
    <a href="http://www.greatgamesexperiment.com/game/Valgard/?utm_source=gge&amp;utm_medium=badge_game"><img border="0" alt="GGE" title="GGE" src="http://static.greatgamesexperiment.com/badge/game/valgard/gge400x56.png"></a>

  10. #10
    Legendary Member NecroDOME's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands, Eindhoven
    Posts
    1,059

    plz help me(opengl/fps game)

    2 options to solve...

    1. Scale down your guns and place them closer to cam
    2. Clear z-buffer...
    NecroSOFT - End of line -

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •