Made XplicitNgine secret instance of DataModel
This commit is contained in:
@@ -631,6 +631,14 @@
|
|||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="XplicitNgine"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\XplicitNgine\XplicitNgine.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Properties"
|
Name="Properties"
|
||||||
@@ -644,14 +652,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="XplicitNgine"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\source\XplicitNgine\XplicitNgine.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Header Files"
|
Name="Header Files"
|
||||||
@@ -872,6 +872,14 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="XplicitNgine"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\XplicitNgine\XplicitNgine.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Properties"
|
Name="Properties"
|
||||||
@@ -885,14 +893,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="XplicitNgine"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\XplicitNgine\XplicitNgine.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "IEBrowser.h"
|
#include "IEBrowser.h"
|
||||||
#include "Mouse.h"
|
#include "Mouse.h"
|
||||||
#include "Tool/Tool.h"
|
#include "Tool/Tool.h"
|
||||||
#include "XplicitNgine/XplicitNgine.h"
|
|
||||||
//#include "GuiRoot.h"
|
//#include "GuiRoot.h"
|
||||||
|
|
||||||
class TextButtonInstance;
|
class TextButtonInstance;
|
||||||
@@ -76,7 +75,6 @@ class Application { // : public GApp {
|
|||||||
HWND _buttonTest;
|
HWND _buttonTest;
|
||||||
HWND _hwndRenderer;
|
HWND _hwndRenderer;
|
||||||
DataModelInstance* _dataModel;
|
DataModelInstance* _dataModel;
|
||||||
XplicitNgine* _xplicitNgine;
|
|
||||||
G3D::TextureRef shadowMap;
|
G3D::TextureRef shadowMap;
|
||||||
std::string _title;
|
std::string _title;
|
||||||
bool _dragging;
|
bool _dragging;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "PartInstance.h"
|
#include "PartInstance.h"
|
||||||
#include "rapidxml/rapidxml.hpp"
|
#include "rapidxml/rapidxml.hpp"
|
||||||
#include "GuiRootInstance.h"
|
#include "GuiRootInstance.h"
|
||||||
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
|
|
||||||
class GuiRootInstance;
|
class GuiRootInstance;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ public:
|
|||||||
void drawMessage(RenderDevice*);
|
void drawMessage(RenderDevice*);
|
||||||
WorkspaceInstance* getWorkspace();
|
WorkspaceInstance* getWorkspace();
|
||||||
LevelInstance * getLevel();
|
LevelInstance * getLevel();
|
||||||
|
XplicitNgine * getEngine();
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string _loadedFileName;
|
std::string _loadedFileName;
|
||||||
bool showMessage;
|
bool showMessage;
|
||||||
@@ -38,6 +40,7 @@ public:
|
|||||||
void clearLevel();
|
void clearLevel();
|
||||||
void toggleRun();
|
void toggleRun();
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
|
void resetEngine();
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
void modXMLLevel(float modY);
|
void modXMLLevel(float modY);
|
||||||
#endif
|
#endif
|
||||||
@@ -54,4 +57,5 @@ private:
|
|||||||
LevelInstance * level;
|
LevelInstance * level;
|
||||||
GuiRootInstance* guiRoot;
|
GuiRootInstance* guiRoot;
|
||||||
bool running;
|
bool running;
|
||||||
|
XplicitNgine * xplicitNgine;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ode/ode.h>
|
#include <ode/ode.h>
|
||||||
|
#include "DatamodelV2/Instance.h"
|
||||||
#include "DatamodelV2/PartInstance.h"
|
#include "DatamodelV2/PartInstance.h"
|
||||||
|
|
||||||
class XplicitNgine
|
class XplicitNgine : Instance
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XplicitNgine();
|
XplicitNgine();
|
||||||
|
|||||||
@@ -188,9 +188,6 @@ void Application::onInit() {
|
|||||||
_dataModel->setName("undefined");
|
_dataModel->setName("undefined");
|
||||||
_dataModel->font = g_fntdominant;
|
_dataModel->font = g_fntdominant;
|
||||||
g_dataModel = _dataModel;
|
g_dataModel = _dataModel;
|
||||||
|
|
||||||
_xplicitNgine = new XplicitNgine();
|
|
||||||
g_xplicitNgine = _xplicitNgine;
|
|
||||||
|
|
||||||
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
||||||
// Anchored this baseplate for XplicitNgine tests
|
// Anchored this baseplate for XplicitNgine tests
|
||||||
@@ -305,7 +302,7 @@ void Application::onLogic() {
|
|||||||
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
|
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
|
||||||
{
|
{
|
||||||
PartInstance* partInstance = _dataModel->getWorkspace()->partObjects[i];
|
PartInstance* partInstance = _dataModel->getWorkspace()->partObjects[i];
|
||||||
_xplicitNgine->createBody(partInstance);
|
_dataModel->getEngine()->createBody(partInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,21 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
_loadedFileName="..//skooter.rbxm";
|
_loadedFileName="..//skooter.rbxm";
|
||||||
listicon = 5;
|
listicon = 5;
|
||||||
running = false;
|
running = false;
|
||||||
|
xplicitNgine = NULL;
|
||||||
|
resetEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataModelInstance::resetEngine()
|
||||||
|
{
|
||||||
|
if(xplicitNgine != NULL)
|
||||||
|
delete xplicitNgine;
|
||||||
|
xplicitNgine = new XplicitNgine();
|
||||||
|
g_xplicitNgine = xplicitNgine;
|
||||||
|
}
|
||||||
|
|
||||||
|
XplicitNgine * DataModelInstance::getEngine()
|
||||||
|
{
|
||||||
|
return xplicitNgine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModelInstance::toggleRun()
|
void DataModelInstance::toggleRun()
|
||||||
@@ -47,6 +61,7 @@ bool DataModelInstance::isRunning()
|
|||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
DataModelInstance::~DataModelInstance(void)
|
||||||
{
|
{
|
||||||
|
delete xplicitNgine;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -448,6 +463,7 @@ bool DataModelInstance::load(const char* filename, bool clearObjects)
|
|||||||
std::string hname = sfilename.substr(begin);
|
std::string hname = sfilename.substr(begin);
|
||||||
std::string tname = hname.substr(0, hname.length() - 5);
|
std::string tname = hname.substr(0, hname.length() - 5);
|
||||||
name = tname;
|
name = tname;
|
||||||
|
resetEngine();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ XplicitNgine::XplicitNgine()
|
|||||||
contactgroup = dJointGroupCreate(0);
|
contactgroup = dJointGroupCreate(0);
|
||||||
|
|
||||||
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
dWorldSetGravity(physWorld, 0, -0.5, 0);
|
||||||
|
|
||||||
|
this->name = "PhysicsService";
|
||||||
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
//dGeomID ground_geom = dCreatePlane(physSpace, 0, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,14 +43,16 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
|
|||||||
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
|
n = dCollide (o1,o2,N,&contact[0].geom,sizeof(dContact));
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
contact[i].surface.mode = dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
contact[i].surface.mode = dContactBounce | dContactSlip1 | dContactSlip2 | dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||||
|
|
||||||
// Define contact surface properties
|
// Define contact surface properties
|
||||||
contact[i].surface.mu = 0.5;
|
|
||||||
|
contact[i].surface.bounce = 0.5; //Elasticity
|
||||||
|
contact[i].surface.mu = 0.3F; //Friction
|
||||||
contact[i].surface.slip1 = 0.0;
|
contact[i].surface.slip1 = 0.0;
|
||||||
contact[i].surface.slip2 = 0.0;
|
contact[i].surface.slip2 = 0.0;
|
||||||
contact[i].surface.soft_erp = 0.8;
|
contact[i].surface.soft_erp = 0.8F;
|
||||||
contact[i].surface.soft_cfm = 0.01;
|
contact[i].surface.soft_cfm = 0.01F;
|
||||||
|
|
||||||
// Create joints
|
// Create joints
|
||||||
dJointID c = dJointCreateContact(
|
dJointID c = dJointCreateContact(
|
||||||
@@ -119,22 +123,22 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
dGeomSetBody(partInstance->physGeom[0], partInstance->physBody);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(partInstance->anchored)
|
if(!partInstance->anchored)
|
||||||
return;
|
{
|
||||||
|
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
||||||
const dReal* physPosition = dBodyGetPosition(partInstance->physBody);
|
|
||||||
|
// TODO: Rotation code
|
||||||
// TODO: Rotation code
|
// Probably should be done AFTER we get physics KINDA working!!!
|
||||||
// Probably should be done AFTER we get physics KINDA working!!!
|
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
||||||
const dReal* physRotation = dGeomGetRotation(partInstance->physGeom[0]);
|
//partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
||||||
//partInstance->setPosition(Vector3(physPosition[0], physPosition[1], physPosition[2]));
|
partInstance->setCFrame(CoordinateFrame(
|
||||||
partInstance->setCFrame(CoordinateFrame(
|
Matrix3(physRotation[0],physRotation[1],physRotation[2],
|
||||||
Matrix3(physRotation[0],physRotation[1],physRotation[2],
|
physRotation[4],physRotation[5],physRotation[6],
|
||||||
physRotation[4],physRotation[5],physRotation[6],
|
physRotation[8],physRotation[9],physRotation[10]),
|
||||||
physRotation[8],physRotation[9],physRotation[10]),
|
Vector3(physPosition[0], physPosition[1], physPosition[2])));
|
||||||
Vector3(physPosition[0], physPosition[1], physPosition[2])));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dWorldQuickStep(physWorld,0.05);
|
dWorldQuickStep(physWorld,0.05F);
|
||||||
dJointGroupEmpty(contactgroup);
|
dJointGroupEmpty(contactgroup);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user