Game Development Community

dev|Pro Game Development Curriculum

Come Fly With Me

by Sean Rice · 03/28/2010 (12:00 pm) · 46 comments

Because this is a paid for resource and not a free one, only the original resources will be provided. You may purchase this resource here www.decane.net/products/torque/fge/ if you do not already have this. This will show you the requirements needed to convert the existing files to the T3D engine.

First, We will work in the engine itself. Copy the 4 files from the 13103.aiflyingvehicleclasses_1.0 (these may be obtained from here www.torquepowered.com/community/resources/view/13103) and the files from the GuiReticleHUD folder. I placed all of the GuiReticleHUD in engine/soruce/gui/controls and the aiflyingclasses in engine/source/T3D/vehicles. You may also wish to copy these resources in when you compile your engine, this way you have the correct resources for the ported game example. www.torquepowered.com/community/resources/view/19519

Edit guiReticleHud.cpp

Change your includes from this
//#include "dgl/dgl.h"
//#include "dgl/gFont.h"
#include "gui/core/guiControl.h"
#include "gui/core/guiTSControl.h"
#include "console/consoleTypes.h"
#include "sceneGraph/sceneGraph.h"
#include "game/shapeBase.h"
#include "game/gameConnection.h"
#include "string.h"	// Needed for strcmp
to this
//#include "dgl/dgl.h"
//#include "dgl/gFont.h"
#include "gui/core/guiControl.h"
#include "gui/3d/guiTSControl.h"
#include "gui/core/guiCanvas.h"
#include "gfx/gfxDrawUtil.h"
#include "console/consoleTypes.h"
#include "sceneGraph/sceneGraph.h"
#include "T3D/shapeBase.h"
#include "T3D/gameBase/gameConnection.h"
#include "string.h"	// Needed for strcmp
#include "platform/platform.h"


Change all occurrences of (should be 3)
ShapeBase* control = conn->getControlObject();
to this
GameBase* control = conn->getControlObject();

Change this
ShapeBase *mount = shape->getObjectMount();
to this
SceneObject *mount = shape->getObjectMount();

This
pts[idx].x = bounds.min.x;
			pts[idx].y = bounds.min.y;
			pts[idx].z = bounds.min.z;
			idx++;

			pts[idx].x = bounds.min.x;
			pts[idx].y = bounds.min.y;
			pts[idx].z = bounds.max.z;
			idx++;

			pts[idx].x = bounds.min.x;
			pts[idx].y = bounds.max.y;
			pts[idx].z = bounds.min.z;
			idx++;

			pts[idx].x = bounds.min.x;
			pts[idx].y = bounds.max.y;
			pts[idx].z = bounds.max.z;
			idx++;

			pts[idx].x = bounds.max.x;
			pts[idx].y = bounds.min.y;
			pts[idx].z = bounds.min.z;
			idx++;

			pts[idx].x = bounds.max.x;
			pts[idx].y = bounds.min.y;
			pts[idx].z = bounds.max.z;
			idx++;

			pts[idx].x = bounds.max.x;
			pts[idx].y = bounds.max.y;
			pts[idx].z = bounds.min.z;
			idx++;

			pts[idx].x = bounds.max.x;
			pts[idx].y = bounds.max.y;
			pts[idx].z = bounds.max.z;
to this

//HNG 
pts[idx].x = bounds.minExtents.x;
			pts[idx].y = bounds.minExtents.y;
			pts[idx].z = bounds.minExtents.z;
			idx++;

			pts[idx].x = bounds.minExtents.x;
			pts[idx].y = bounds.minExtents.y;
			pts[idx].z = bounds.maxExtents.z;
			idx++;

			pts[idx].x = bounds.minExtents.x;
			pts[idx].y = bounds.maxExtents.y;
			pts[idx].z = bounds.minExtents.z;
			idx++;

			pts[idx].x = bounds.minExtents.x;
			pts[idx].y = bounds.maxExtents.y;
			pts[idx].z = bounds.maxExtents.z;
			idx++;

			pts[idx].x = bounds.maxExtents.x;
			pts[idx].y = bounds.minExtents.y;
			pts[idx].z = bounds.minExtents.z;
			idx++;

			pts[idx].x = bounds.maxExtents.x;
			pts[idx].y = bounds.minExtents.y;
			pts[idx].z = bounds.maxExtents.z;
			idx++;

			pts[idx].x = bounds.maxExtents.x;
			pts[idx].y = bounds.maxExtents.y;
			pts[idx].z = bounds.minExtents.z;
			idx++;

			pts[idx].x = bounds.maxExtents.x;
			pts[idx].y = bounds.maxExtents.y;
			pts[idx].z = bounds.maxExtents.z;
// HNG




This
GFX->drawRect(RectI(min.x, min.y, max.x-min.x, max.y-min.y), mRenderColor);
			}
			else if( strcmp(mRectangleStyle , "c" ) == 0) // corners
			{
				// draw only the corners of the rectangle
				GFX->drawLine(min.x, min.y, min.x + cornerLength, min.y, mRenderColor); // top left
				GFX->drawLine(min.x, min.y, min.x, min.y + cornerLength, mRenderColor); // top left
				GFX->drawLine(max.x, min.y, max.x - cornerLength, min.y, mRenderColor); // top right
				GFX->drawLine(max.x, min.y, max.x, min.y + cornerLength, mRenderColor); // top right
				GFX->drawLine(min.x, max.y, min.x + cornerLength, max.y, mRenderColor); // bottom left
				GFX->drawLine(min.x, max.y, min.x, max.y - cornerLength, mRenderColor); // bottom left
				GFX->drawLine(max.x, max.y, max.x, max.y - cornerLength, mRenderColor); // bottom right
				GFX->drawLine(max.x, max.y, max.x - cornerLength, max.y, mRenderColor); // bottom right
to this
// HNG
				GFX->getDrawUtil()->drawRect(RectI(min.x, min.y, max.x-min.x, max.y-min.y), mRenderColor);
			}
			else if( strcmp(mRectangleStyle , "c" ) == 0) // corners
			{
				// draw only the corners of the rectangle
				GFX->getDrawUtil()->drawLine(min.x, min.y, min.x + cornerLength, min.y, mRenderColor); // top left
				GFX->getDrawUtil()->drawLine(min.x, min.y, min.x, min.y + cornerLength, mRenderColor); // top left
				GFX->getDrawUtil()->drawLine(max.x, min.y, max.x - cornerLength, min.y, mRenderColor); // top right
				GFX->getDrawUtil()->drawLine(max.x, min.y, max.x, min.y + cornerLength, mRenderColor); // top right
				GFX->getDrawUtil()->drawLine(min.x, max.y, min.x + cornerLength, max.y, mRenderColor); // bottom left
				GFX->getDrawUtil()->drawLine(min.x, max.y, min.x, max.y - cornerLength, mRenderColor); // bottom left
				GFX->getDrawUtil()->drawLine(max.x, max.y, max.x, max.y - cornerLength, mRenderColor); // bottom right
				GFX->getDrawUtil()->drawLine(max.x, max.y, max.x - cornerLength, max.y, mRenderColor); // bottom right
// HNG


This
GFX->setBitmapModulation(mFillColorDefault);
   GFX->drawText(mProfile->mFont, offset, name);
   GFX->clearBitmapModulation();
to this
// HNG
   GFX->getDrawUtil()->setBitmapModulation(mFillColorDefault);
   GFX->getDrawUtil()->drawText(mProfile->mFont, offset, name);
   GFX->getDrawUtil()->clearBitmapModulation();
// HNG


Next open aiFlyingVehicle.cpp and

change
#include "aiFlyingVehicle.h"
#include "../console/consoleInternal.h"
#include "../core/realComp.h"
#include "../math/mMatrix.h"
#include "moveManager.h"
to this
#include "aiFlyingVehicle.h"
#include "console/consoleInternal.h"
//#include "core/realComp.h"
#include "math/mMatrix.h"
#include "T3D/gameBase/moveManager.h"

change (2 occurrences)
mCross( forward, up, right );
to this
mCross( forward, up, &right );

change
Con::executef(getDataBlock(), 2, name, scriptThis());
to this
Con::executef(getDataBlock(), name, scriptThis());





aiFlyingVehicle.h

change
#include "game/vehicles/flyingVehicle.h"
to this
#include "T3D/vehicles/flyingVehicle.h"



aiRepairshipFlyingVehicle.cpp
change
#include "AIRepairshipFlyingVehicle.h"
#include "../console/consoleInternal.h"
#include "../core/realComp.h"
#include "../math/mMatrix.h"
#include "moveManager.h"
to this
#include "AIRepairshipFlyingVehicle.h"
#include "console/consoleInternal.h"
//#include "../core/realComp.h"
#include "math/mMatrix.h"
#include "T3D/gameBase/moveManager.h"


change
mCross( forward, up, right );
to this
mCross( forward, up, &right );


change
Con::executef(getDataBlock(), 2, name, scriptThis());
to this
Con::executef(getDataBlock(), name, scriptThis());


change
#include "game/vehicles/flyingVehicle.h"
to this
#include "T3D/vehicles/flyingVehicle.h"

This completes the engine changes, you can recompile your engine at this time. We will continue onto the server and client sides next. This will take a bit of time, but you can complete the engine changes now.

#21
04/01/2010 (8:56 pm)
Edit for correction...
#22
04/04/2010 (6:51 am)
Error("onImpact: FIXME: Hier this statt 0?");

thats the exact error...
#23
04/04/2010 (9:38 am)
You can comment it out and it will not crash immediately which might allow for some debugging of the resource. It seems I have a couple of issues, respawning after death could be related to the issue we have here. After commenting that out, at the end of the crash I popped an error that I was not able to spawn as the requested item and it spawned me as an observer instead. It is also spawning the bots in as a number two lower then it is referencing. Something that was indicated in some of the other posts, but no "fix" was generated for it as far as I can tell.
#24
04/06/2010 (3:21 pm)
Some major updates for this, weapons are now online and there are no more hard crashes on death.

@Cyberkada, check out the mission file, almost all of my death issues were resolved with a few corrections to this file. Specifically with the mission area, waterblock, sun and sky. Replace them with T3D specific versions. Also, check out the onDeath function, there appears to be an issue with some of the syntax in this for T3D.
#25
04/08/2010 (1:06 pm)
Wow Sean that is indeed major progress!
#26
04/08/2010 (1:21 pm)
I have found that the issues with the crashing on death actually appears to be particles that are moved over from TGEA. Removing the 'weapons'from play and allowing them to crash into the terrain and each other, they will rack up 50+ kills. So it looks like more work ahead :)
#27
04/13/2010 (11:29 pm)
Hi Sean, I made all the changes accourding to your suggestions, but i could not understand changes i have to make in scripting.. what the necessary changes i have to do to get the effect of flying vehicle? I want fighter air craft effect. How I can achive this??
#28
04/14/2010 (8:00 am)
Cheryl, the script changes are really complex and I am still working my way through them. I have some crash that is still plaguing me on this port. It looks to be an issue with the STDGameProcess.cpp being unable to evaluate the process that is being sent to it. Unfortunately for me, I am not a C++ coder, so I may need a bit of assistance in that area. There are additional changes that need to occur to other engine files. Also, this is specifically a conversion for the FGE, so you must have that application in order to use this.
#29
04/15/2010 (6:06 am)
Thanks Sean, FGE starter kit is available in T3D 1.0? Is it useful to make Flight Simulation(jet movements)?
#30
04/15/2010 (10:22 am)
Cheryl, the FGE is definitely useful, the issue is that the current release is only for TGE and TGEA 1.01 I believe. This resource is my attempt to port the items over to the T3D engine. However, these are merely extensions of the existing flying vehicles that are are already in the engine. They don't feel right when your flying and do not provide a truly realistic flying feeling. More like a hovercraft then an aircraft.
#31
04/16/2010 (6:28 am)
Thanks Sean, Right now I'm working with T3D. FGE is not yet ported to T3D. I don't have much idea whether FEG will be easy to port for T3D. I'm just trying to make Flying Vehicle with all aircraft movements and AI Flying Vehicles. I used your source code. But we have to write lot of scrits. Please keep updating for any improvements for scripts.
#32
04/16/2010 (7:51 am)
One more thing I want to change my Player Datablock into FyingVehicle Datablock..I changed into gameCore.cs and gameDM.cs and spawn.cs. But my application is getting crash. So can you please suggest me how easy I can change my player datablock into Flying Vehicle Data block in T3D? Thanks in advance....!
#33
04/16/2010 (7:53 am)
It's most likely crashing due to being unable to identify what your asking it to do. FlyingVehicle and PlayerData reside under different connections I believe and the scripts are now unable to process. You will have to debug it and follow the train to ensure your doing it correctly.
#34
04/24/2010 (6:17 pm)
On my end, I was getting a crash when AIFlyingVehicles were being deleted too. I'm not exactly using the FGE code-base but the error I had occured because of 2 call's to delete the object on death.

In Scout::onDisabled there was a call to %obj.delete (in a schedule) and then in GameConnection::onDeath there was also a call to %obj.delete


Additionally, there is another bug where projectiles collide with AI after they have been deleted, it is documented in this thread: http://www.torquepowered.com/community/forums/viewthread/111201
#35
04/24/2010 (8:55 pm)
I am wondering if that is the bug I am seeing... I have zero crashes with the weapons out, place them in and it crashes. Thanks for pointing that out, i will look over it.
#36
04/25/2010 (4:49 am)
@Sean

Tom Spilman posted the fix in the thread I posted above. This solved my outstanding AIFlyingVehicle onDisabled crash bug.
#37
04/25/2010 (7:48 am)
I saw that, I was going to apply it last night... Then I realized something... A lot of the people that own the FGE, don't have T3D Pro, so my FGE port into 1.1B cannot be released as is. I am rewritting this now and hopefully this bug will not be present in 1.01. I will apply this to the 1.1B port I have made and finish that up for those that do have it.
#38
04/26/2010 (11:55 am)
Keep up the great work Sean and co!
#39
05/14/2010 (5:37 am)
Hi Sean, I resolved issues. Thank You very much. Now i got the flying vehicle moving around nicely...now i hav animation sequence like, anim0, anim1, anim2. I want to play these animation according to the ship movement. If i move left play anim0, if move right play anim1 and if you move up play anim2.. so how can I do this? I'm unable to find the flying vehicle update..! Thanks in advance...!



#40
05/16/2010 (12:13 pm)
I'm curious, Sean, is this working 100% with T3d? Are there any crashes when using weapons or with the AI flying bots?