mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
Adds some in-progress gameObject recreation of various legacy game classes, such as PlayerObject, AIPlayerObject, Sound Emitter and Static Shape.
This commit is contained in:
parent
e0627973fb
commit
f3e04751b6
23 changed files with 792 additions and 35 deletions
|
|
@ -139,6 +139,44 @@ void GameObjectAsset::onAssetRefresh()
|
||||||
Con::executeFile(mScriptFilePath, false, false);
|
Con::executeFile(mScriptFilePath, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* GameObjectAsset::create()
|
||||||
|
{
|
||||||
|
if (!Platform::isFile(mTAMLFilePath))
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Set the format mode.
|
||||||
|
Taml taml;
|
||||||
|
|
||||||
|
// Yes, so set it.
|
||||||
|
taml.setFormatMode(Taml::getFormatModeEnum("xml"));
|
||||||
|
|
||||||
|
// Turn-off auto-formatting.
|
||||||
|
taml.setAutoFormat(false);
|
||||||
|
|
||||||
|
// Read object.
|
||||||
|
SimObject* pSimObject = taml.read(mTAMLFilePath);
|
||||||
|
|
||||||
|
// Did we find the object?
|
||||||
|
if (pSimObject == NULL)
|
||||||
|
{
|
||||||
|
// No, so warn.
|
||||||
|
Con::warnf("GameObjectAsset::create() - Could not read object from file '%s'.", mTAMLFilePath);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Flag it so we know where it came from
|
||||||
|
pSimObject->setDataField("GameObject", nullptr, getAssetId());
|
||||||
|
|
||||||
|
return pSimObject->getIdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
DefineEngineMethod(GameObjectAsset, createObject, const char*, (),,
|
||||||
|
"Creates an instance of the given GameObject given the asset definition.\n"
|
||||||
|
"@return The GameObject entity created from the asset.")
|
||||||
|
{
|
||||||
|
return object->create();
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// GuiInspectorTypeAssetId
|
// GuiInspectorTypeAssetId
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
@ -161,34 +199,50 @@ void GuiInspectorTypeGameObjectAssetPtr::consoleInit()
|
||||||
GuiControl* GuiInspectorTypeGameObjectAssetPtr::constructEditControl()
|
GuiControl* GuiInspectorTypeGameObjectAssetPtr::constructEditControl()
|
||||||
{
|
{
|
||||||
// Create base filename edit controls
|
// Create base filename edit controls
|
||||||
GuiControl *retCtrl = Parent::constructEditControl();
|
// Create "Open in ShapeEditor" button
|
||||||
if (retCtrl == NULL)
|
mGameObjectEditButton = new GuiButtonCtrl();
|
||||||
return retCtrl;
|
|
||||||
|
|
||||||
// Change filespec
|
// Change filespec
|
||||||
char szBuffer[512];
|
char szBuffer[512];
|
||||||
dSprintf(szBuffer, sizeof(szBuffer), "AssetBrowser.showDialog(\"GameObjectAsset\", \"AssetBrowser.changeAsset\", %d, %s);",
|
dSprintf(szBuffer, sizeof(szBuffer), "%d.onClick(%s);", this->getId(), mCaption);
|
||||||
mInspector->getComponentGroupTargetId(), mCaption);
|
mGameObjectEditButton->setField("Command", szBuffer);
|
||||||
mBrowseButton->setField("Command", szBuffer);
|
|
||||||
|
|
||||||
// Create "Open in ShapeEditor" button
|
mGameObjectEditButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
||||||
mSMEdButton = new GuiBitmapButtonCtrl();
|
mGameObjectEditButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
||||||
|
mGameObjectEditButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
||||||
|
|
||||||
dSprintf(szBuffer, sizeof(szBuffer), "echo(\"Game Object Editor not implemented yet!\");", retCtrl->getId());
|
const char* assetId = getData();
|
||||||
mSMEdButton->setField("Command", szBuffer);
|
|
||||||
|
|
||||||
char bitmapName[512] = "tools/worldEditor/images/toolbar/shape-editor";
|
if (assetId == "")
|
||||||
mSMEdButton->setBitmap(bitmapName);
|
{
|
||||||
|
mGameObjectEditButton->setText("Create Game Object");
|
||||||
|
|
||||||
mSMEdButton->setDataField(StringTable->insert("Profile"), NULL, "GuiButtonProfile");
|
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Convert this object into a reusable Game Object asset.");
|
||||||
mSMEdButton->setDataField(StringTable->insert("tooltipprofile"), NULL, "GuiToolTipProfile");
|
}
|
||||||
mSMEdButton->setDataField(StringTable->insert("hovertime"), NULL, "1000");
|
else
|
||||||
mSMEdButton->setDataField(StringTable->insert("tooltip"), NULL, "Open this file in the State Machine Editor");
|
{
|
||||||
|
GameObjectAsset* goAsset = AssetDatabase.acquireAsset< GameObjectAsset>(assetId);
|
||||||
|
|
||||||
mSMEdButton->registerObject();
|
if (goAsset)
|
||||||
addObject(mSMEdButton);
|
{
|
||||||
|
mGameObjectEditButton->setText("Edit Game Object");
|
||||||
|
|
||||||
return retCtrl;
|
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Edit this object instance or Game Object asset.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mGameObjectEditButton->setText("Create Game Object");
|
||||||
|
|
||||||
|
mGameObjectEditButton->setDataField(StringTable->insert("tooltip"), NULL, "Convert this object into a reusable Game Object asset.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//mGameObjectEditButton->registerObject();
|
||||||
|
_registerEditControl(mGameObjectEditButton);
|
||||||
|
|
||||||
|
addObject(mGameObjectEditButton);
|
||||||
|
|
||||||
|
return mGameObjectEditButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiInspectorTypeGameObjectAssetPtr::updateRects()
|
bool GuiInspectorTypeGameObjectAssetPtr::updateRects()
|
||||||
|
|
@ -199,19 +253,12 @@ bool GuiInspectorTypeGameObjectAssetPtr::updateRects()
|
||||||
Point2I fieldPos = getPosition();
|
Point2I fieldPos = getPosition();
|
||||||
|
|
||||||
mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
|
mCaptionRect.set(0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y);
|
||||||
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin - 34, fieldExtent.y);
|
mEditCtrlRect.set(fieldExtent.x - dividerPos + dividerMargin, 1, dividerPos - dividerMargin, fieldExtent.y);
|
||||||
|
|
||||||
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
bool resized = mEdit->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||||
if (mBrowseButton != NULL)
|
if (mGameObjectEditButton != NULL)
|
||||||
{
|
{
|
||||||
mBrowseRect.set(fieldExtent.x - 32, 2, 14, fieldExtent.y - 4);
|
resized |= mGameObjectEditButton->resize(mEditCtrlRect.point, mEditCtrlRect.extent);
|
||||||
resized |= mBrowseButton->resize(mBrowseRect.point, mBrowseRect.extent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSMEdButton != NULL)
|
|
||||||
{
|
|
||||||
RectI shapeEdRect(fieldExtent.x - 16, 2, 14, fieldExtent.y - 4);
|
|
||||||
resized |= mSMEdButton->resize(shapeEdRect.point, shapeEdRect.extent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return resized;
|
return resized;
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ public:
|
||||||
static void initPersistFields();
|
static void initPersistFields();
|
||||||
virtual void copyTo(SimObject* object);
|
virtual void copyTo(SimObject* object);
|
||||||
|
|
||||||
|
const char* create();
|
||||||
|
|
||||||
/// Declare Console Object.
|
/// Declare Console Object.
|
||||||
DECLARE_CONOBJECT(GameObjectAsset);
|
DECLARE_CONOBJECT(GameObjectAsset);
|
||||||
|
|
||||||
|
|
@ -73,12 +75,12 @@ DefineConsoleType(TypeGameObjectAssetPtr, GameObjectAsset)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// TypeAssetId GuiInspectorField Class
|
// TypeAssetId GuiInspectorField Class
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
class GuiInspectorTypeGameObjectAssetPtr : public GuiInspectorTypeFileName
|
class GuiInspectorTypeGameObjectAssetPtr : public GuiInspectorField
|
||||||
{
|
{
|
||||||
typedef GuiInspectorTypeFileName Parent;
|
typedef GuiInspectorField Parent;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GuiBitmapButtonCtrl *mSMEdButton;
|
GuiButtonCtrl *mGameObjectEditButton;
|
||||||
|
|
||||||
DECLARE_CONOBJECT(GuiInspectorTypeGameObjectAssetPtr);
|
DECLARE_CONOBJECT(GuiInspectorTypeGameObjectAssetPtr);
|
||||||
static void consoleInit();
|
static void consoleInit();
|
||||||
|
|
|
||||||
42
Engine/source/T3D/gameObjects/aiPlayerObject.cpp
Normal file
42
Engine/source/T3D/gameObjects/aiPlayerObject.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
#include "aiPlayerObject.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CO_NETOBJECT_V1(AIPlayerObject);
|
||||||
|
|
||||||
|
AIPlayerObject::AIPlayerObject()
|
||||||
|
: mAIControllerComponent(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
AIPlayerObject::~AIPlayerObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AIPlayerObject::onAdd()
|
||||||
|
{
|
||||||
|
if (!Parent::onAdd())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//If we don't delinate from the template, just spawn as apropos here
|
||||||
|
if (!mDirtyGameObject)
|
||||||
|
{
|
||||||
|
//AI Controller
|
||||||
|
mAIControllerComponent = new AIControllerComponent();
|
||||||
|
if (!mAIControllerComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add mAIControllerComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAIControllerComponent->setInternalName("aiControllerComponent");
|
||||||
|
|
||||||
|
addComponent(mAIControllerComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AIPlayerObject::onRemove()
|
||||||
|
{
|
||||||
|
Parent::onRemove();
|
||||||
|
}
|
||||||
20
Engine/source/T3D/gameObjects/aiPlayerObject.h
Normal file
20
Engine/source/T3D/gameObjects/aiPlayerObject.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
#include "playerObject.h"
|
||||||
|
|
||||||
|
#include "T3D/components/ai/aiControllerComponent.h"
|
||||||
|
|
||||||
|
class AIPlayerObject : public PlayerObject
|
||||||
|
{
|
||||||
|
typedef PlayerObject Parent;
|
||||||
|
|
||||||
|
AIControllerComponent* mAIControllerComponent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
AIPlayerObject();
|
||||||
|
~AIPlayerObject();
|
||||||
|
|
||||||
|
virtual bool onAdd();
|
||||||
|
virtual void onRemove();
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(AIPlayerObject);
|
||||||
|
};
|
||||||
165
Engine/source/T3D/gameObjects/playerObject.cpp
Normal file
165
Engine/source/T3D/gameObjects/playerObject.cpp
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
#include "playerObject.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CO_NETOBJECT_V1(PlayerObject);
|
||||||
|
|
||||||
|
PlayerObject::PlayerObject()
|
||||||
|
: mMeshComponent(nullptr),
|
||||||
|
mCollisionComponent(nullptr),
|
||||||
|
mAnimationComponent(nullptr),
|
||||||
|
mPhysicsComponent(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
PlayerObject::~PlayerObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PlayerObject::onAdd()
|
||||||
|
{
|
||||||
|
if (!Parent::onAdd())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//If we don't delinate from the template, just spawn as apropos here
|
||||||
|
if (!mDirtyGameObject)
|
||||||
|
{
|
||||||
|
//Mesh
|
||||||
|
mMeshComponent = new MeshComponent();
|
||||||
|
if (!mMeshComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add MeshComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMeshComponent->setInternalName("meshComponent");
|
||||||
|
|
||||||
|
addComponent(mMeshComponent);
|
||||||
|
|
||||||
|
//Collision
|
||||||
|
mCollisionComponent = new ShapeCollisionComponent();
|
||||||
|
if (!mCollisionComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add ShapeCollisionComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCollisionComponent->setInternalName("collisionComponent");
|
||||||
|
|
||||||
|
addComponent(mCollisionComponent);
|
||||||
|
|
||||||
|
//Animation
|
||||||
|
mAnimationComponent = new ActionAnimationComponent();
|
||||||
|
if (!mAnimationComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add ActionAnimationComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAnimationComponent->setInternalName("animationComponent");
|
||||||
|
|
||||||
|
addComponent(mAnimationComponent);
|
||||||
|
|
||||||
|
//Arm Animation
|
||||||
|
mArmAnimationComponent = new ArmAnimationComponent();
|
||||||
|
if (!mArmAnimationComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add ArmAnimationComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mArmAnimationComponent->setInternalName("armAnimationComponent");
|
||||||
|
|
||||||
|
addComponent(mArmAnimationComponent);
|
||||||
|
|
||||||
|
//Physics control
|
||||||
|
mPhysicsComponent = new PlayerControllerComponent();
|
||||||
|
if (!mPhysicsComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add PhysicsComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPhysicsComponent->setInternalName("physicsComponent");
|
||||||
|
|
||||||
|
addComponent(mPhysicsComponent);
|
||||||
|
|
||||||
|
//State Machine
|
||||||
|
mStateMachineComponent = new StateMachineComponent();
|
||||||
|
if (!mStateMachineComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add StateMachineComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mStateMachineComponent->setInternalName("stateMachineComponent");
|
||||||
|
|
||||||
|
addComponent(mStateMachineComponent);
|
||||||
|
|
||||||
|
//Camera
|
||||||
|
mCameraComponent = new CameraComponent();
|
||||||
|
if (!mCameraComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add CameraComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCameraComponent->setInternalName("cameraComponent");
|
||||||
|
|
||||||
|
addComponent(mCameraComponent);
|
||||||
|
|
||||||
|
//Camera Orbiter
|
||||||
|
mCameraOrbiterComponent = new CameraOrbiterComponent();
|
||||||
|
if (!mCameraOrbiterComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add CameraOrbiterComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCameraOrbiterComponent->setInternalName("cameraOrbiterComponent");
|
||||||
|
|
||||||
|
addComponent(mCameraOrbiterComponent);
|
||||||
|
|
||||||
|
//Control Object
|
||||||
|
mControlObjectComponent = new ControlObjectComponent();
|
||||||
|
if (!mControlObjectComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add ControlObjectComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mControlObjectComponent->setInternalName("controlObjectComponent");
|
||||||
|
|
||||||
|
addComponent(mControlObjectComponent);
|
||||||
|
|
||||||
|
//Sound
|
||||||
|
mSoundComponent = new SoundComponent();
|
||||||
|
if (!mSoundComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add SoundComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSoundComponent->setInternalName("soundComponent");
|
||||||
|
|
||||||
|
addComponent(mSoundComponent);
|
||||||
|
|
||||||
|
//Interaction
|
||||||
|
mInteractComponent = new InteractComponent();
|
||||||
|
if (!mInteractComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("PlayerObject::onAdd - unable to add InteractComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mInteractComponent->setInternalName("interactComponent");
|
||||||
|
|
||||||
|
addComponent(mInteractComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerObject::onRemove()
|
||||||
|
{
|
||||||
|
Parent::onRemove();
|
||||||
|
}
|
||||||
40
Engine/source/T3D/gameObjects/playerObject.h
Normal file
40
Engine/source/T3D/gameObjects/playerObject.h
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "T3D/entity.h"
|
||||||
|
#include "T3D/components/render/meshComponent.h"
|
||||||
|
#include "T3D/components/collision/shapeCollisionComponent.h"
|
||||||
|
#include "T3D/components/animation/actionAnimationComponent.h"
|
||||||
|
#include "T3D/components/animation/armAnimationComponent.h"
|
||||||
|
#include "T3D/components/physics/playerControllerComponent.h"
|
||||||
|
#include "T3D/components/game/stateMachineComponent.h"
|
||||||
|
#include "T3D/components/camera/cameraComponent.h"
|
||||||
|
#include "T3D/components/camera/cameraOrbiterComponent.h"
|
||||||
|
#include "T3D/components/game/controlObjectComponent.h"
|
||||||
|
#include "T3D/components/audio/soundComponent.h"
|
||||||
|
#include "T3D/components/game/interactComponent.h"
|
||||||
|
|
||||||
|
class PlayerObject : public Entity
|
||||||
|
{
|
||||||
|
typedef Entity Parent;
|
||||||
|
|
||||||
|
MeshComponent* mMeshComponent;
|
||||||
|
ShapeCollisionComponent* mCollisionComponent;
|
||||||
|
ActionAnimationComponent* mAnimationComponent;
|
||||||
|
ArmAnimationComponent* mArmAnimationComponent;
|
||||||
|
PlayerControllerComponent* mPhysicsComponent;
|
||||||
|
StateMachineComponent* mStateMachineComponent;
|
||||||
|
CameraComponent* mCameraComponent;
|
||||||
|
CameraOrbiterComponent* mCameraOrbiterComponent;
|
||||||
|
ControlObjectComponent* mControlObjectComponent;
|
||||||
|
SoundComponent* mSoundComponent;
|
||||||
|
InteractComponent* mInteractComponent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PlayerObject();
|
||||||
|
~PlayerObject();
|
||||||
|
|
||||||
|
virtual bool onAdd();
|
||||||
|
virtual void onRemove();
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(PlayerObject);
|
||||||
|
};
|
||||||
38
Engine/source/T3D/gameObjects/soundEmitterObject.cpp
Normal file
38
Engine/source/T3D/gameObjects/soundEmitterObject.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#include "SoundEmitterObject.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CO_NETOBJECT_V1(SoundEmitterObject);
|
||||||
|
|
||||||
|
SoundEmitterObject::SoundEmitterObject()
|
||||||
|
: mSoundComponent(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
SoundEmitterObject::~SoundEmitterObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SoundEmitterObject::onAdd()
|
||||||
|
{
|
||||||
|
if (!Parent::onAdd())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//Sound
|
||||||
|
mSoundComponent = new SoundComponent();
|
||||||
|
if (!mSoundComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("SoundEmitterObject::onAdd - unable to add soundComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSoundComponent->setInternalName("soundComponent");
|
||||||
|
|
||||||
|
addComponent(mSoundComponent);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SoundEmitterObject::onRemove()
|
||||||
|
{
|
||||||
|
Parent::onRemove();
|
||||||
|
}
|
||||||
20
Engine/source/T3D/gameObjects/soundEmitterObject.h
Normal file
20
Engine/source/T3D/gameObjects/soundEmitterObject.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "T3D/entity.h"
|
||||||
|
#include "T3D/components/audio/soundComponent.h"
|
||||||
|
|
||||||
|
class SoundEmitterObject : public Entity
|
||||||
|
{
|
||||||
|
typedef Entity Parent;
|
||||||
|
|
||||||
|
SoundComponent* mSoundComponent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
SoundEmitterObject();
|
||||||
|
~SoundEmitterObject();
|
||||||
|
|
||||||
|
virtual bool onAdd();
|
||||||
|
virtual void onRemove();
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(SoundEmitterObject);
|
||||||
|
};
|
||||||
68
Engine/source/T3D/gameObjects/staticShapeObject.cpp
Normal file
68
Engine/source/T3D/gameObjects/staticShapeObject.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include "staticShapeObject.h"
|
||||||
|
|
||||||
|
IMPLEMENT_CO_NETOBJECT_V1(StaticShapeObject);
|
||||||
|
|
||||||
|
StaticShapeObject::StaticShapeObject()
|
||||||
|
: mMeshComponent(nullptr),
|
||||||
|
mCollisionComponent(nullptr),
|
||||||
|
mAnimationComponent(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
StaticShapeObject::~StaticShapeObject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StaticShapeObject::onAdd()
|
||||||
|
{
|
||||||
|
if (!Parent::onAdd())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//If we don't delinate from the template, just spawn as apropos here
|
||||||
|
if (!mDirtyGameObject)
|
||||||
|
{
|
||||||
|
//Mesh
|
||||||
|
mMeshComponent = new MeshComponent();
|
||||||
|
if (!mMeshComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("StaticShapeObject::onAdd - unable to add MeshComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mMeshComponent->setInternalName("meshComponent");
|
||||||
|
|
||||||
|
addComponent(mMeshComponent);
|
||||||
|
|
||||||
|
//Collision
|
||||||
|
mCollisionComponent = new ShapeCollisionComponent();
|
||||||
|
if (!mCollisionComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("StaticShapeObject::onAdd - unable to add ShapeCollisionComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mCollisionComponent->setInternalName("collisionComponent");
|
||||||
|
|
||||||
|
addComponent(mCollisionComponent);
|
||||||
|
|
||||||
|
//Animation
|
||||||
|
mAnimationComponent = new AnimationComponent();
|
||||||
|
if (!mAnimationComponent->registerObject())
|
||||||
|
{
|
||||||
|
Con::errorf("StaticShapeObject::onAdd - unable to add AnimationComponent!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mAnimationComponent->setInternalName("animationComponent");
|
||||||
|
|
||||||
|
addComponent(mAnimationComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticShapeObject::onRemove()
|
||||||
|
{
|
||||||
|
Parent::onRemove();
|
||||||
|
}
|
||||||
28
Engine/source/T3D/gameObjects/staticShapeObject.h
Normal file
28
Engine/source/T3D/gameObjects/staticShapeObject.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "T3D/entity.h"
|
||||||
|
#include "T3D/components/render/meshComponent.h"
|
||||||
|
#include "T3D/components/collision/shapeCollisionComponent.h"
|
||||||
|
#include "T3D/components/animation/animationComponent.h"
|
||||||
|
|
||||||
|
class StaticShapeObject : public Entity
|
||||||
|
{
|
||||||
|
typedef Entity Parent;
|
||||||
|
|
||||||
|
MeshComponent* mMeshComponent;
|
||||||
|
ShapeCollisionComponent* mCollisionComponent;
|
||||||
|
AnimationComponent* mAnimationComponent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
StaticShapeObject();
|
||||||
|
~StaticShapeObject();
|
||||||
|
|
||||||
|
virtual bool onAdd();
|
||||||
|
virtual void onRemove();
|
||||||
|
|
||||||
|
MeshComponent* getMeshComponent() { return mMeshComponent; }
|
||||||
|
ShapeCollisionComponent* getCollisionComponent() { return mCollisionComponent; }
|
||||||
|
AnimationComponent* getAnimationComponent() { return mAnimationComponent; }
|
||||||
|
|
||||||
|
DECLARE_CONOBJECT(StaticShapeObject);
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
function Core_GameObjects::onCreate(%this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function Core_GameObjects::onDestroy(%this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
<ModuleDefinition
|
||||||
|
ModuleId="Core_GameObjects"
|
||||||
|
VersionId="1"
|
||||||
|
Description="Module that implements the core engine-level setup for the game."
|
||||||
|
ScriptFile="Core_GameObjects.cs"
|
||||||
|
CreateFunction="onCreate"
|
||||||
|
DestroyFunction="onDestroy"
|
||||||
|
Group="Core">
|
||||||
|
<DeclaredAssets
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
Extension="asset.taml"
|
||||||
|
Recurse="true" />
|
||||||
|
<AutoloadAssets
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetType="GameObjectAsset"
|
||||||
|
Recurse="true" />
|
||||||
|
</ModuleDefinition>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<GameObjectAsset
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetName="AIPlayerObject"
|
||||||
|
gameObjectName="AIPlayerObject"
|
||||||
|
scriptFilePath="core/gameObjects/gameObjects/AIPlayerObject.cs"
|
||||||
|
TAMLFilePath="core/gameObjects/gameObjects/AIPlayerObject.taml"
|
||||||
|
description="A basic AI Player Object example." />
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
function AIPlayerObject::onAdd(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::onRemove(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::moveVectorEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::moveYawEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::movePitchEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::moveRollEvent(%this){}
|
||||||
|
|
||||||
|
function AIPlayerObject::moveTriggerEvent(%this, %triggerNum, %triggerValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::onCollisionEvent(%this, %colObject, %colNormal, %colPoint, %colMatID, %velocity)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function AIPlayerObject::processTick(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<AIPlayerObject
|
||||||
|
scale="1 1 1"
|
||||||
|
class="AIPlayerObject"
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
position="0 0 0"
|
||||||
|
rotation="0 -0 -0"
|
||||||
|
LocalPosition="0 0 0"
|
||||||
|
LocalRotation="1 0 0 0"
|
||||||
|
lifetimeMS="0"
|
||||||
|
gameObject="Core_GameObjects:AIPlayerObject">
|
||||||
|
</AIPlayerObject>
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
<GameObjectAsset
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetName="PlayerObject"
|
||||||
|
gameObjectName="PlayerObject"
|
||||||
|
scriptFilePath="core/gameObjects/gameObjects/PlayerObject.cs"
|
||||||
|
TAMLFilePath="core/gameObjects/gameObjects/PlayerObject.taml"
|
||||||
|
description="A basic Player Object example." />
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
function PlayerObject::onAdd(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::onRemove(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::moveVectorEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::moveYawEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::movePitchEvent(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::moveRollEvent(%this){}
|
||||||
|
|
||||||
|
function PlayerObject::moveTriggerEvent(%this, %triggerNum, %triggerValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::onCollisionEvent(%this, %colObject, %colNormal, %colPoint, %colMatID, %velocity)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function PlayerObject::processTick(%this)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
<PlayerObject
|
||||||
|
scale="1 1 1"
|
||||||
|
class="PlayerObject"
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
position="0 0 0"
|
||||||
|
rotation="0 -0 -0"
|
||||||
|
LocalPosition="0 0 0"
|
||||||
|
LocalRotation="1 0 0 0"
|
||||||
|
lifetimeMS="0"
|
||||||
|
gameObject="Core_GameObjects:PlayerObject">
|
||||||
|
<MeshComponent
|
||||||
|
componentType="Render"
|
||||||
|
friendlyName="Mesh Component"
|
||||||
|
description="Causes the object to render a non-animating 3d shape using the file provided."
|
||||||
|
networked="true"
|
||||||
|
enabled="true"
|
||||||
|
internalName="MeshComponent" />
|
||||||
|
<ShapeCollisionComponent
|
||||||
|
componentType="Collision"
|
||||||
|
friendlyName="Shape Collision"
|
||||||
|
description="A stub component class that physics components should inherit from."
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="CollisionComponent"
|
||||||
|
CollisionType="Collision Mesh"
|
||||||
|
LineOfSightType="Collision Mesh"
|
||||||
|
DecalType="Collision Mesh"
|
||||||
|
CollisionMeshPrefix="Collision"
|
||||||
|
BlockCollisions="true" />
|
||||||
|
<AnimationComponent
|
||||||
|
componentType="Render"
|
||||||
|
friendlyName="Animation(Component)"
|
||||||
|
description="Allows a rendered mesh to be animated"
|
||||||
|
networked="true"
|
||||||
|
enabled="true"
|
||||||
|
internalName="AnimationComponent" />
|
||||||
|
<PlayerControllerComponent
|
||||||
|
componentType="Physics"
|
||||||
|
friendlyName="Player Controller"
|
||||||
|
description="A general-purpose physics player controller."
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="PhysicsComponent"
|
||||||
|
inputVelocity="0 0 0"
|
||||||
|
useDirectMoveInput="0 -3.37028e+15 0" />
|
||||||
|
<StateMachineComponent
|
||||||
|
componentType="Game"
|
||||||
|
friendlyName="State Machine"
|
||||||
|
description="A generic state machine."
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="StateMachineComponent" />
|
||||||
|
<CameraComponent
|
||||||
|
friendlyName="Camera(Component)"
|
||||||
|
networked="true"
|
||||||
|
enabled="true"
|
||||||
|
internalName="CameraComponent"
|
||||||
|
FOV="80"
|
||||||
|
MinFOV="5"
|
||||||
|
MaxFOV="175"
|
||||||
|
ScreenAspect="1065353216 1065353216"
|
||||||
|
positionOffset="0 0 0"
|
||||||
|
rotationOffset="0 -0 -0"
|
||||||
|
useParentTransform="true" />
|
||||||
|
<CameraOrbiterComponent
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="CameraOrbiterComponent"
|
||||||
|
orbitDistance="8"
|
||||||
|
rotation="0 0 0"
|
||||||
|
maxPitchAngle="70"
|
||||||
|
minPitchAngle="-10" />
|
||||||
|
<ControlObjectComponent
|
||||||
|
componentType="Game"
|
||||||
|
friendlyName="Control Object"
|
||||||
|
description="Allows owner entity to be controlled by a client."
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="ControlObjectComponent"
|
||||||
|
clientOwner="0" />
|
||||||
|
<SoundComponent
|
||||||
|
componentType="Sound"
|
||||||
|
friendlyName="Sound(Component)"
|
||||||
|
description="Stores up to 4 sounds for playback."
|
||||||
|
networked="true"
|
||||||
|
enabled="true"
|
||||||
|
internalName="SoundComponent">
|
||||||
|
<SoundComponent.MPreviewSounds>
|
||||||
|
<MPreviewSound
|
||||||
|
MPreviewSound="false" />
|
||||||
|
<MPreviewSound
|
||||||
|
MPreviewSound="false" />
|
||||||
|
<MPreviewSound
|
||||||
|
MPreviewSound="false" />
|
||||||
|
<MPreviewSound
|
||||||
|
MPreviewSound="false" />
|
||||||
|
</SoundComponent.MPreviewSounds>
|
||||||
|
<SoundComponent.Plays>
|
||||||
|
<Play
|
||||||
|
Play="false" />
|
||||||
|
<Play
|
||||||
|
Play="false" />
|
||||||
|
<Play
|
||||||
|
Play="false" />
|
||||||
|
<Play
|
||||||
|
Play="false" />
|
||||||
|
</SoundComponent.Plays>
|
||||||
|
</SoundComponent>
|
||||||
|
<InteractComponent
|
||||||
|
componentType="Game"
|
||||||
|
friendlyName="Interact"
|
||||||
|
description="Allows owner entity interact."
|
||||||
|
networked="false"
|
||||||
|
enabled="true"
|
||||||
|
internalName="InteractComponent" />
|
||||||
|
</PlayerObject>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<GameObjectAsset
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetName="soundEmitterObject"
|
||||||
|
gameObjectName="soundEmitterObject"
|
||||||
|
TAMLFilePath="core/gameObjects/gameObjects/soundEmitterObject.taml"
|
||||||
|
description="A basic sound emitter example." />
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<soundEmitterObject
|
||||||
|
scale="1 1 1"
|
||||||
|
class="SoundEmitterObject"
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
position="0 0 0"
|
||||||
|
Rotation="0 -0 -0"
|
||||||
|
LocalPosition="0 0 0"
|
||||||
|
LocalRotation="1 0 0 0"/>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<GameObjectAsset
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
AssetName="StaticShapeObject"
|
||||||
|
gameObjectName="StaticShapeObject"
|
||||||
|
TAMLFilePath="core/gameObjects/gameObjects/staticShapeObject.taml"
|
||||||
|
description="A basic static shape example." />
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<StaticShapeObject
|
||||||
|
scale="1 1 1"
|
||||||
|
class="StaticShapeObject"
|
||||||
|
canSave="true"
|
||||||
|
canSaveDynamicFields="true"
|
||||||
|
position="0 0 0"
|
||||||
|
Rotation="0 -0 -0"
|
||||||
|
LocalPosition="0 0 0"
|
||||||
|
LocalRotation="1 0 0 0"/>
|
||||||
|
|
@ -39,8 +39,7 @@ function GameObjectCreateBtn::onClick(%this)
|
||||||
//also, exec any components that may exist
|
//also, exec any components that may exist
|
||||||
//find all GameObjectAssets
|
//find all GameObjectAssets
|
||||||
%assetQuery = new AssetQuery();
|
%assetQuery = new AssetQuery();
|
||||||
if(!AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset"))
|
AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset");
|
||||||
return; //if we didn't find ANY, just exit
|
|
||||||
|
|
||||||
%count = %assetQuery.getCount();
|
%count = %assetQuery.getCount();
|
||||||
|
|
||||||
|
|
@ -69,7 +68,7 @@ function GameObjectCreateBtn::onClick(%this)
|
||||||
//get the selected module data
|
//get the selected module data
|
||||||
%moduleName = GameObjectModuleList.getText();
|
%moduleName = GameObjectModuleList.getText();
|
||||||
|
|
||||||
%selectedEntity.gameObjectAsset = %moduleName @ ":" @ %className;
|
%selectedEntity.gameObject = %moduleName @ ":" @ %className;
|
||||||
|
|
||||||
%path = "data/" @ %moduleName @ "/gameObjects/";
|
%path = "data/" @ %moduleName @ "/gameObjects/";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue