Rts Port To Tgea
by Johnathan Moore · in RTS Starter Kit · 05/06/2006 (2:45 pm) · 62 replies
Hey, I have tried to port the rts starter kit over to the latest TSE. I have solved nearly all the errors apart from lot of files need a file dgl/dgl.h. It either stands for somthing to do with open gl or dynamic game lighting(could someone clear that up) either way this hasnt been intergrated into TSE yet. So has anyone managed to port the RTS kit to TSE yet?, or all but the selection circles on atlas.
the other errors I get are
but that may be because I am using vc2005
Edit: after installing the directx sdk propally I am left with only the dgl error
the other errors I get are
#include <d3d9.h> & #include <dinput.h>
but that may be because I am using vc2005
Edit: after installing the directx sdk propally I am left with only the dgl error
About the author
Been tinkering with this since I was young.
#22
08/01/2006 (9:33 am)
The code of fxZoo.cpp : // fxZoo.cpp
#include "platform/platform.h"
#include "gfx/gfxDevice.h"
#include "gfx/PrimBuilder.h" // Used for debug / mission edit rendering
#include "console/consoleTypes.h"
#include "core/bitStream.h"
#include "math/mRandom.h"
#include "math/mathIO.h"
#include "terrain/terrData.h"
#include "game/gameConnection.h"
#include "console/simBase.h"
#include "materials/matInstance.h"
#include "materials/sceneData.h"
#include "sceneGraph/sceneGraph.h"
#include "fxZoo.h"
#include "atlas/runtime/atlasInstance2.h"
#include "atlas/editor/atlasDiscreteMesh.h"
#include "renderInstance/renderInstMgr.h"
IMPLEMENT_CO_NETOBJECT_V1(fxZ);
fxZ::fxZ()
{
mTypeMask |= StaticObjectType | StaticTSObjectType | StaticRenderedObjectType;
mNetFlags.set(Ghostable | ScopeAlways);
}
fxZ::~fxZ()
{
}
bool fxZ::onAdd()
{
if(!Parent::onAdd()) return(false);
// Set Default Object Box.
mObjBox.min.set( -10000.0, -10000.0, -10000.0 );
mObjBox.max.set( 10000.0, 10000.0, 10000.0 );
// Reset the World Box.
resetWorldBox();
// Set the Render Transform.
setRenderTransform(mObjToWorld);
// Add to Scene.
addToScene();
if (isClientObject()) { Buildtris(); }
// Return OK.
return(true);
}
void fxZ::onRemove()
{
// Remove from Scene.
removeFromScene();
// Do Parent.
Parent::onRemove();
}
void fxZ::initPersistFields()
{
Parent::initPersistFields();
// addGroup("misc"); // MM: Added Group Header.
// addField( "textColor", TypeColorF, Offset( mTextColor, fxZ ) );
// endGroup("Misc"); // MM: Added Group Footer.
}
U32 fxZ::packUpdate(NetConnection * con, U32 mask, BitStream * stream)
{
// Pack Parent.
U32 retMask = Parent::packUpdate(con, mask, stream);
// Write Foliage Replication Flag.
if (stream->writeFlag(mask & fxZMask))
{
stream->writeAffineTransform(mObjToWorld); // Foliage Master-Object Position.
// stream->write(mTextColor); // Foliage Debug Height.
}
// Were done ...
return(retMask);
}
void fxZ::unpackUpdate(NetConnection * con, BitStream *stream)
{
// Unpack Parent.
Parent::unpackUpdate(con, stream);
// Read Replication Details.
if(stream->readFlag())
{
MatrixF fxZMatrix;
stream->readAffineTransform(&fxZMatrix); // Foliage Master Object Position.
// stream->read(&mTextColor); // Foliage Debug Height.
// Set Transform.
setTransform(fxZMatrix);
}
}
bool fxZ::prepRenderImage(SceneState* state, const U32 stateKey, const U32 /*startZone*/,
const bool /*modifyBaseZoneState*/)
{
// Return if last state.
if (isLastState(state, stateKey)) return false;
// Set Last State.
setLastState(state, stateKey);
// Is Object Rendered?
if (state->isObjectRendered(this))
{
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Object;
gRenderInstManager.addInst( ri );
}
return false;
}
void fxZ::renderObject(SceneState* state, RenderInst *ri)
{
PROFILE_START(fxZ_renderObject);
GFX->pushState();
// Set up projection and world transform info.
GFX->pushWorldMatrix();
GFX->multWorld(getRenderTransform());
MatrixF scaleMat(1);
scaleMat.scale(getScale());
GFX->multWorld(scaleMat);
MatrixF world = GFX->getWorldMatrix();
MatrixF proj = GFX->getProjectionMatrix();
proj.mul(world);
proj.transpose();
GFX->setVertexShaderConstF( 0, (float*)&proj, 4 );
// Set up rendering state
GFX->setBaseRenderState();
GFX->disableShaders();
// and now do the full textured material.
/*enum GFXTextureAddressMode
{
GFXAddress_FIRST = 0,
GFXAddressWrap = 0,
GFXAddressMirror,
GFXAddressClamp,
GFXAddressBorder,
GFXAddressMirrorOnce,
GFXAddress_COUNT
};*/
MatInstance mat("fxZm");
SceneGraphData sgData;
// Store object and camera transform data
sgData.objTrans = getRenderTransform() * scaleMat;
sgData.camPos = state->getCameraPosition();
// Set up fogging.
sgData.useFog = true;
sgData.fogTex = gClientSceneGraph->getFogTexture();
sgData.fogHeightOffset = gClientSceneGraph->getFogHeightOffset();
sgData.fogInvHeightRange = gClientSceneGraph->getFogInvHeightRange();
sgData.visDist = gClientSceneGraph->getVisibleDistanceMod();
// grab the sun data from the light manager
const Vector<LightInfo*> & lights = gClientSceneGraph->getLightManager()->getLights();
VectorF sunVector = lights[0]->mDirection; //first light is always sun
// set the sun data into scenegraph data
sgData.lights[0].mDirection.set( sunVector );
sgData.lights[0].mPos.set( sunVector * -10000.0 );
sgData.lights[0].mAmbient = lights[0]->mAmbient;
sgData.lights[0].mColor = lights[0]->mColor;
mat.init(sgData, (GFXVertexFlags) (GFXVertexFlagUV0)); //getGFXVertFlags( (GFXAtlasVert2*)NULL));
GFX->setTextureStageAddressModeU(0, GFXAddressWrap );
GFX->setTextureStageAddressModeV(0, GFXAddressWrap );
GFX->setTextureStageColorOp(0, GFXTOPDisable);
// GFX->setTextureStageColorOp( 0, GFXTOPModulate);
/* GFX->setTextureStageAddressModeU( 1, GFXAddressWrap );
GFX->setTextureStageAddressModeV( 1, GFXAddressWrap );
GFX->setTextureStageColorOp( 1, GFXTOPModulate);
GFX->setTexture(1, gClientSceneGraph->getFogTexture());*/
// Blend ops
GFX->setAlphaBlendEnable( true );
GFX->setAlphaTestEnable( true );
GFX->setSrcBlend(GFXBlendSrcAlpha);
GFX->setDestBlend(GFXBlendInvSrcAlpha);
GFX->setAlphaFunc( GFXCmpGreaterEqual );
GFX->setAlphaRef(10);
GFX->setZWriteEnable( true );
GFX->setCullMode(GFXCullNone);
//GFX->setCullMode(state->mFlipCull ? GFXCullCW : GFXCullCCW);
while(mat.setupPass(sgData))
{
// Setup our buffers
GFX->setVertexBuffer(mVertexBuffer);
GFX->setPrimitiveBuffer(mPrimBuffer);
// If we use culling, we're going to send chunks of our buffers to the card
GFX->drawIndexedPrimitive(GFXTriangleList, 0, mVertexBuffer->mNumVerts, 0, mPrimBuffer->mIndexCount / 3);
}
GFX->setAlphaBlendEnable( false );
GFX->setAlphaTestEnable( false );
GFX->setTextureStageColorOp(0, GFXTOPDisable);
GFX->popWorldMatrix();
GFX->popState();
PROFILE_END();
}
void fxZ::Buildtris()
{
bool CollisionResult;
RayInfo RayEvent;
Point3F fxZStart;
Point3F fxZEnd;
[B] fxZStart.x = fxZEnd.x = 1306.16;
fxZStart.y = fxZEnd.y = 1159.13;
fxZStart.z = 2000.0;
fxZEnd.z = -2000.0;[/B]
CollisionResult = gClientContainer.castRay( fxZStart, fxZEnd, FXZ_MASK, &RayEvent);
AtlasInstance2 *Atlas = dynamic_cast<AtlasInstance2 *>(RayEvent.object);
TerrSelectionInfo Sel;
Sel.pos = RayEvent.point;
[B] Sel.radius=10.0;[/B]
Sel.radiusSquared = Sel.radius*Sel.radius;
AtlasDiscreteMesh *liste = Atlas->mGeomTOC->BuildTris(Sel);
mVertexBuffer.set(GFX, liste->mVertexCount, GFXBufferTypeStatic);
mVertexBuffer.lock();
for (U32 vertIndex = 0; vertIndex < liste->mVertexCount; vertIndex++) {
GFXVertexfxz *vert = &mVertexBuffer[vertIndex];
vert->point = liste->mPos[vertIndex];
vert->texCoord = liste->mTex[vertIndex];
}
mVertexBuffer.unlock();
// Init our Primitive Buffer
U32 indexSize = liste->mVertexCount;
U16* indices = new U16[indexSize];
// Two triangles per particle
for (U16 i = 0; i < liste->mVertexCount; i++) {
U16* idx = &indices[i]; // hey, no offset math below, neat
idx[0] = liste->mIndex[i];
}
// Init the prim buffer and copy our indexes over
U16 *ibIndices;
mPrimBuffer.set(GFX, indexSize, 0, GFXBufferTypeStatic);
mPrimBuffer.lock(&ibIndices);
dMemcpy(ibIndices, indices, indexSize * sizeof(U16));
mPrimBuffer.unlock();
Con::printf("Fin du build tris");
//RayEvent.point;
}
ConsoleMethod(fxZ, build, void, 2, 2, "Build triangles")
{
object->Buildtris();
}Edit : Bolded text is to mark hardcoded values. It's intentend to be use by another way.
#23
This code is for test purpose only.
I have problems with UV coordinates out of [0..1] range... I don't know How to ask the engine to no render pixels outside this range.
If someone can tell me how to solve this UV range problem...
Edit : to make this work, type in the console
08/01/2006 (9:39 am)
You also have to add a material.cs like this : new Material(fxZm)
{
baseTex[0] = "tool.htc/data/test.png";
animFlags[0] = $rotate;
rotPivotOffset[0] = "-0.5 -0.5"; // this is the center point UV offset for the rotation.
rotSpeed[0] = 0.2;
glow = true;
};This code is for test purpose only.
I have problems with UV coordinates out of [0..1] range... I don't know How to ask the engine to no render pixels outside this range.
If someone can tell me how to solve this UV range problem...
Edit : to make this work, type in the console
$fxz = new fxz();
#24
08/01/2006 (9:47 am)
Cant wait to try this out,Thanks!
#25
08/01/2006 (9:56 am)
@Josh : I still need some help to solve UV coords problem before making a larger resource.
#26
Click me (right) save target as..

this should be applied to mesh faces with errors
to assist in positioning the face flatten/unwrap
08/01/2006 (10:40 am)
Perhaps this will helpClick me (right) save target as..

this should be applied to mesh faces with errors
to assist in positioning the face flatten/unwrap
#27
08/01/2006 (10:45 am)
@William : The problem is UV Coords greater than 1. I don't know how to tell the engine how to ignore pixels with UV greater than 1.
#28
If you are creating a TSE RTS merge I would elect to create them your self
the ring color is tied to health bar color and hardcoded
posistion of hardcoded color set doesnt allow for seperate colors per team
this means if you drag your mouse over alot of units even the enemy appears selected
and bears the green ring and health bars . Ideally there would be a color difference
between units of different players and teams
as to the Atlas terrain .. Visions project has expressed that they are waiting on an Atlas terrain
FIX from the current TSE work .. I dont think you are alone here on this issue.
08/02/2006 (6:22 pm)
Quote:J.C. SmithTarget circles or "selection ring" was the last problem I had with a RTS ver TGE.14 build
Member Posted: May 24, 2006 10:10
I ported the RTS pack over to TSE the other day. I'm still working on some things, there are no target circles at the moment, though I'm not sure I want them. There is also no map, I'm looking into rigging that up with some map code I wrote for an FPS project a few months ago.
If your having problems with a specific function feel free to poke me and I'll post code.
On a sidenote I haven't yet gotten it working with Atlas terrain, only with legacy terrain under TSE. Will figure it out, but at the moment it's crashing when you click Atlas terrain.
If you are creating a TSE RTS merge I would elect to create them your self
the ring color is tied to health bar color and hardcoded
posistion of hardcoded color set doesnt allow for seperate colors per team
this means if you drag your mouse over alot of units even the enemy appears selected
and bears the green ring and health bars . Ideally there would be a color difference
between units of different players and teams
as to the Atlas terrain .. Visions project has expressed that they are waiting on an Atlas terrain
FIX from the current TSE work .. I dont think you are alone here on this issue.
#29
so to remove the error / warning he is going to have recode for the TSE
to support that function
.............\RTSStarterKit\engine\dgl
i would guess all of the dgl references for this need to be recoded to new functions
08/02/2006 (6:30 pm)
Quote:Ben Curleyunfortunatly what i was trying to express is there is a dgl in RTS
Member Posted: May 07, 2006 02:09
There is no dgl.h in TSE. Have a look in gfxdevice.h for the things you are probably seeking.
For example. Instead of:
dglDrawLine( x1, y1, x2, y2, colour );
you now do:
GFX->drawLine( x1, y1, x2, y2, colour );
so to remove the error / warning he is going to have recode for the TSE
to support that function
.............\RTSStarterKit\engine\dgl
i would guess all of the dgl references for this need to be recoded to new functions
#30
12/18/2006 (2:24 pm)
Any more news on this?
#31
I have problem with this lines :
TSMesh::setGlow( image->glow );
TSMesh::setRefract( image->sortType == SceneRenderImage::Refraction );
with error:
d:\Torque\TGEA\engine\game\RTS\RTSBuilding.cc(49): error C2027: use of undefined type 'SceneRenderImage'
d:\Torque\TGEA\engine\game\RTS\RTSBuilding.cc(50): error C2027: use of undefined type 'SceneRenderImage'
../engine\sim\sceneObject.h(38) : see declaration of 'SceneRenderImage'
Could you help please ..
02/20/2007 (11:42 am)
Hi I have problem with this lines :
TSMesh::setGlow( image->glow );
TSMesh::setRefract( image->sortType == SceneRenderImage::Refraction );
with error:
d:\Torque\TGEA\engine\game\RTS\RTSBuilding.cc(49): error C2027: use of undefined type 'SceneRenderImage'
d:\Torque\TGEA\engine\game\RTS\RTSBuilding.cc(50): error C2027: use of undefined type 'SceneRenderImage'
../engine\sim\sceneObject.h(38) : see declaration of 'SceneRenderImage'
Could you help please ..
#32
02/22/2007 (8:56 am)
There is not SceneRenderImage class in TGEA
#33
03/13/2007 (3:39 pm)
Easily ported over guiRTSTSCtrl and RTSCamera, this was all I needed.
#34
Just wondering what's the purpose of the hardcoded values and how to use them?
Try it on a 10x10 km atlas 2 terrain without success and trace into the code, I find that the isContained test always fail which lead to this problem. Any clue for this?
04/15/2007 (9:20 am)
@Vicent:Just wondering what's the purpose of the hardcoded values and how to use them?
Try it on a 10x10 km atlas 2 terrain without success and trace into the code, I find that the isContained test always fail which lead to this problem. Any clue for this?
#35
07/30/2007 (10:52 am)
I am tryin to port this over, but Im not exactly "good" at c++ so if someone could post their files that wd b awsome :D
#36
enum GFXTextureAddressMode
{
GFXAddress_FIRST = 0,
GFXAddressWrap = 0,
GFXAddressMirror,
GFXAddressClamp,
GFXAddressBorder,
GFXAddressMirrorOnce,
GFXAddress_COUNT
};
The address mode you are looking for is GFXAddressClamp. After a little search I found the engine exposes these functions:
void setTextureStageAddressModeU( U32 stage, GFXTextureAddressMode mode );
void setTextureStageAddressModeV( U32 stage, GFXTextureAddressMode mode );
So, considering your texture is located at stage 0 (because you are using only one texture sample), I guess you are looking for:
GFX->setTextureStageAddressModeU( 0, GFXAddressClamp );
GFX->setTextureStageAddressModeV( 0, GFXAddressClamp );
Never tried these, but if the engine is coherent then it should work.
Luck!
Guimo
08/08/2007 (9:06 am)
Vincent. The command you are looking for is the texture address mode. I find TGEA presents the following address modes:enum GFXTextureAddressMode
{
GFXAddress_FIRST = 0,
GFXAddressWrap = 0,
GFXAddressMirror,
GFXAddressClamp,
GFXAddressBorder,
GFXAddressMirrorOnce,
GFXAddress_COUNT
};
The address mode you are looking for is GFXAddressClamp. After a little search I found the engine exposes these functions:
void setTextureStageAddressModeU( U32 stage, GFXTextureAddressMode mode );
void setTextureStageAddressModeV( U32 stage, GFXTextureAddressMode mode );
So, considering your texture is located at stage 0 (because you are using only one texture sample), I guess you are looking for:
GFX->setTextureStageAddressModeU( 0, GFXAddressClamp );
GFX->setTextureStageAddressModeV( 0, GFXAddressClamp );
Never tried these, but if the engine is coherent then it should work.
Luck!
Guimo
#37
Mine compiles but crashes when you try to start a game.
Henry
12/31/2007 (7:48 am)
Im having some real issues getting it to run and im not quite sure why. Anyone dabbled with this recently?Mine compiles but crashes when you try to start a game.
Henry
#38
01/05/2008 (9:07 am)
I have it running. Minus selection circles. And it did work fine. But now I've got a problem where, I've tried to use the original player class physics for unit characters, oppose to having the network friendlier design. And now the physics has gone messy.
#39
01/15/2008 (5:24 am)
I got it ported over but ive given up on it. This kit is completly useless, its too old to make it worth while updating. Your better off writing your own, which is exactly what ive done :P
#40
I cannot understand this kind of speech. I consider it an extreme form of amateur and naive thinking.
Besides that, you mention that you worked with the kit, but there is NOT ONE comment of yours on the RTS Kit forums that expressed that. Maybe if you had expressed your disagreement on the proper time, some constructive debate could have happened. Now, this, its just flame.
But overall, I cant understand at all, why such people feel compelled to write when others are doing what they couldnt. I this case, and in many others, there are people pushing for do something better, and always appear someone trying to demoralize the whole offort.
The kit has fantastic functionalities, and is an starting point. I believe that, to the point of use it day after day, and besides that, push to make a better product.
01/15/2008 (7:14 am)
And I think the problem of some people is this enormous arrogance... Henry, the kit has some flaws, but do you really believe that you are capable of program an entire subset of RTS functionalities alone? Do you also think that you alone, could do a better job than the team of programmers and testers at GG (who are the core engine owners and developers?)I cannot understand this kind of speech. I consider it an extreme form of amateur and naive thinking.
Besides that, you mention that you worked with the kit, but there is NOT ONE comment of yours on the RTS Kit forums that expressed that. Maybe if you had expressed your disagreement on the proper time, some constructive debate could have happened. Now, this, its just flame.
But overall, I cant understand at all, why such people feel compelled to write when others are doing what they couldnt. I this case, and in many others, there are people pushing for do something better, and always appear someone trying to demoralize the whole offort.
The kit has fantastic functionalities, and is an starting point. I believe that, to the point of use it day after day, and besides that, push to make a better product.
Torque Owner Vincent BILLET
Default Studio Name
I Added a file (fxZoo.h)
// FxZ.h #include "platform/types.h" #define FXZ_MASK ( AtlasObjectType ) DEFINE_VERT( GFXVertexfxz, GFXVertexFlagXYZ | GFXVertexFlagTextureCount1 | GFXVertexFlagUV0 | GFXVertexFlagUV1 ) { Point3F point; Point2F texCoord; }; class fxZ : public SceneObject { typedef SceneObject Parent; protected : GFXShader* mShader; StringTableEntry mfxzTextureFile; GFXTexHandle mfxzTexture; GFXVertexBufferHandle<GFXVertexfxz> mVertexBuffer; GFXPrimitiveBufferHandle mPrimBuffer; public: fxZ(); ~fxZ(); enum { fxZMask = (1 << 0) }; static void initPersistFields(); bool onAdd(); void onRemove(); U32 packUpdate(NetConnection * con, U32 mask, BitStream * stream); void unpackUpdate(NetConnection * con, BitStream *stream); bool prepRenderImage(SceneState* state, const U32 stateKey, const U32 /*startZone*/, const bool /*modifyBaseZoneState*/); void renderObject(SceneState* state, RenderInst *ri); void setupSGData( RenderInst *ri, SceneGraphData &data ); void Buildtris(); DECLARE_CONOBJECT(fxZ); };