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