Game Development Community

Creating a new object outside the engine source

by Diego Perez · in Torque 3D Professional · 02/09/2010 (8:10 am) · 4 replies

Hi community!

I am pretty new in Torique 3D engine. I was trying to implement a new C++ class (for pathfinding) but I can not modify the Torque engine code. In other words, Torque engine must end as it comes at the beginning, so somebody that does not have access to the engine code can use my library/classes.

First of all, I do not know if this is possible...

I am trying to implement it using a ConObject, but the IMPLEMENT_CONOBJECT macro does not seem to work for me. As I have seen, my C++ class is not being include in the 'classLinkList' list of classes.

Any suggestion about how could I do it?

Thanks a lot!
Diego.

#1
02/10/2010 (10:51 am)
You should be able to implement a ConObject... just make sure you include the DECLARE_CONOBJECT(yourNewClass) as a public member of your class declaration in your .h file, and sounds like you already have the corresponding IMPLEMENT_CONOBJECT(yourNewClass) near the top of your class definitions in the .cpp file.
#2
02/10/2010 (11:44 am)
Thanks for your reply.

Indeed I am doing also the declaration as a public member of the class. This is my code:

//Header File mesh.h
#include "console/scriptObjects.h"
class BTMeshLoader : public ScriptObject
{
  typedef ScriptObject Parent;

public:
  DECLARE_CONOBJECT( BTMeshLoader );
  BTMeshLoader(){}
  ~BTMeshLoader(){}
}
******

//CPP File
#include "mesh.h"
#include "console/scriptObjects.h"
IMPLEMENT_CONOBJECT(BTMeshLoader);
//-----------------------------------
// BTMeshLoader Console functions
//-----------------------------------

//...

But, as I do not have Torque source code changed (I can't do that for my project, it is a requirement), I guess that the implementation of this console object is never executed so script code cannot recognize my class.
#3
02/10/2010 (1:41 pm)
You can't change the source code... so you're trying to load a c++ library through script? I'm not sure if that is even possible, since it would have to be linked in at runtime. Never seen anything like that, but I'm no expert programmer by any means.
#4
02/10/2010 (2:21 pm)
If I am not wrong (I could be) I could be able to load a DLL dynamically.

The point is if Torque let me do that, and obviously must be through script... That's why I asked, because I do not even know if that is possible in Torque.