Ported part and pvinstance, made XplicitNgine not use globals

This commit is contained in:
Vulpovile
2023-11-04 23:01:43 -07:00
parent cb8f6f1a80
commit 901539e594
13 changed files with 1008 additions and 160 deletions

View File

@@ -80,9 +80,8 @@ public:
// onTouch
void onTouch();
//Properties
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
std::vector<PROPGRIDITEM> getProperties();
void PropUpdate(LPPROPGRIDITEM &item);
private:
bool anchored;
Vector3 position;

View File

@@ -6,11 +6,11 @@ using namespace B3D;
// Instances
//#include "WorkspaceInstance.h"
#include "LevelInstance.h"
//#include "PartInstance.h"
#include "PartInstance.h"
//#include "SelectionService.h"
//#include "GuiRootInstance.h"
//#include "ThumbnailGeneratorInstance.h"
//#include "XplicitNgine/XplicitNgine.h"
#include "XplicitNgine/XplicitNgine.h"
//#include "SoundService.h"
//#include "LightingInstance.h"
@@ -30,7 +30,7 @@ namespace B3D {
// Instance getters
// WorkspaceInstance* getWorkspace();
LevelInstance* getLevel();
// XplicitNgine* getEngine();
XplicitNgine* getEngine();
// ThumbnailGeneratorInstance* getThumbnailGenerator();
// SoundService* getSoundService();
// LightingInstance* getLighting();
@@ -55,7 +55,7 @@ namespace B3D {
// GuiRootInstance* guiRoot;
// SelectionService* selectionService;
// ThumbnailGeneratorInstance* thumbnailGenerator;
// XplicitNgine* xplicitNgine;
XplicitNgine* xplicitNgine;
// SoundService* soundService;
// LightingInstance* lightingInstance;
bool running;

View File

@@ -1,5 +1,6 @@
#pragma once
#include "Instance.h"
#include "Enum.h"
namespace B3D{
class LevelInstance : public Instance
{
@@ -17,8 +18,8 @@ class LevelInstance : public Instance
//Values
Reflection::ReflectionProperty<bool> highScoreIsGood;
Reflection::ReflectionProperty<int> timerUpAction;
Reflection::ReflectionProperty<int> timerAffectsScore;
Reflection::ReflectionProperty<Enum::ActionType::Value> timerUpAction;
Reflection::ReflectionProperty<Enum::AffectType::Value> timerAffectsScore;
Reflection::ReflectionProperty<bool> runOnOpen;
Reflection::ReflectionProperty<float> timer;
Reflection::ReflectionProperty<int> score;

View File

@@ -0,0 +1,38 @@
#pragma once
#include "Instance.h"
#include "Enum.h"
#include <ode/ode.h>
namespace B3D {
class PVInstance : public Instance
{
public:
~PVInstance(void);
virtual void postRender(RenderDevice* rd);
Reflection::ReflectionProperty<bool> nameShown;
Reflection::ReflectionProperty<bool> controllerFlagShown;
Reflection::ReflectionProperty<Enum::Controller::Value> controller;
protected:
PVInstance(void);
PVInstance(std::string);
Reflection::ReflectionProperty<CoordinateFrame> cFrame;
//TODO move elsewhere?
static G3D::Color3 getControllerColor(int controller)
{
switch(controller)
{
case Enum::Controller::KeyboardLeft:
return Color3::red();
case Enum::Controller::KeyboardRight:
return Color3::blue();
case Enum::Controller::Chase:
return Color3::black();
case Enum::Controller::Flee:
return Color3::yellow();
}
return Color3::gray();
}
};
}

View File

@@ -0,0 +1,101 @@
#pragma once
#include "PVInstance.h"
#include "Enum.h"
#define _USE_MATH_DEFINES
#include <cmath>
namespace B3D
{
class PartInstance : public PVInstance
{
public:
PartInstance(void);
~PartInstance(void);
//Reflective Properties
Reflection::ReflectionProperty<Color3> color;
Reflection::ReflectionProperty<bool> canCollide;
//Surfaces
Reflection::ReflectionProperty<Enum::SurfaceType::Value> top, front, right, back, left, bottom;
//Shapes
Reflection::ReflectionProperty<Enum::Shape::Value> shape;
//OnTouch
Reflection::ReflectionProperty<Enum::ActionType::Value> onTouchAction;
Reflection::ReflectionProperty<Enum::Sound::Value> OnTouchSound;
//Non-Reflective Variables
dBodyID physBody;
dGeomID physGeom[3];
//Functions
//Rendering
virtual void PartInstance::postRender(RenderDevice* rd);
virtual void render(RenderDevice*);
virtual void renderName(RenderDevice*);
//Getters
Vector3 getPosition();
Vector3 getVelocity();
Vector3 getRotVelocity();
Vector3 getSize();
Box getBox();
Sphere getSphere();
Box getScaledBox();
CoordinateFrame getCFrame();
//OnTouch Getters
bool isSingleShot();
int getTouchesToTrigger();
int getUniqueObjectsToTrigger();
int getChangeScore();
float getChangeTimer();
//Setters
void setParent(Instance* parent);
void setPosition(Vector3);
void setVelocity(Vector3);
void setRotVelocity(Vector3);
void setCFrame(CoordinateFrame);
void setCFrameNoSync(CoordinateFrame);
void setSize(Vector3);
void setShape(Enum::Shape::Value shape);
void setChanged();
void setSurface(int face, Enum::SurfaceType::Value surface);
void setAnchored(bool anchored);
bool isAnchored();
float getMass();
bool isDragging();
void setDragging(bool value);
//Collision
bool collides(PartInstance * part);
bool collides(Box);
// onTouch
void onTouch();
private:
//Reflective Properties
Reflection::ReflectionProperty<bool> anchored;
Reflection::ReflectionProperty<Vector3> position;
Reflection::ReflectionProperty<Vector3> size;
Reflection::ReflectionProperty<Vector3> velocity;
Reflection::ReflectionProperty<Vector3> rotVelocity;
// OnTouch
Reflection::ReflectionProperty<bool> singleShot;
Reflection::ReflectionProperty<int> touchesToTrigger;
Reflection::ReflectionProperty<int> uniqueObjectsToTrigger;
Reflection::ReflectionProperty<int> changeScore;
Reflection::ReflectionProperty<float> changeTimer;
//Non-reflective Variables
bool changed;
bool dragging;
Box itemBox;
GLuint glList;
bool _touchedOnce;
};
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include <ode/ode.h>
#include "DatamodelV3/Instance.h"
#include "DatamodelV3/PartInstance.h"
namespace B3D{
struct PhysWorldData{
dWorldID physWorld;
dSpaceID physSpace;
dJointGroupID contactgroup;
};
class XplicitNgine : public Instance
{
public:
XplicitNgine();
~XplicitNgine();
dWorldID physWorld;
dSpaceID physSpace;
PhysWorldData physWorldData;
dJointGroupID contactgroup;
void step(float stepSize);
void createBody(PartInstance* partInstance);
void deleteBody(PartInstance* partInstance);
void updateBody(PartInstance* partInstance);
void resetBody(PartInstance* partInstance);
};
}

View File

@@ -34,6 +34,7 @@ ReflectionProperty<T>::ReflectionProperty(void)
template<class T>
ReflectionProperty<T>::~ReflectionProperty(void)
{
dispose();
}
template<class T>