Initial JointsService and Snap implementation
This is incomplete and some issues need to be fixed
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8.00"
|
Version="8,00"
|
||||||
Name="Blocks3D"
|
Name="Blocks3D"
|
||||||
ProjectGUID="{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}"
|
ProjectGUID="{6C4D6EEF-B1D1-456A-B850-92CAB17124BE}"
|
||||||
RootNamespace="Blocks3D"
|
RootNamespace="Blocks3D"
|
||||||
@@ -439,6 +439,10 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV2\JointsService.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV2\LevelInstance.cpp"
|
RelativePath=".\src\source\DataModelV2\LevelInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -513,6 +517,10 @@
|
|||||||
RelativePath=".\src\source\DataModelV2\SelectionService.cpp"
|
RelativePath=".\src\source\DataModelV2\SelectionService.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV2\SnapInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV2\SoundInstance.cpp"
|
RelativePath=".\src\source\DataModelV2\SoundInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -886,6 +894,10 @@
|
|||||||
RelativePath=".\src\include\DataModelV2\Instance.h"
|
RelativePath=".\src\include\DataModelV2\Instance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\JointsService.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
|
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
|
||||||
>
|
>
|
||||||
@@ -906,6 +918,10 @@
|
|||||||
RelativePath=".\src\include\DataModelV2\SelectionService.h"
|
RelativePath=".\src\include\DataModelV2\SelectionService.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\SnapInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\SoundInstance.h"
|
RelativePath=".\src\include\DataModelV2\SoundInstance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
#include "SoundService.h"
|
#include "SoundService.h"
|
||||||
#include "LightingInstance.h"
|
#include "LightingInstance.h"
|
||||||
|
#include "JointsService.h"
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "rapidxml/rapidxml.hpp"
|
#include "rapidxml/rapidxml.hpp"
|
||||||
@@ -37,6 +38,7 @@ public:
|
|||||||
XplicitNgine* getEngine();
|
XplicitNgine* getEngine();
|
||||||
ThumbnailGeneratorInstance* getThumbnailGenerator();
|
ThumbnailGeneratorInstance* getThumbnailGenerator();
|
||||||
SoundService* getSoundService();
|
SoundService* getSoundService();
|
||||||
|
JointsService* getJointsService();
|
||||||
LightingInstance* getLighting();
|
LightingInstance* getLighting();
|
||||||
|
|
||||||
std::string message;
|
std::string message;
|
||||||
@@ -72,6 +74,7 @@ private:
|
|||||||
XplicitNgine* xplicitNgine;
|
XplicitNgine* xplicitNgine;
|
||||||
SoundService* soundService;
|
SoundService* soundService;
|
||||||
LightingInstance* lightingInstance;
|
LightingInstance* lightingInstance;
|
||||||
|
JointsService* jointsService;
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
13
src/include/DataModelV2/JointsService.h
Normal file
13
src/include/DataModelV2/JointsService.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
#include "PartInstance.h"
|
||||||
|
|
||||||
|
class JointsService:
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JointsService(void);
|
||||||
|
~JointsService(void);
|
||||||
|
void createSnap(PartInstance* Part1, PartInstance* Part2);
|
||||||
|
void destroyPartSnap(PartInstance* Part);
|
||||||
|
};
|
||||||
13
src/include/DataModelV2/SnapInstance.h
Normal file
13
src/include/DataModelV2/SnapInstance.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
#include "PartInstance.h"
|
||||||
|
|
||||||
|
class SnapInstance:
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SnapInstance(PartInstance* Part1, PartInstance* Part2);
|
||||||
|
~SnapInstance(void);
|
||||||
|
PartInstance* Joint1;
|
||||||
|
PartInstance* Joint2;
|
||||||
|
};
|
||||||
@@ -17,4 +17,6 @@ public:
|
|||||||
void deleteBody(PartInstance* partInstance);
|
void deleteBody(PartInstance* partInstance);
|
||||||
void updateBody(PartInstance* partInstance);
|
void updateBody(PartInstance* partInstance);
|
||||||
void resetBody(PartInstance* partInstance);
|
void resetBody(PartInstance* partInstance);
|
||||||
|
void createJoint(PartInstance *part1, PartInstance *part2);
|
||||||
|
void destroyJoint(PartInstance *part);
|
||||||
};
|
};
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "DataModelV2/DataModelInstance.h"
|
#include "DataModelV2/DataModelInstance.h"
|
||||||
#include "DataModelV2/GuiRootInstance.h"
|
#include "DataModelV2/GuiRootInstance.h"
|
||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
|
#include "DataModelV2/JointsService.h"
|
||||||
#include "CameraController.h"
|
#include "CameraController.h"
|
||||||
#include "AudioPlayer.h"
|
#include "AudioPlayer.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
@@ -200,7 +201,12 @@ void Application::onInit() {
|
|||||||
|
|
||||||
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
#ifdef LEGACY_LOAD_G3DFUN_LEVEL
|
||||||
// Anchored this baseplate for XplicitNgine tests
|
// Anchored this baseplate for XplicitNgine tests
|
||||||
|
//XplicitNgine ngine;
|
||||||
PartInstance* test = makePart();
|
PartInstance* test = makePart();
|
||||||
|
PartInstance* test2;
|
||||||
|
PartInstance* test3;
|
||||||
|
JointsService* JointsSvc = g_dataModel->getJointsService();
|
||||||
|
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
test->color = Color3(0.2F,0.3F,1);
|
test->color = Color3(0.2F,0.3F,1);
|
||||||
test->setSize(Vector3(24,1,24));
|
test->setSize(Vector3(24,1,24));
|
||||||
@@ -223,12 +229,12 @@ void Application::onInit() {
|
|||||||
test->setPosition(Vector3(10,1,0));
|
test->setPosition(Vector3(10,1,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
|
||||||
test = makePart();
|
test2 = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test2->setParent(_dataModel->getWorkspace());
|
||||||
test->color = Color3::gray();
|
test2->color = Color3::red();
|
||||||
test->setSize(Vector3(4,1,2));
|
test2->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(7,2,0));
|
test2->setPosition(Vector3(7,2,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test2->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
@@ -237,12 +243,14 @@ void Application::onInit() {
|
|||||||
test->setPosition(Vector3(-7,2,0));
|
test->setPosition(Vector3(-7,2,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
|
||||||
test = makePart();
|
test3 = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test3->setParent(_dataModel->getWorkspace());
|
||||||
test->color = Color3::gray();
|
test3->color = Color3::red();
|
||||||
test->setSize(Vector3(4,1,2));
|
test3->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(4,3,0));
|
test3->setPosition(Vector3(4,3,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test3->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
JointsSvc->createSnap(test2, test3);
|
||||||
|
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
@@ -253,10 +261,11 @@ void Application::onInit() {
|
|||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
test->color = Color3::gray();
|
test->color = Color3::red();
|
||||||
test->setSize(Vector3(4,1,2));
|
test->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(1,4,0));
|
test->setPosition(Vector3(1,4,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
JointsSvc->createSnap(test, test3);
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
@@ -338,7 +347,6 @@ void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
_dataModel->getEngine()->step(0.03F);
|
_dataModel->getEngine()->step(0.03F);
|
||||||
}
|
}
|
||||||
onLogic();
|
onLogic();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_dataModel->getGuiRoot()->update();
|
_dataModel->getGuiRoot()->update();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
thumbnailGenerator = new ThumbnailGeneratorInstance();
|
thumbnailGenerator = new ThumbnailGeneratorInstance();
|
||||||
soundService = new SoundService();
|
soundService = new SoundService();
|
||||||
lightingInstance = new LightingInstance();
|
lightingInstance = new LightingInstance();
|
||||||
|
jointsService = new JointsService();
|
||||||
|
|
||||||
selectionService = new SelectionService();
|
selectionService = new SelectionService();
|
||||||
selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
||||||
@@ -41,6 +42,7 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
level->setParent(this);
|
level->setParent(this);
|
||||||
soundService->setParent(this);
|
soundService->setParent(this);
|
||||||
lightingInstance->setParent(this);
|
lightingInstance->setParent(this);
|
||||||
|
jointsService->setParent(this);
|
||||||
|
|
||||||
_loadedFileName="..//skooter.rbxm";
|
_loadedFileName="..//skooter.rbxm";
|
||||||
listicon = 5;
|
listicon = 5;
|
||||||
@@ -672,6 +674,11 @@ SoundService* DataModelInstance::getSoundService()
|
|||||||
return soundService;
|
return soundService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JointsService* DataModelInstance::getJointsService()
|
||||||
|
{
|
||||||
|
return jointsService;
|
||||||
|
}
|
||||||
|
|
||||||
LightingInstance* DataModelInstance::getLighting()
|
LightingInstance* DataModelInstance::getLighting()
|
||||||
{
|
{
|
||||||
return lightingInstance;
|
return lightingInstance;
|
||||||
|
|||||||
35
src/source/DataModelV2/JointsService.cpp
Normal file
35
src/source/DataModelV2/JointsService.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "DataModelV2/JointsService.h"
|
||||||
|
#include "DataModelV2/SnapInstance.h"
|
||||||
|
#include "StringFunctions.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
|
JointsService::JointsService()
|
||||||
|
{
|
||||||
|
name = "JointsService";
|
||||||
|
className = "JointsService";
|
||||||
|
canDelete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
JointsService::~JointsService(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void JointsService::createSnap(PartInstance* Part1, PartInstance* Part2)
|
||||||
|
{
|
||||||
|
SnapInstance* Snap = new SnapInstance(Part1, Part2);
|
||||||
|
Snap->setParent(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//This is only for removing the Snap instance not for removing the joint
|
||||||
|
void JointsService::destroyPartSnap(PartInstance* Part)
|
||||||
|
{
|
||||||
|
std::vector<Instance* > children = getChildren();
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
SnapInstance* Snap = (SnapInstance*)children.at(i);
|
||||||
|
if((Snap->Joint1 == Part) || (Snap->Joint2 == Part))
|
||||||
|
{
|
||||||
|
removeChild(Snap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -398,6 +398,7 @@ void PartInstance::render(RenderDevice* rd) {
|
|||||||
PartInstance::~PartInstance(void)
|
PartInstance::~PartInstance(void)
|
||||||
{
|
{
|
||||||
glDeleteLists(glList, 1);
|
glDeleteLists(glList, 1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Causes some weird ODE error
|
// Causes some weird ODE error
|
||||||
// Someone, please look into this
|
// Someone, please look into this
|
||||||
|
|||||||
29
src/source/DataModelV2/SnapInstance.cpp
Normal file
29
src/source/DataModelV2/SnapInstance.cpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include "DataModelV2/SnapInstance.h"
|
||||||
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
|
#include "StringFunctions.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
|
||||||
|
SnapInstance::SnapInstance(PartInstance* Part1, PartInstance* Part2)
|
||||||
|
{
|
||||||
|
XplicitNgine* Phys = g_xplicitNgine;
|
||||||
|
name = "Snap";
|
||||||
|
className = "Snap";
|
||||||
|
Joint1 = Part1;
|
||||||
|
Joint2 = Part2;
|
||||||
|
|
||||||
|
if (Part1->physBody == NULL)
|
||||||
|
Phys->createBody(Part1);
|
||||||
|
|
||||||
|
if (Part2->physBody == NULL)
|
||||||
|
Phys->createBody(Part2);
|
||||||
|
|
||||||
|
Phys->createJoint(Part1, Part2);
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapInstance::~SnapInstance(void)
|
||||||
|
{
|
||||||
|
XplicitNgine* Phys = g_xplicitNgine;
|
||||||
|
printf("SnapInstance destroyed...");
|
||||||
|
Phys->destroyJoint(Joint1);
|
||||||
|
Phys->destroyJoint(Joint2);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
|
#include "DataModelV2/JointsService.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
XplicitNgine::XplicitNgine()
|
XplicitNgine::XplicitNgine()
|
||||||
@@ -81,6 +82,7 @@ void collisionCallback(void *data, dGeomID o1, dGeomID o2)
|
|||||||
|
|
||||||
void XplicitNgine::deleteBody(PartInstance* partInstance)
|
void XplicitNgine::deleteBody(PartInstance* partInstance)
|
||||||
{
|
{
|
||||||
|
g_dataModel->getJointsService()->destroyPartSnap(partInstance);
|
||||||
if(partInstance->physBody != NULL)
|
if(partInstance->physBody != NULL)
|
||||||
{
|
{
|
||||||
dBodyEnable(partInstance->physBody);
|
dBodyEnable(partInstance->physBody);
|
||||||
@@ -233,4 +235,22 @@ void XplicitNgine::updateBody(PartInstance *partInstance)
|
|||||||
|
|
||||||
dBodySetRotation(partInstance->physBody, rotation);
|
dBodySetRotation(partInstance->physBody, rotation);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XplicitNgine::createJoint(PartInstance *part1, PartInstance *part2)
|
||||||
|
{
|
||||||
|
printf("XplicitNgine::createJoint called\n");
|
||||||
|
if((part1->physBody != NULL) & (part2->physBody != NULL)){
|
||||||
|
printf("creating a fixed joint\n");
|
||||||
|
dJointID c = dJointCreateFixed(physWorld, 0);
|
||||||
|
dJointAttach(c, part1->physBody, part2->physBody);
|
||||||
|
dJointSetFixed(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void XplicitNgine::destroyJoint(PartInstance *part)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < dBodyGetNumJoints(part->physBody); i++)
|
||||||
|
dJointDestroy(dBodyGetJoint(part->physBody, i));
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user