Game Development Community

[DELETE] Creating a new object from staticshape : T3D 1.2

by MarkusDavey · in Torque 3D Professional · 12/01/2011 (1:11 am) · 1 replies

DELETE this thread, I'm a derp.


Hello everyone,

I recently migrated from T3D 1.1 to 1.2, and it appears that creating new engine objects has changed.

In 1.1, I made a turret system, and creating an engine object the same way in 1.2 appears to not work.

For example, I've made an object inherit from staticshape, with the name of "testObject"

When I import the object into the game (having made a datablock etc in torquescript, exec'd etc), the object's source class is "staticshape", meaning it magically became it's parent class, even though the datablock classed it as the testObject.

Testobject.h:
#ifndef _H_TESTOBJECT
#define _H_TESTOBJECT


#ifndef _STATICSHAPE_H_
	#include "T3D/staticShape.h"
#endif

// Made with static shape :D

class TestObject : public StaticShape
{
   public:
		typedef StaticShape Parent;

		DECLARE_CONOBJECT(TestObject);
		TestObject();
		~TestObject();

		void processTick(const Move *move);
		
	protected:

	private:

};

struct TestObjectData : public StaticShapeData 
{
	typedef StaticShapeData Parent;
	public:
		TestObjectData();
		~TestObjectData();

		// Declare variables here
		String testtValue;

		DECLARE_CONOBJECT(TestObjectData);
		static void initPersistFields();
};

#endif

Testobject.cpp
// Markus Davey 1/12/2011
// Skype Markus.davey

#include "T3D/TestObject.h";
//
#include "math/mathUtils.h"
#include "console/engineAPI.h"
#include "console/consoleTypes.h"
#include "scene/sceneObject.h"
#include "gfx/gfxDrawUtil.h"
#include "gfx/sim/debugDraw.h"

// TestObject START /////////////////////////////////////////////////////////////

IMPLEMENT_CO_NETOBJECT_V1(TestObject);

// Constructor
TestObject::TestObject()
{
	mTypeMask |= TestObjectObjectType;// | ShapeBaseObjectType;
}

// Deconstructor
TestObject::~TestObject()
{

}


void TestObject::processTick(const Move* move)
{
	Parent::processTick(move);
}

// TestObject END /////////////////////////////////////////////////////////////

//----------------------------------------------------------------------------------------------------------------------------

// TestObjectData START /////////////////////////////////////////////////////////////

IMPLEMENT_CO_DATABLOCK_V1(TestObjectData);

// Constructor
TestObjectData::TestObjectData()
{
	
}

// Deconstructor
TestObjectData::~TestObjectData()
{

}

void TestObjectData::initPersistFields()
{
	addField("testValue", TypeRealString,  Offset(testValue, TestObjectData), "Holds a test value!");
}

// TestObjectData END /////////////////////////////////////////////////////////////

// ENGINE METHODS START /////////////////////////////////////////////////////////


// ENGINE METHODS END ///////////////////////////////////////////////////////////

^ no compile issues. I also cannot see the "testValue" in the dump out of the object. The dump says it's a staticshape.

testValue has a value in the datablock I am using.

So, any idea what's going on?

#1
12/01/2011 (6:36 pm)
You have a typo in the code you posted.
String testtValue

Getting rid of the extra 't' makes it work fine for me. Make sure you are looking at the datablock not the actual object when you do a 'dump' and look at the top under static values, not the bottom section where the functions are.

If you want to also use the datablock values from staticShapeData and its parents you need to add

Parent::initPersistFields();

to your initPersistFields function.