Results 1 to 4 of 4

Thread: bullet(well... paintball) physics?

  1. #1
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    bullet(well... paintball) physics?

    for the fps im making i am doing bullet physics... here is my code so far
    Code :
    class paint
    {
    	public:
    	GLfloat heading;
    	GLfloat xpos;
    	GLfloat zpos;
    	GLfloat ypos;
    	int go;
    	void newPaint(GLfloat heading1, GLfloat xpos1, GLfloat ypos1, GLfloat zpos1);
    	void updatePaint();
    	void drawPaint();
    };
     
    void paint::newPaint(GLfloat heading1, GLfloat xpos1, GLfloat ypos1, GLfloat zpos1)
    {
    	xpos = xpos1;
    	ypos = ypos1;
    	zpos = zpos1;
    	heading = heading1;
    	go = 1;
    }
     
    void paint::updatePaint()
    {
    	xpos += (float)sin(heading*piover180) * 0.5f * speed;
    	zpos += (float)cos(heading*piover180) * 0.5f * speed;
    }
     
    void paint::drawPaint()
    {
     
    	glTranslatef(xpos, 5.5f, zpos);
    	ballmesh.Render(1.0f, 0.0f, 0.0f);
    }
    paint ball[100];
    for(int i = 0; i < 100; i++)
    	{
    		if(ball[i].go == 1) ball[i].updatePaint();
    	}
    for(int j = 0; j < 100; j++)
    	{
    		if(j > 1) glTranslatef(ball[j - 1].xpos, -5.5f, ball[j - 1].zpos);
    		if(ball[j].go == 1) ball[j].drawPaint();
     
    	}
    id(mouseclick)
    {
    ball[ballcount].newPaint(mcamera.heading , mcamera.xpos, 5.5f, mcamera.zpos);
    				ballcount++;
     
    }

    it works fine for the first ball, but all the balls after that get a weird heading!

    please hlep

    [This message has been edited by c_olin (edited 05-14-2003).]

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: bullet(well... paintball) physics?

    Try this:

    void paint::drawPaint()
    {
    glPushMatrix();
    glTranslatef(xpos, 5.5f, zpos);
    ballmesh.Render(1.0f, 0.0f, 0.0f);
    glPopMatrix();
    }

    for(int j = 0; j < 100; j++)
    {
    /* if(j > 1)
    glTranslatef(ball[j - 1].xpos, -5.5f, ball[j - 1].zpos);
    */
    if(ball[j].go == 1)
    ball[j].drawPaint();
    }


    [This message has been edited by Relic (edited 05-15-2003).]

  3. #3
    Member Contributor
    Join Date
    May 2003
    Posts
    50

    Re: bullet(well... paintball) physics?

    thanks!

    what does the pushmatrix and popmatrix do to the heading?

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: bullet(well... paintball) physics?

    RTFM (Couldn't resist) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc03_246w .asp

    In your case it prohibits that your glTranslatef calls accumulate in the modelview matrix by saving and restoring the current matrix so that your drawPaint doesn't change it.
    You tried to do that same by resetting the translate of the previous ball but forgot to negate the x and z values.
    But your code would have broken if one previous ball has go=0 (in case it has hit something and is taken out of the list).

    [This message has been edited by Relic (edited 05-15-2003).]

Similar Threads

  1. Parsing an OBJ file to add triangles to a Bullet Physics Triangle Mesh
    By zsloan112 in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-05-2018, 09:39 AM
  2. Bullet Physics and OpenCL
    By drlesser12 in forum OpenCL
    Replies: 0
    Last Post: 10-08-2011, 05:38 PM
  3. Replies: 1
    Last Post: 11-26-2007, 05:28 AM
  4. digital paintball not working in OPENGL help!!!
    By nvnvb in forum OpenGL: User Software
    Replies: 5
    Last Post: 10-16-2004, 10:00 AM
  5. Bullet management
    By Noah in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-27-2002, 11:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean