Commander Map
by Kyle Carter · 03/01/2004 (10:52 am) · 155 comments
Download Code File
To use this resource:
1. Copy guiCommanderHud.cc to your engine/gui subfolder.
2. Open your IDE of choice (or a text editor if that's what you like).
3. Add the source file to your project so it will be compiled into Torque.
4. Do a clean rebuild.
5. Go to the GUI of your choice and add a GuiCommanderHud to it. Poof, instant GUI!
Security and Scoping Issues:
The HUD is designed to prevent people from abusing it in-game. It does not change how anything is scoped, so people will only see what the net code would have previously allowed them to see. If you want to have a special "commander map" behavior that shows all active objects you will need to add it either via server side scripting or in GameConnection::doneScopingScene(). Remember, the best way to prevent cheating and improve net performance on your game is to only scope what people need to see.
If you're particularly paranoid, you may want to remove the ConsoleMethods at the end of the file and control the commander map with events; this is probably unnecessary in most cases, as the commander map reveals no more information than the player could get by opening a map in single player mode or a dedicated server and flying/walking around.
Panning and Zooming:
There are three useful actions you can do via scripting with the GuiCommanderHud. First, you can zoom. This basically consists of changing the FOV of the overhead camera that the view is being rendered from (see GuiCommanderHud::processCameraQuery()), so you want to stick to values between 0 and one half pi. Larger values can give "interesting" results though no value should crash the engine. The available script methods for this are zoom() to instantly set the zoom level and zoomTo() to smoothly interpolate to the requested zoom level.
pan() and panTo() let you set the x,y co-ordinates of the overhead camera - essentially setting where the center of the map is. If you wish to pan onto an object, get the first two words of its position and pass them to pan() or panTo().
There are also two exposed fields, panSpeed and zoomSpeed, which let you tweak how quickly panning and zooming occurs. Negative values for these will give catastrophic results!
Performance:
On a 1.8Ghz P4 with 512mb of RAM and a GeForce 4 440 Go (equivalent to a fast GeForce 2), I get 70fps in the test FPS level without the map on screen, and 40fps with it on the screen (in addition to the normal FPS view). Suggested usage is to run the GuiCommanderHud in its own GUI, so that you don't have the overhead of the PlayGUI and its view of the world.
The GuiCommanderHud only renders interior, terrain, water, and environmental objects. You can easily change the mask it uses for rendering the scene by editing GuiCommanderHud::renderWorld() - there is a comment to guide you. Re-enabling all DTS shapes will bring a significant performance hit, since you'll be rendering potentially all the objects in the game world!
Extensions:
There are three major areas in which the GuiCommanderHud could be extended for your game.
First, you may want to render an overlay or icons indicating where objectives/players are. There is a comment located where you would want to render these objects, in GuiCommanderHud::onRender(). Using standard DGL calls will give good results.
Second, you may want to have the control handle mouse input. Looking at EditTSCtrl (located in engine/editor/editTSCtrl.*) will be an excellent guide for this process. You could either inherit from EditTSCtrl, or copy its mouse handling code to the GuiCommanderHud. The project() and unproject() functions that GuiCommmanderHud inherits from GuiTSCtrl may also be useful here.
Finally, you may wish to optimize rendering speed by caching output to a texture, rendering only the texture, and updating the texture as needed when the map needs to change its view. (You could even render to a large texture and simply pan it around, though this would kill the neat parallaxing and depth buffering effects that you could gain from actually rendering the world into the GuiCommanderHud.) This would be a bit tricky, but GuiCommanderHud::onRender would be your starting point. Look at TSShapeInstance::snapshot() for guidance on how to implement this sort of functionality in OpenGL - beware that the DirectX layer may not place nice with this.
Usage Restrictions:
None. Knock yourself out! :) I would ask that you put my name in your credits somewhere and send me a free copy of your game if this resource is a major piece of functionality for your project, but you are by no means required to do so. I'd also appreciate it if, if you found bugs or made enhancements for the code, if you'd send me your change(s) so I can merge them back into this resource. Many eyes find more bugs. ;)
Addendums:
Neat bit of code to try from the console(replace 1494 with the SimObject you want to track). Notice my commander hud is named commHud.
To use this resource:
1. Copy guiCommanderHud.cc to your engine/gui subfolder.
2. Open your IDE of choice (or a text editor if that's what you like).
3. Add the source file to your project so it will be compiled into Torque.
4. Do a clean rebuild.
5. Go to the GUI of your choice and add a GuiCommanderHud to it. Poof, instant GUI!
Security and Scoping Issues:
The HUD is designed to prevent people from abusing it in-game. It does not change how anything is scoped, so people will only see what the net code would have previously allowed them to see. If you want to have a special "commander map" behavior that shows all active objects you will need to add it either via server side scripting or in GameConnection::doneScopingScene(). Remember, the best way to prevent cheating and improve net performance on your game is to only scope what people need to see.
If you're particularly paranoid, you may want to remove the ConsoleMethods at the end of the file and control the commander map with events; this is probably unnecessary in most cases, as the commander map reveals no more information than the player could get by opening a map in single player mode or a dedicated server and flying/walking around.
Panning and Zooming:
There are three useful actions you can do via scripting with the GuiCommanderHud. First, you can zoom. This basically consists of changing the FOV of the overhead camera that the view is being rendered from (see GuiCommanderHud::processCameraQuery()), so you want to stick to values between 0 and one half pi. Larger values can give "interesting" results though no value should crash the engine. The available script methods for this are zoom() to instantly set the zoom level and zoomTo() to smoothly interpolate to the requested zoom level.
pan() and panTo() let you set the x,y co-ordinates of the overhead camera - essentially setting where the center of the map is. If you wish to pan onto an object, get the first two words of its position and pass them to pan() or panTo().
There are also two exposed fields, panSpeed and zoomSpeed, which let you tweak how quickly panning and zooming occurs. Negative values for these will give catastrophic results!
Performance:
On a 1.8Ghz P4 with 512mb of RAM and a GeForce 4 440 Go (equivalent to a fast GeForce 2), I get 70fps in the test FPS level without the map on screen, and 40fps with it on the screen (in addition to the normal FPS view). Suggested usage is to run the GuiCommanderHud in its own GUI, so that you don't have the overhead of the PlayGUI and its view of the world.
The GuiCommanderHud only renders interior, terrain, water, and environmental objects. You can easily change the mask it uses for rendering the scene by editing GuiCommanderHud::renderWorld() - there is a comment to guide you. Re-enabling all DTS shapes will bring a significant performance hit, since you'll be rendering potentially all the objects in the game world!
Extensions:
There are three major areas in which the GuiCommanderHud could be extended for your game.
First, you may want to render an overlay or icons indicating where objectives/players are. There is a comment located where you would want to render these objects, in GuiCommanderHud::onRender(). Using standard DGL calls will give good results.
Second, you may want to have the control handle mouse input. Looking at EditTSCtrl (located in engine/editor/editTSCtrl.*) will be an excellent guide for this process. You could either inherit from EditTSCtrl, or copy its mouse handling code to the GuiCommanderHud. The project() and unproject() functions that GuiCommmanderHud inherits from GuiTSCtrl may also be useful here.
Finally, you may wish to optimize rendering speed by caching output to a texture, rendering only the texture, and updating the texture as needed when the map needs to change its view. (You could even render to a large texture and simply pan it around, though this would kill the neat parallaxing and depth buffering effects that you could gain from actually rendering the world into the GuiCommanderHud.) This would be a bit tricky, but GuiCommanderHud::onRender would be your starting point. Look at TSShapeInstance::snapshot() for guidance on how to implement this sort of functionality in OpenGL - beware that the DirectX layer may not place nice with this.
Usage Restrictions:
None. Knock yourself out! :) I would ask that you put my name in your credits somewhere and send me a free copy of your game if this resource is a major piece of functionality for your project, but you are by no means required to do so. I'd also appreciate it if, if you found bugs or made enhancements for the code, if you'd send me your change(s) so I can merge them back into this resource. Many eyes find more bugs. ;)
Addendums:
Neat bit of code to try from the console(replace 1494 with the SimObject you want to track). Notice my commander hud is named commHud.
commHud.zoomTo(0.02);
function panPlayer() { commHud.panTo(getWord(1494.getPosition(), 0), getWord(1494.getPosition(), 1)); schedule(100, 0, panPlayer); }
panPlayer();
#102
05/02/2007 (11:11 am)
Thx Ben :) I'm going to see that
#103
05/02/2007 (11:50 am)
Sorry Ben but i don't find this code... Can you give me a portion of this code ? I have searched in Atlas/runtime/AtlasInstance2 .h/cpp ...
#104
It skips the clipmap recentering if it's a reflection; you need to make it additionally skip if it's a minimap render.
05/02/2007 (11:59 am)
The check is in these lines (around ln 349 of atlasInstance.cpp)// Synch up with the atlas file.
if(!gClientSceneGraph->isReflectPass())
{
PROFILE_START(reflectPass);It skips the clipmap recentering if it's a reflection; you need to make it additionally skip if it's a minimap render.
#105
In scenegraph.h :
void setReflectPass( bool isReflecting ) { mReflectPass = isReflecting; }
bool isReflectPass(){ return mReflectPass; }
void setMiniMapPass( bool isMiniMap ) { mMiniMapPass = isMiniMap; } << added
bool isMiniMapPass(){ return mMiniMapPass; } << added
In AtlasInstance2.cpp :
// Synch up with the atlas file.
if(!gClientSceneGraph->isReflectPass() && !gClientSceneGraph->isMiniMapPass()) << modifed
In MiniMap.cpp : (renderWorld)
//TerrainRender::mRenderingCommander = true;
gClientSceneGraph->setMiniMapPass(true); << added
//TerrainRender::mRenderingCommander = false;
gClientSceneGraph->setMiniMapPass(false); << added
But same probleme ... Help me lol
05/02/2007 (12:36 pm)
I have added some code :In scenegraph.h :
void setReflectPass( bool isReflecting ) { mReflectPass = isReflecting; }
bool isReflectPass(){ return mReflectPass; }
void setMiniMapPass( bool isMiniMap ) { mMiniMapPass = isMiniMap; } << added
bool isMiniMapPass(){ return mMiniMapPass; } << added
In AtlasInstance2.cpp :
// Synch up with the atlas file.
if(!gClientSceneGraph->isReflectPass() && !gClientSceneGraph->isMiniMapPass()) << modifed
In MiniMap.cpp : (renderWorld)
//TerrainRender::mRenderingCommander = true;
gClientSceneGraph->setMiniMapPass(true); << added
//TerrainRender::mRenderingCommander = false;
gClientSceneGraph->setMiniMapPass(false); << added
But same probleme ... Help me lol
#106
It's too difficult for a noob lol
05/02/2007 (1:10 pm)
I add the GUI editor Crash when i enter in PlayGui edition..It's too difficult for a noob lol
#107
With a atlas terrain a can't set the camera's Zcoord enough big to see all the terrain.
In fact if it is too big it crash (DEBUG : Error alloc too large, increase frame size!)
Is there a solution ?
05/03/2007 (2:46 pm)
I'm trying to create my own minimap but i'm confronted to a big issue...With a atlas terrain a can't set the camera's Zcoord enough big to see all the terrain.
In fact if it is too big it crash (DEBUG : Error alloc too large, increase frame size!)
Is there a solution ?
#108
What's causing the frameallocator to blow up?
05/03/2007 (2:51 pm)
I'd use an orthographic projection.What's causing the frameallocator to blow up?
#109
I think i have forgotten something but TSE engine is new for me ..
here is the error :
query->cameraMatrix.setPosition(Point3F(mCurPos.x,mCurPos.y,mCurPos.z+5000));
5000 is too big... when i set it to 1500 there is no crash...
GuiMiniControl.h
GuiMiniControl.cpp
05/03/2007 (3:01 pm)
I don't know .. it is in my code not in your code :)I think i have forgotten something but TSE engine is new for me ..
here is the error :
query->cameraMatrix.setPosition(Point3F(mCurPos.x,mCurPos.y,mCurPos.z+5000));
5000 is too big... when i set it to 1500 there is no crash...
GuiMiniControl.h
#ifndef _GUIMINICTRL_H_
#define _GUIMINICTRL_H_
#include "console/consoleTypes.h"
#include "game/projectile.h"
#include "game/gameBase.h"
#include "game/gameConnection.h"
#include "game/shapeBase.h"
#include "game/player.h"
#include "sceneGraph/sceneGraph.h"
#include "terrain/sky.h"
#include "game/collisionTest.h"
#ifndef _GAME_H_
#include "game/game.h"
#endif
#ifndef _GUITSCONTROL_H_
#include "gui/core/guiTSControl.h"
#endif
class ProjectileData;
class GameBase;
//----------------------------------------------------------------------------
class GuiMiniCtrl : public GuiTSCtrl
{
private:
typedef GuiTSCtrl Parent;
U32 MaxZoomSpeed; ///< max number of ms to reach target FOV
F32 sConsoleCameraFov; ///< updated to camera FOV each frame
F32 sCameraFov; ///< current camera FOV
F32 sTargetFov; ///< the desired FOV
F32 sLastCameraUpdateTime; ///< last time camera was updated
S32 sZoomSpeed; ///< ms per 90deg fov change
CollisionTest collisionTest;
public:
Point2F mPanGoal, mCurPan;
F32 mZoomGoal, mCurZoom;
GuiMiniCtrl();
bool processCameraQuery(CameraQuery *query);
void renderWorld(const RectI &updateRect);
void onMouseMove(const GuiEvent &evt);
void onRender(Point2I offset, const RectI &updateRect);
void MiniUpdateCameraFov();
bool MiniGetCameraTransform(MatrixF *mat, Point3F *velocity);
DECLARE_CONOBJECT(GuiMiniCtrl);
};
#endifGuiMiniControl.cpp
#include "gui/minimap/guiMiniControl.h"
//---------------------------------------------------------------------------
// Debug stuff:
Point3F MinilineTestStart = Point3F(0, 0, 0);
Point3F MinilineTestEnd = Point3F(0, 1000, 0);
Point3F MinilineTestIntersect = Point3F(0, 0, 0);
bool gMiniSnapLine = false;
static void findObjectsCallback(SceneObject* obj, void * val)
{
Vector<SceneObject*> * list = (Vector<SceneObject*>*)val;
list->push_back(obj);
}
//----------------------------------------------------------------------------
// Class: GuiMiniCtrl
//----------------------------------------------------------------------------
IMPLEMENT_CONOBJECT(GuiMiniCtrl);
GuiMiniCtrl::GuiMiniCtrl()
{
MaxZoomSpeed = 2000; ///< max number of ms to reach target FOV
sConsoleCameraFov = 90.f; ///< updated to camera FOV each frame
sCameraFov = 90.f; ///< current camera FOV
sTargetFov = 90.f; ///< the desired FOV
sLastCameraUpdateTime = 0; ///< last time camera was updated
sZoomSpeed = 500; ///< ms per 90deg fov change
}
//---------------------------------------------------------------------------
bool GuiMiniCtrl::processCameraQuery(CameraQuery *query)
{
MiniUpdateCameraFov();
GameConnection* connection = GameConnection::getConnectionToServer();
if (connection && connection->getControlCameraTransform(0.032f, &query->cameraMatrix))
{
Point3F mCurPos = query->cameraMatrix.getPosition();
query->cameraMatrix = MatrixF(EulerF(3.14/2, 0, 0));
query->cameraMatrix.setPosition(Point3F(mCurPos.x,mCurPos.y,mCurPos.z+5000));
query->object = connection->getControlObject();
query->nearPlane = 0.1f;
//Sky* pSky = gClientSceneGraph->getCurrentSky();
//if (pSky)
//query->farPlane = pSky->getVisibleDistance();
//else
query->farPlane = 10000.0f;
F32 cameraFov;
if(!connection->getControlCameraFov(&cameraFov))
return false;
query->fov = mDegToRad(cameraFov);
return true;
}
return false;
}
//---------------------------------------------------------------------------
void GuiMiniCtrl::renderWorld(const RectI &updateRect)
{
F32 oldVisDist = gClientSceneGraph->getVisibleDistance();
gClientSceneGraph->setVisibleDistance(10000);
F32 oldFogDist = gClientSceneGraph->getFogDistance();
gClientSceneGraph->setFogDistance(10000);
PROFILE_START(MiniRenderWorld);
FrameAllocator::setWaterMark(0);
GFX->setZEnable( true );
GFX->setZFunc( GFXCmpLessEqual );
GFX->clear( GFXClearZBuffer | GFXClearStencil | GFXClearTarget, ColorI(0,0,0), 1.0f, 0 );
#if defined(TORQUE_GATHER_METRICS) && TORQUE_GATHER_METRICS > 1
TextureManager::smTextureCacheMisses = 0;
#endif
// Need to consoldate to one clear call
GFX->setCullMode( GFXCullNone );
//
gClientSceneGraph->renderScene( StaticObjectType | WaterObjectType);
GFX->setZEnable( false );
collisionTest.render();
#if defined(TORQUE_GATHER_METRICS) && TORQUE_GATHER_METRICS > 1
Con::setFloatVariable("Video::texResidentPercentage",
TextureManager::getResidentFraction());
Con::setIntVariable("Video::textureCacheMisses",
TextureManager::smTextureCacheMisses);
#endif
AssertFatal(FrameAllocator::getWaterMark() == 0, "Error, someone didn't reset the water mark on the frame allocator!");
FrameAllocator::setWaterMark(0);
PROFILE_END();
gClientSceneGraph->setVisibleDistance(oldVisDist);
gClientSceneGraph->setFogDistance (oldFogDist);
GFX->setClipRect(updateRect);
}
//---------------------------------------------------------------------------
void GuiMiniCtrl::onMouseMove(const GuiEvent &evt)
{
if(gMiniSnapLine)
return;
MatrixF mat;
Point3F vel;
if ( MiniGetCameraTransform(&mat, &vel) )
{
Point3F pos;
mat.getColumn(3,&pos);
Point3F screenPoint(evt.mousePoint.x, evt.mousePoint.y, -1);
Point3F worldPoint;
if (unproject(screenPoint, &worldPoint)) {
Point3F vec = worldPoint - pos;
MinilineTestStart = pos;
vec.normalizeSafe();
MinilineTestEnd = pos + vec * 1000;
}
}
}
void GuiMiniCtrl::onRender(Point2I offset, const RectI &updateRect)
{
// check if should bother with a render
GameConnection * con = GameConnection::getConnectionToServer();
bool skipRender = !con || (con->getWhiteOut() >= 1.f) || (con->getDamageFlash() >= 1.f) || (con->getBlackOut() >= 1.f);
if(!skipRender)
Parent::onRender(offset, updateRect);
GFX->setViewport( updateRect );
}
void GuiMiniCtrl::MiniUpdateCameraFov()
{
F32 time = F32(Platform::getVirtualMilliseconds());
F32 delta = time - sLastCameraUpdateTime;
// need to update fov?
if(sTargetFov != sCameraFov && delta > 0.0f)
{
// snap zoom?
if(sZoomSpeed == 0)
sCameraFov = sTargetFov;
else
{
// gZoomSpeed is time in ms to zoom 90deg
F32 step = 90.f * (delta / F32(sZoomSpeed));
if(sCameraFov > sTargetFov)
{
sCameraFov -= step;
if(sCameraFov < sTargetFov)
sCameraFov = sTargetFov;
}
else
{
sCameraFov += step;
if(sCameraFov > sTargetFov)
sCameraFov = sTargetFov;
}
}
}
// the game connection controls the vertical and the horizontal
GameConnection * connection = GameConnection::getConnectionToServer();
if(connection)
{
// check if fov is valid on control object
if(connection->isValidControlCameraFov(sCameraFov))
connection->setControlCameraFov(sCameraFov);
else
{
// will set to the closest fov (fails only on invalid control object)
if(connection->setControlCameraFov(sCameraFov))
{
F32 setFov = sCameraFov;
connection->getControlCameraFov(&setFov);
sTargetFov = sCameraFov = setFov;
}
}
}
// update the console variable
sConsoleCameraFov = sCameraFov;
sLastCameraUpdateTime = time;
}
bool GuiMiniCtrl::MiniGetCameraTransform(MatrixF *mat, Point3F *velocity)
{
// Return the position and velocity of the control object
GameConnection* connection = GameConnection::getConnectionToServer();
return connection && connection->getControlCameraTransform(0, mat) &&
connection->getControlCameraVelocity(velocity);
}
//--------------------------------------------------------------------------
ConsoleFunction( MinisnapToggle, void, 1, 1, "()" )
{
gMiniSnapLine = !gMiniSnapLine;
}
#110
BTW... I've noticed that I can't use GFX-drawbitmap... For some reason it doesnt draw. When I have a gui on top of it... It will draw the bitmap when it gets over the GUI. I'm thinking of creating guiBitmapsCtrl for layer icons, altough it doesn't seem like thie correct way of doing it.
05/04/2007 (3:07 am)
Ben... I was going to ask about orthographic projection. Is there an easy code change for that?BTW... I've noticed that I can't use GFX-drawbitmap... For some reason it doesnt draw. When I have a gui on top of it... It will draw the bitmap when it gets over the GUI. I'm thinking of creating guiBitmapsCtrl for layer icons, altough it doesn't seem like thie correct way of doing it.
#111
I have seen in a other forum that for create a orthographic projection we need to set
query-> ortho at true with query a object of CameraQuery. I will try this night (in france lol)
05/04/2007 (3:59 am)
I don't know if it is your question James butI have seen in a other forum that for create a orthographic projection we need to set
query-> ortho at true with query a object of CameraQuery. I will try this night (in france lol)
#112
05/04/2007 (4:02 am)
Duh... Didn't even see that... Thanx Christopher.
#113
05/04/2007 (4:43 am)
I have seen that here : http://www.garagegames.com/mg/forums/result.thread.php?qt=22927
#114
05/04/2007 (5:46 am)
Not sure about TGE, but in TGEA there is no query->ortho member. I'll just play with the FOV in the meantime as mentioned in the thread you posted.
#115
05/04/2007 (6:33 am)
i will test tonight but i think there is no solution for my probleme :(
#116
Now, implementing a bitmap image into this code for TGEA is a big question on where to begin.
05/07/2007 (11:47 am)
You know, it would make more sense to use bitmap for Atlas than trying to get it to render the entire map. Especially if the missions are very large in size.Now, implementing a bitmap image into this code for TGEA is a big question on where to begin.
#117
Here my non-working Render code (TGEA):
Note that I'm trying to rendering bitmaps where my (Flying)Vehicles are.
Maybe I'm doing something small wrong?
05/08/2007 (12:43 am)
Absolutely, Andy... getting a bitmap in should be done by using a GFX->Drawbitmap function, however I did not get it working for some strange reason. It seems a bitmap just doesn't want to draw without a GuiControl underneath it. Here my non-working Render code (TGEA):
void GuiCommanderHud::onRender(Point2I offset, const RectI &updateRect)
{
// Update pan/zoom
S32 time = Platform::getVirtualMilliseconds();
S32 dt = time - mLastRenderTime;
mLastRenderTime = time;
mCurPan += (mPanGoal - mCurPan) * (F32)dt/1000.f;
mCurZoom += (mZoomGoal - mCurZoom) * (F32)dt/1000.f;
// Render the world...
Parent::onRender(offset, updateRect);
//-------------------------------------------------------------------------
// Render Vehicles
//-------------------------------------------------------------------------
GameConnection* conn = GameConnection::getConnectionToServer();
if (!conn) return;
GFX->setZEnable(false);
GFX->setZWriteEnable(false);
GFX->clearBitmapModulation();
GFXTextureObject* imgAllies = (GFXTextureObject*) mAlliesImage;
// Go through all ghosted objects on connection (client-side)
for (SimSetIterator itr(conn); *itr; ++itr) {
// Make sure that the object is a shapebase object
if ((*itr)->getType() & ShapeBaseObjectType) {
//Cast the Iteration Object to a ShapeBase
ShapeBase* shape = static_cast<ShapeBase*>(*itr);
// Make sure the shapebase object is a vehicle
if (shape->getType() & VehicleObjectType) {
Point3F newCoord;
// Get coords of shape object
newCoord = shape->getPosition();
Point3F DestCoord;
if (!project(newCoord, &DestCoord))
continue;
// Draw Images
if (imgAllies)
{
// Center the Image
DestCoord.x -= (imgAllies->getWidth() / 2);
DestCoord.y -= (imgAllies->getHeight() / 2);
//Con::printf("Drawing Bitmap at (%f, %f)",DestCoord.x,DestCoord.y);
GFX->drawBitmap(imgAllies, Point2I((S32)DestCoord.x, (S32)DestCoord.y));
}//If ImgAllies
}//Is Vehicle
}//Is ShapeBaseObjectType
}//SimSetIterator Loop
renderChildControls(offset,updateRect);
}Note that I'm trying to rendering bitmaps where my (Flying)Vehicles are.
Maybe I'm doing something small wrong?
#118
05/08/2007 (5:04 am)
if fact it is a good idea to render a simple bitmap :) i will try in this direction
#119
Also, it would be cool if we could have a "Arrow" or something in the center of the map, showing where you are on the map. Something that could rotate as the mouse moves.
05/08/2007 (6:48 am)
If we can get the render world to use a bitmap of the terrain for the map, I think this will resolve all the issues. I'm having trouble getting it to read a bitmap.Also, it would be cool if we could have a "Arrow" or something in the center of the map, showing where you are on the map. Something that could rotate as the mouse moves.
#120
Added to public vars in class declaration:
Added to GuiMapHud constructor:
Added to initPersistFields definition:
renderGrid() method:
Added to onRender method:
No matter what origin I use for renderGrid, or what color I specify, I can't see a grid rendered to the screen. I stepped through the code, and the values all seem valid and the the methods step properly.
Any suggestions would be greatly appreciated =)
05/18/2007 (6:24 am)
Hmm, I'm attempting to draw a grid (got the code from WorldEditor) over the map so players inform team mates of their location based on square positions. Rendering code isn't my strongest area, so I was wondering if someone could have a look:Added to public vars in class declaration:
ColorI mGridColor; F32 mPlaneDim; Point3F mGridSize; void renderGrid(Point3F& origin);
Added to GuiMapHud constructor:
mGridColor.set(255,255,255,20); // MP - White Grid mGridSize.set(10,10,10); // MP - 10 meter separations mPlaneDim = 500;
Added to initPersistFields definition:
addField("gridColor", TypeColorI, Offset(mGridColor, GuiMapHud), "Set the color of the grid overlay.");
addField("planeDim", TypeF32, Offset(mPlaneDim, GuiMapHud), "Used to process grid rendering/steps.");
addField("gridSize", TypePoint3F, Offset(mGridSize, GuiMapHud), "Set the size of the grid.");renderGrid() method:
void GuiMapHud::renderGrid(Point3F& origin)
{
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4ub(mGridColor.red, mGridColor.green, mGridColor.blue, mGridColor.alpha);
//Point3F origin(0.0f, 0.0f, 0.0f);
Point2F start(origin.x - mPlaneDim / 2, origin.y - mPlaneDim / 2);
// MP - No sense rendering the plane right now, we just want a grid
// draw the plane
glBegin(GL_QUADS);
glVertex3f(start.x, start.y, origin.z);
glVertex3f(start.x, start.y + mPlaneDim, origin.z);
glVertex3f(start.x + mPlaneDim, start.y + mPlaneDim, origin.z);
glVertex3f(start.x + mPlaneDim, start.y, origin.z);
glEnd();
//
if(mGridSize.x > 0)
{
U32 xSteps = (U32)(mPlaneDim / mGridSize.x);
F32 hashStart = mCeil(start.x / mGridSize.x) * mGridSize.x;
for(U32 i = 0; i < xSteps; i++)
{
glBegin(GL_LINE_LOOP);
glVertex3f(hashStart + mGridSize.x * i, start.y, origin.z + 0.001f);
glVertex3f(hashStart + mGridSize.x * i, start.y + mPlaneDim, origin.z + 0.001f);
glEnd();
}
}
if(mGridSize.y > 0)
{
U32 ySteps = (U32)(mPlaneDim / mGridSize.y);
F32 hashStart = mCeil(start.y / mGridSize.y) * mGridSize.y;
for(U32 i = 0; i < ySteps; i++)
{
glBegin(GL_LINE_LOOP);
glVertex3f(start.x, hashStart + mGridSize.y * i, origin.z + 0.001f);
glVertex3f(start.x + mPlaneDim, hashStart + mGridSize.y * i, origin.z + 0.001f);
glEnd();
}
}
glDisable(GL_BLEND);
}Added to onRender method:
// If you wanted to render custom GUI elements, like a sensor map, icons for // players/vehicles/objectives, you would do it here by calling project() // for all their positions and drawing bitmaps at the appropriate locations. renderGrid(Point3F(75, -210, 200));
No matter what origin I use for renderGrid, or what color I specify, I can't see a grid rendered to the screen. I stepped through the code, and the values all seem valid and the the methods step properly.
Any suggestions would be greatly appreciated =)

Associate Kyle Carter
If you look there is code in AtlasInstance2 to suppress loader updates when drawing reflections. You'll need to extend that to apply to the minimap render as well, or face dire performance consequences.