Game Development Community

Commander Map and project...... need some help

by Josh Moore · in Torque Game Engine · 08/25/2004 (3:18 pm) · 17 replies

I'm using Ben's commander map:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5277
and some code from this resource:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6307

My problem is that I can't get the icons(dots) to render in the correct spot on my map control. They just render in random spots based on my zoom/pan; I have the mouse controling those(pan doesn't work right though). They'll appear in the correct positions reletive to each other, but way off from their actual positions. I'll post my onRender function for you guys to look at. I tried to use project alone to get the x/y coords, but nothing rendered. I've also tried a number of different aproaches, but all give me similar results. Any help would be greatly apprechiated.

#1
08/26/2004 (6:03 pm)
Well I got it to work. It was just some extra code that I forgot was there. Everything is working fairly well, I still need to change the dots to bitmaps, though. The only thing thats not working correctly is my script callback that is supposedto return a vector. I'm using unproject for this, which works for panning, but I get all kinds of weird numbers. Heres the console log from that callback.

setting state for MapHud: 1 // switches from control to command mode
MapHud::onIssueCommand called.
command type: onMouseDown
position : -1073741824 1081274825 -2147483648
vector : -1073741824 1081274825 -2147483648
keyboard0 input device unacquired.
keyboard0 input device acquired.
MapHud::onIssueCommand called.
command type: onRightMouseDown
position : 0 1081274826 0
vector : 0 1081274826 0
keyboard0 input device unacquired.
keyboard0 input device acquired.
MapHud::onIssueCommand called.
command type: onMouseDown
position : 1073741824 1081299426 -536870912
vector : 1073741824 1081299426 -536870912

The positions and vectors are the same because I removed the position part(so they both print the vector). I have no idea why I get those numbers, heres the source that calls the onIssueCommand function.

Point3F pt(event.mousePoint.x, event.mousePoint.y, 1);
        Point3F mousePoint;
        unproject(pt, &mousePoint);
        char* vecBuff = Con::getReturnBuffer(256);
        dSprintf(vecBuff, 256, "%d %d %d", mousePoint.x, mousePoint.y, mousePoint.z);
        Con::executef(this, 4, "onIssueCommand", name, vecBuff);


Hers what it looks like BTW:
illumina-game.com/forum/download.php?id=273
#2
08/28/2004 (11:30 am)
That looks cool! I'm glad you got it working. :)
#3
08/28/2004 (1:23 pm)
Thanks, and thank you for the great start. I have it team sensitive now, and if there is no bitmap set, dots get rendered instead. I still can't figure out how to get the world position/vector from the screen coords, but I'm hopeing someone will help me out. The code I'm using is in the above post, butI get allkinds of weird numbers.

BTW - Everything is that pic is temp untill I get this class into my game.
#4
08/31/2004 (7:32 pm)
Bump. I'm having some serious trouble with the camera pos and the mouse vector thing.
#5
09/04/2004 (1:12 pm)
Are you sure the camera transform is right?
#6
09/06/2004 (12:26 pm)
Not really, the whole GUI thing is new to me. I set my mCameraMatrix in process camera query.
mCamMatrix = q->cameraMatrix;

and then I try to unproject the 2nd coords to world coords.

Point3F sp(event.mousePoint.x, event.mousePoint.y, 1);
         Point3F wp;
         Point3F CamPos;
         VectorF Vec;
         unproject(sp, &wp);
         mCamMatrix.getColumn(3,&CamPos);
         
         Vec = wp - CamPos;
         Vec.normalizeSafe();

I've sorta stoped working on this part of the class. ATM, I'm trying to get waypoints to render, but for some reason, the markerobjecttype isn't getting found. I'm using this code:

if ((*itr)->getType() & MarkerObjectType) {
      WayPoint* way = static_cast<WayPoint*>(*itr);
      
      Point3F newCoord;
      MatrixF srtMat = way->getRenderTransform();
      srtMat.getColumn(3, &newCoord);
      
      Con::errorf("waypoint found! position: %d, %e, %f", newCoord.x, newCoord.y, newCoord.z);

      Point3F projPnt;
      if (!project(newCoord, &projPnt))
         continue;

      if(!mTextureHandle)
      {
      glColor4f(mVehiclesColor.red,mVehiclesColor.green,mVehiclesColor.blue,mVehiclesColor.alpha);
      glVertex2f(projPnt.x,projPnt.y);
      }
      else
      {
      Point2I imgCenter( mTextureHandle.getWidth()/2, mTextureHandle.getHeight()/2);
      dglSetBitmapModulation(ColorF(mVehiclesColor.red,mVehiclesColor.green,mVehiclesColor.blue,mVehiclesColor.alpha));
      dglDrawBitmap(mTextureHandle,Point2I((S32)projPnt.x - imgCenter.x,(S32)projPnt.y - imgCenter.y));
      }
   }

Anyone care to shed some light on what I'm doing wrong?

Thanks in advance, Josh.
#7
09/07/2004 (2:38 pm)
Hmm. Which object set are you iterating over?

You're going to have to get your hands a bit dirty here to get stuff working, I fear. :)
#8
09/07/2004 (4:56 pm)
Going throught all the gosted objects.
for (SimSetIterator itr(conn); *itr; ++itr) {
Its in the same loop as all the other object that get renered. However its a seperate if statement than the one for the shapebase objects.
I changed the mission marker type mask to MarkerObjectType, but it still doesn't find it.

I tried using gServerContainer.findObjects(... But I have no idea how it works(lots of errors); I haven't found the source for it yet.

It seems that the more advanced the commander mapgets, the more walls I'm running into. I don't mind getting my hands dirty since its essential for Illumina, and its my main focus untill 1.3 is released.
#9
09/07/2004 (5:30 pm)
Be sure everything is in scope as I explain in the comments of ben's resource
#10
09/07/2004 (7:15 pm)
Thanks Anthony, I got it to render the marker object types. However, this inculdes the spawn spheres. I'm working on a way to only render the waypoints. Anyone have any ideas on how to distinguish class types?

Thanks agian, Josh.
#11
09/07/2004 (7:19 pm)
PlayerOjectType, TriggerObjectType . . ect ect all the Type masks look in the object's constructor
#12
09/07/2004 (7:40 pm)
I was searching for the MarkerObjectType. I just gave the mission maker class a different type mask, and gave the waypoint the MarkerObjectType. So now I just need to get the camera position and mouse click vectors to be passed into the scripts and I'll start on a waypoint GUI.
#13
09/07/2004 (11:31 pm)
You could also do a dynamic_cast to the appropriate class and see if you get a non-null result.
#14
09/07/2004 (11:31 pm)
GServerContainer is a Container class object. The source code is in sceneObject.cc, I believe. Do you have a good find in files app? It will save you immeasurable trouble.
#15
09/08/2004 (2:51 pm)
I tried using dynamic_cast, but it crashed Torque when I tested it. I got it to only render waypoint by giving them the MarkerObjectType for mTypeMask, and having the mssion marker have some other typemask.

I still can't figure out how to get the darn screen to worlds thing working.
#16
03/27/2005 (5:19 am)
@Josh:
I'm just wondering if you've figured out to do it?

Steven
#17
09/18/2006 (9:06 pm)
I'm interested in this as well... over a year later...

i'm trying to do what you did and just keep creating engines that can bring down any computer.