Game Development Community

Access Marker data in the engine

by Chris Walters · in Torque Game Engine · 11/25/2002 (12:22 pm) · 3 replies

Hi,

I've got a bunch of Markers within a SimGroup, inside my mission file.

I'm trying to make a new class (ie not a script) who's purpose in life is to plough through the x,y,z data of the Markers and to choose which marker best suits a Bot's needs.

However, I'm stuck...... how do I get access to the data in the markers, in the SimGroup

If it's important, lets call the SimGroup myMarkers, and the Markers can be called m1, m2, m3..... etc.

Any help gratefully accepted.

Cheers.

About the author

Recent Threads


#1
11/25/2002 (2:08 pm)
normally you do it like this:
Note: this isnt tested :P

GameConnection* conn = GameConnection::getServerConnection();
if (!conn) return;

U32 mTypeMask |= StaticShapeObjectType | StaticObjectType;

for (SimSetIterator itr(conn); *itr; ++itr) {
	if ((*itr)->getType() & mTypeMask) {
		WayPoint* marker = static_cast<WayPoint*>(*itr);
		// or?
		//MissionMarker* marker = static_cast<MissionMarker*>(*itr);

it looks like the MissionMarkers are ghosted always, so this *should* work... lemme know if it does... ;)
#2
11/25/2002 (2:11 pm)
... although, to make really sure that you get MissionMarkers with that, you probably should declare a new objectType and change the typeMask for the MissionMarkers in their constructor (and then add a new "MissionMarkerType" in objectTypes.h)...
then check for
if ((*itr)->getType() & MissionMarkerType) {
...
#3
11/26/2002 (12:50 am)
Nightmare....... lost my rather lengthy reply last night cos my LAN dropped out.

Stefan,
Thanks for you reply, I've added your code. Got it to make the result available to the script, broke the loop on the first match.

COOL! kind of works... I get back the SpawnSphere location.

On further inspection I think I'm using a Marker and not a MissionMarker for by botMarkers -mission file is like this:

new SimGroup(BotMarkers) {

      new Marker(bm1) {
         position = "167.215 -174.737 186.714";
         rotation = "1 0 0 0";
         scale = "1 1 1";
         seqNum = "0";
         msToNext = "1000";


So, I found Marker defined in sim/simPath.cc
Inside the Marker constructor it sets mTypeMask = MarkerObjectType

..so far so good :)

Code currently looks like this:

GameConnection* conn = GameConnection::getServerConnection();
if (!conn) return;

U32 mTypeMask = StaticShapeObjectType | StaticObjectType | MarkerObjectType;
//U32 mTypeMask = MarkerObjectType;
for (SimSetIterator itr(conn); *itr; ++itr) {
	if ((*itr)->getType() & mTypeMask) {

		Marker* marker = static_cast<Marker*>(*itr);
		Point3F pos = marker->getPosition() ;

                //make pos available to the script
		mAIObjective.setDestination( pos );
		break; //only want first match for now...
	}
}

Unfortunately I still only get back the position of the SpawnSphere. I've adjusted the break to allow the second iteration of the loop/if to occur, but that returns -1024.000000 -1024.000000 0 which doesn't match any of my markers. I've also tried setting mTypeMask = MarkerObjectType - but that just returns -1024.000000 -1024.000000 0

In the Marker constructor there is this comment:
// Not ghostable unless we're editing...
//mNetFlags.set(Ghostable);

In your post before you mention that MissionMarker is Ghostable....

What does Ghostable mean/do ? Have you got any pointers on where I'm going wrong ?

Thanks alot.