The TORCS Racing Board
Username: Password: Remember Me?
Lost Password Register
Author: muton | Created: 2019-05-10 08:08:02
Subject: How to display a red point on the screen at a specified coordinate position
Hi All.

I want to display a red point on the screen for the specified coordinate position.
We could define the position coordinates i want to specify.
However, I do not know how to add code.
Can somebdy help me?
Last Edited: 2019-05-10 08:08:45 by muton
    Author: phi | Created: 2019-05-10 14:47:48
    Subject: Re: How to display a red point on the screen at a specified coordinate position
    Hi

    See http://www.berniw.org/trb/forum/showthread.php?topicid=3299 (and maybe other topics present here). I believe this meets your needs.
    Last Edited: 2019-05-10 14:48:00 by phi
      Author: muton | Created: 2019-05-13 11:00:13
      Subject: Re: How to display a red point on the screen at a specified coordinate position
      Thank you very much.
      I referred to the URL of the reference source.
      Should we first define the coordinates we want to specify in the tCarCtrl structure?
      Last Edited: 2019-05-13 11:00:13 by muton
        Author: phi | Created: 2019-05-13 19:27:08
        Subject: Re: How to display a red point on the screen at a specified coordinate position
        If I do not make a mistake in any way, I think it's like this:

        You have a pointer to a vector for your coords in tCarCtrl (you can also have this pointer in tCarElt), accessed via the tCarElt pointer given to you in NewRace, Drive & PitCommand functions; and this is where you will fill your coordinate vector. Your grDrawCar code will also have access to this pointer, so it can draw its coordinates (or whatever they represent).

        The pointer can also be dynamically created (for example, in NewRace) and deleted in Shutdown (or elsewhere, in which case you should set the pointer to zero so that grCarDraw does not try to draw), but in this case I think the best place for the pointer is tCarElt (usually tCarCtrl is cleaned every time Drive is called).
        Last Edited: 2019-05-13 19:27:08 by phi
          Author: muton | Created: 2019-05-21 07:18:07
          Subject: Re: How to display a red point on the screen at a specified coordinate position
          thank you for your answer.
          I understand how to define the coordinates I want to specify.

          Next, I would like to draw the coordinates defined by grDrawCar, but I do not know how to do it at all.
          Could you tell me specifically how to draw to grDrawCar?
          Last Edited: 2019-05-21 07:18:07 by muton
            Author: phi | Created: 2019-05-21 10:41:47
            Subject: Re: How to display a red point on the screen at a specified coordinate position
            You must insert your own drawing code in grDrawCar. I can't help you more than this:


            if(car->YourCoordsVector) {

            ... Your OpenGL draw ...

            }


            Don't forget Bernhard "Pitfalls" in above URL.
            Last Edited: 2019-05-21 10:41:47 by phi
              Author: muton | Created: 2019-05-28 12:55:01
              Subject: Re: How to display a red point on the screen at a specified coordinate position
              thank you for your answer.
              The programming to draw a point at x coordinate = 74, y coordinate = 171, z coordinate = 0 was constructed as follows.
              However, although the build passes, I can not confirm the point on the simulation screen.
              I'm glad to get some advice.

              if (car-> myCoordsVector)
              {
                   glClear (GL_COLOR_BUFFER_BIT);
                   glColor3d (1.0, 0.0, 0.0);
                   glPointSize (500);
                   glBegin (GL_POINTS);
                   glVertex 3d (74, 171, 0);
                   glEnd ();
                   glFlush ();
              }
              Last Edited: 2019-05-28 12:55:01 by muton
                Author: phi | Created: 2019-05-28 19:25:27
                Subject: Re: How to display a red point on the screen at a specified coordinate position
                I tested this block on Corkscrew, and I see the point (perhaps the most privileged view is that of the interior of the car, but the point is also visible in other views):


                if(/*car->myCoordsVector*/true) {
                glPushAttrib(GL_ALL_ATTRIB_BITS);
                glPushMatrix();

                glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                gluPerspective(curCam->getFovY(), 2, .005, 100000);
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();
                t3Dd *pos = curCam->getPos();
                t3Dd *center = curCam->getCenter();
                t3Dd *upv = curCam->getUp();
                gluLookAt(pos->x, pos->y, pos->z, center->x, center->y, center->z, upv->x, upv->y, upv->z);

                glColor3d(1.0, 0.0, 0.0);
                glPointSize(60);
                glBegin(GL_POINTS);
                glVertex3d(74, 171, 100);
                glEnd();

                glPopMatrix();
                glPopAttrib();
                }


                1) If you call glClear(GL_COLOR_BUFFER_BIT) the sky box will disappear.


                EDIT: I put the block at the end of grDrawCar.
                Last Edited: 2019-05-28 19:27:22 by phi
                  Author: muton | Created: 2019-05-29 08:41:53
                  Subject: Re: How to display a red point on the screen at a specified coordinate position
                  thank you for your answer.
                  When I built using the provided code, I was able to confirm the points.
                  However, it seems that the point is drawn on the background position, not on the course.
                  What should I do to draw on the course?
                  I am sorry for many times.

                  course
                  Dirt → Mixed 1

                  Position to display
                  Position coordinates at start of car race (x = 74, y = 171, z = 0)
                  Last Edited: 2019-05-29 08:41:53 by muton
                    Author: phi | Created: 2019-05-29 21:28:30
                    Subject: Re: How to display a red point on the screen at a specified coordinate position
                    It's all right. I started getting curious about this process, and what we did here perhaps might be of some use to me.

                    Try this one:

                    if(/*car->myCoordsVector*/true) {
                    glPushAttrib(GL_ALL_ATTRIB_BITS);
                    glPushMatrix();

                    // Activate if you want the point to appear pure red (without the light interfering).
                    ///glDisable(GL_TEXTURE_2D);

                    glMatrixMode(GL_PROJECTION);
                    grContext.loadProjectionMatrix();
                    glMatrixMode(GL_MODELVIEW);
                    grContext.loadModelviewMatrix();

                    // Your drawing space ////////////////////////////////
                    glColor3d(1.0, 0.0, 0.0);
                    glPointSize(60);
                    glBegin(GL_POINTS);
                    glVertex3d(74, 171, 0);
                    glEnd();
                    //////////////////////////////////////////////////////

                    glPopMatrix();
                    glPopAttrib();
                    }
                    Last Edited: 2019-05-29 21:28:30 by phi
                      Author: muton | Created: 2019-06-17 07:34:12
                      Subject: Re: How to display a red point on the screen at a specified coordinate position
                      thank you for your answer.
                      We could confirm the point on (74,171,0) by using the code you provided.

                      Next, the predicted value is displayed on the screen by using the following code.
                      (car-> ctrl.ary [0], car-> ctrl.ary [1] is a previously defined forecast value)

                      "
                      void grDrawCar (tCarElt * car, tCarElt * curCar, int dispCarFlag, int dispDrvFlag, double curTime, class cGrPerspCamera * curCam)
                      {
                      glPushAttrib (GL_ALL_ATTRIB_BITS);
                      glPushMatrix ();

                      // Activate if you want the point to appear pure red (without the light interfering).
                      /// glDisable (GL_TEXTURE_2D);

                      glMatrixMode (GL_PROJECTION);
                      grContext.loadProjectionMatrix ();
                      glMatrixMode (GL_MODELVIEW);
                      grContext.loadModelviewMatrix ();

                      // Your drawing space ///////////////////////////////////
                      glColor3d (1.0, 0.0, 0.0);
                      glPointSize (60);
                      glBegin (GL_POINTS);
                      glVertex3d (atoi (car-> ctrl.ary [0]), atoi (car-> ctrl.ary [1]), 1);
                      glEnd ();
                      / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /////

                      glPopMatrix ();
                      glPopAttrib ();
                      }
                      "

                      The problem is that while drawing a forecast, the car will move and the forecast will appear to be behind.
                      Therefore, I wanted to pause the screen using the Sleep function after drawing with OpenGL.
                      However, when putting the Sleep function in the same void, the point is not drawn while pausing.
                      How do I pause the screen after drawing in OpenGL?
                      Could you tell me.
                      Last Edited: 2019-06-17 07:43:12 by muton
                        Author: phi | Created: 2019-06-17 10:43:23
                        Subject: Re: How to display a red point on the screen at a specified coordinate position
                        Maybe something like 'if(MyPauseSignal) ReInfo->s->_raceState = RM_RACE_PAUSED;' (or 'ReInfo->s->_raceState |= RM_RACE_PAUSED' I don't know...) at the end of ReOneStep() (in raceengine.cpp)? I don't know if this will be a possible solution to be worked on, but you can try carefully.

                        I believe you should study TORCS and find a way to use his pause to fulfill your intention. If the above procedure works, it's a matter of finding the right place and time to turn the MyPauseSignal variable on and off. I can't help you more than that.
                        Last Edited: 2019-06-17 10:43:23 by phi