Compare commits
6 Commits
feature/pr
...
JointsServ
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e365f3ed6c | ||
|
|
998a22a43f | ||
|
|
abb1f76c71 | ||
|
|
85e84bfdf3 | ||
|
|
f7a76511a8 | ||
|
|
9cee74baf4 |
@@ -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"
|
||||||
>
|
>
|
||||||
@@ -675,26 +683,14 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="PropertiesV2"
|
Name="Properties"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\PropertiesV2\BoolProperty.cpp"
|
RelativePath=".\src\source\Properties\BoolProperty.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\PropertiesV2\Color3Property.cpp"
|
RelativePath=".\src\source\Properties\Property.cpp"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\source\PropertiesV2\Property.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\source\PropertiesV2\StringProperty.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\source\PropertiesV2\Vector3Property.cpp"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -898,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"
|
||||||
>
|
>
|
||||||
@@ -918,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"
|
||||||
>
|
>
|
||||||
@@ -972,26 +976,14 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="PropertiesV2"
|
Name="Properties"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\PropertiesV2\BoolProperty.h"
|
RelativePath=".\src\include\Properties\BoolProperty.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\PropertiesV2\Color3Property.h"
|
RelativePath=".\src\include\Properties\Property.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\PropertiesV2\Property.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\PropertiesV2\StringProperty.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\PropertiesV2\Vector3Property.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -1003,14 +995,6 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="B3DEnum"
|
|
||||||
>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\Enum\B3DEnum.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Resource Files"
|
Name="Resource Files"
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <G3DAll.h>
|
#include <G3DAll.h>
|
||||||
#include "propertyGrid.h"
|
#include "propertyGrid.h"
|
||||||
#include "PropertiesV2/StringProperty.h"
|
|
||||||
#include "PropertiesV2/BoolProperty.h"
|
|
||||||
#include "map"
|
#include "map"
|
||||||
|
|
||||||
class Instance
|
class Instance
|
||||||
@@ -18,6 +16,7 @@ public:
|
|||||||
virtual void update();
|
virtual void update();
|
||||||
std::vector<Instance*> children; // All children.
|
std::vector<Instance*> children; // All children.
|
||||||
std::string getClassName();
|
std::string getClassName();
|
||||||
|
bool Instance::isA(std::string name);
|
||||||
Instance* findFirstChild(std::string);
|
Instance* findFirstChild(std::string);
|
||||||
std::vector<Instance* > getChildren();
|
std::vector<Instance* > getChildren();
|
||||||
std::vector<Instance* > getAllChildren();
|
std::vector<Instance* > getAllChildren();
|
||||||
@@ -27,19 +26,14 @@ public:
|
|||||||
void removeChild(Instance*);
|
void removeChild(Instance*);
|
||||||
void clearChildren();
|
void clearChildren();
|
||||||
Instance* getParent();
|
Instance* getParent();
|
||||||
|
void remove();
|
||||||
virtual Instance* clone() const { return new Instance(*this); }
|
virtual Instance* clone() const { return new Instance(*this); }
|
||||||
//Deprecated
|
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
//Deprecated
|
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
|
||||||
virtual std::vector<Property *> collectProperties();
|
|
||||||
|
|
||||||
int listicon;
|
int listicon;
|
||||||
protected:
|
protected:
|
||||||
std::string className;
|
std::string className;
|
||||||
Instance* parent; // Another pointer.
|
Instance* parent; // Another pointer.
|
||||||
//Deprecated
|
|
||||||
PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[] = NULL);
|
PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[] = NULL);
|
||||||
private:
|
private:
|
||||||
static const std::map<std::string, Instance> g_logLevelsDescriptions;
|
static const std::map<std::string, Instance> g_logLevelsDescriptions;
|
||||||
|
|||||||
15
src/include/DataModelV2/JointsService.h
Normal file
15
src/include/DataModelV2/JointsService.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#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);
|
||||||
|
void JointsService::solvePartSnap(PartInstance* Part, PartInstance* Part2);
|
||||||
|
void JointsService::solveWorkspaceSnaps();
|
||||||
|
};
|
||||||
@@ -13,13 +13,9 @@ public:
|
|||||||
virtual void postRender(RenderDevice* rd);
|
virtual void postRender(RenderDevice* rd);
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
virtual std::vector<Property*> collectProperties();
|
|
||||||
bool nameShown;
|
bool nameShown;
|
||||||
bool controllerFlagShown;
|
bool controllerFlagShown;
|
||||||
Enum::Controller::Value controller;
|
Enum::Controller::Value controller;
|
||||||
virtual void makeJoints();
|
|
||||||
virtual void setNameShown(bool nameShown);
|
|
||||||
virtual void setControllerFlagShown(bool controllerFlagShown);
|
|
||||||
protected:
|
protected:
|
||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
static G3D::Color3 getControllerColor(int controller)
|
static G3D::Color3 getControllerColor(int controller)
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "PVInstance.h"
|
#include "PVInstance.h"
|
||||||
#include "Enum.h"
|
#include "Enum.h"
|
||||||
#include "PropertiesV2/Color3Property.h"
|
|
||||||
#include "PropertiesV2/Vector3Property.h"
|
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@@ -61,7 +59,6 @@ public:
|
|||||||
//Setters
|
//Setters
|
||||||
void setParent(Instance* parent);
|
void setParent(Instance* parent);
|
||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
void setColor(Color3 color);
|
|
||||||
void setVelocity(Vector3);
|
void setVelocity(Vector3);
|
||||||
void setRotVelocity(Vector3);
|
void setRotVelocity(Vector3);
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
@@ -86,7 +83,6 @@ public:
|
|||||||
//Properties
|
//Properties
|
||||||
virtual std::vector<PROPGRIDITEM> getProperties();
|
virtual std::vector<PROPGRIDITEM> getProperties();
|
||||||
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
virtual std::vector<Property *> collectProperties();
|
|
||||||
private:
|
private:
|
||||||
bool anchored;
|
bool anchored;
|
||||||
Vector3 position;
|
Vector3 position;
|
||||||
|
|||||||
14
src/include/DataModelV2/SnapInstance.h
Normal file
14
src/include/DataModelV2/SnapInstance.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
#include "PartInstance.h"
|
||||||
|
|
||||||
|
class SnapInstance:
|
||||||
|
public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SnapInstance(PartInstance* Part1, PartInstance* Part2);
|
||||||
|
~SnapInstance(void);
|
||||||
|
PartInstance* jPart1;
|
||||||
|
PartInstance* jPart2;
|
||||||
|
dJointID JointID;
|
||||||
|
};
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Enum
|
namespace Enum
|
||||||
{
|
{
|
||||||
@@ -9,30 +7,6 @@ namespace Enum
|
|||||||
enum Value {
|
enum Value {
|
||||||
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5
|
Smooth = 0, Bumps = 1, Hinge = 2, Motor = 3, StepperMotor = 4, Spawn = 5
|
||||||
};
|
};
|
||||||
static std::pair<std::string, Value> map_data[] = {
|
|
||||||
std::make_pair("Smooth", Smooth),
|
|
||||||
std::make_pair("Bumps", Bumps),
|
|
||||||
std::make_pair("Hinge", Hinge),
|
|
||||||
std::make_pair("Motor", Motor),
|
|
||||||
std::make_pair("StepperMotor", StepperMotor),
|
|
||||||
std::make_pair("Spawn", Spawn)
|
|
||||||
};
|
|
||||||
static std::map<std::string, Value> nameMap(map_data,
|
|
||||||
map_data + sizeof map_data / sizeof map_data[0]);
|
|
||||||
|
|
||||||
static Value getByName(std::string name) {
|
|
||||||
if(nameMap.find(name) != nameMap.end()){
|
|
||||||
return nameMap[name];
|
|
||||||
}
|
|
||||||
return Smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string getName(Value value) {
|
|
||||||
for (std::map<std::string, Value>::iterator it = nameMap.begin(); it != nameMap.end(); ++it)
|
|
||||||
if (it->second == value)
|
|
||||||
return it->first;
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
namespace Shape
|
namespace Shape
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
namespace Enum
|
|
||||||
{
|
|
||||||
class B3DEnum {
|
|
||||||
public:
|
|
||||||
B3DEnum(int id, std::string name)
|
|
||||||
{
|
|
||||||
this->id = id;
|
|
||||||
this->name = name;
|
|
||||||
}
|
|
||||||
const int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
const std::string getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
virtual B3DEnum getByName(std::string name);
|
|
||||||
virtual B3DEnum getById(int id);
|
|
||||||
private:
|
|
||||||
int id;
|
|
||||||
std::string name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
12
src/include/Properties/BoolProperty.h
Normal file
12
src/include/Properties/BoolProperty.h
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Property.h"
|
||||||
|
class BoolProperty : public Property<bool>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BoolProperty(std::string name, bool& value, Instance& owner)
|
||||||
|
{
|
||||||
|
Property<bool>(name, value, owner);
|
||||||
|
}
|
||||||
|
~BoolProperty(void);
|
||||||
|
PROPGRIDITEM getPropGridItem();
|
||||||
|
};
|
||||||
30
src/include/Properties/Property.h
Normal file
30
src/include/Properties/Property.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "DataModelV2/Instance.h"
|
||||||
|
#include <string>
|
||||||
|
class Instance;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class Property
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Property(std::string name, T& value, Instance& owner)
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
_owner = owner;
|
||||||
|
}
|
||||||
|
~Property(void);
|
||||||
|
const T getValue()
|
||||||
|
{
|
||||||
|
return _value;
|
||||||
|
}
|
||||||
|
const void setValue(T val)
|
||||||
|
{
|
||||||
|
_value = val;
|
||||||
|
}
|
||||||
|
virtual PROPGRIDITEM getPropGridItem();
|
||||||
|
void setProperty(LPPROPGRIDITEM item);
|
||||||
|
protected:
|
||||||
|
Instance* _owner;
|
||||||
|
std::string _name;
|
||||||
|
T* _value;
|
||||||
|
};
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Property.h"
|
|
||||||
|
|
||||||
class BoolProperty : public Property
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void (Instance::*instanceSetter)(bool);
|
|
||||||
//Win32 why
|
|
||||||
~BoolProperty(void);
|
|
||||||
BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc)
|
|
||||||
:Property(name, desc, catalog, (void*)value, owner)
|
|
||||||
{
|
|
||||||
this->setterFunc = setterFunc;
|
|
||||||
}
|
|
||||||
const void setValue(bool val){
|
|
||||||
(_owner->*setterFunc)(val);
|
|
||||||
_value = (void *)val;
|
|
||||||
}
|
|
||||||
PROPGRIDITEM getPropGridItem();
|
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
private:
|
|
||||||
instanceSetter setterFunc;
|
|
||||||
};
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Property.h"
|
|
||||||
|
|
||||||
class Color3Property : public Property
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void (Instance::*instanceSetter)(Color3);
|
|
||||||
~Color3Property(void){};
|
|
||||||
Color3Property(LPSTR name, LPSTR desc, LPSTR catalog, Color3 value, Instance * owner, instanceSetter setterFunc)
|
|
||||||
:Property(name, desc, catalog, &_value, owner)
|
|
||||||
{
|
|
||||||
this->_value = value;
|
|
||||||
this->setterFunc = setterFunc;
|
|
||||||
}
|
|
||||||
const void setValue(Color3 val){
|
|
||||||
(_owner->*setterFunc)(val);
|
|
||||||
_value = val;
|
|
||||||
}
|
|
||||||
PROPGRIDITEM getPropGridItem();
|
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
private:
|
|
||||||
Color3 _value;
|
|
||||||
instanceSetter setterFunc;
|
|
||||||
};
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <G3DAll.h>
|
|
||||||
#include "propertyGrid.h"
|
|
||||||
|
|
||||||
class Instance;
|
|
||||||
|
|
||||||
class Property
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Property(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner){
|
|
||||||
_name = name;
|
|
||||||
_desc = desc;
|
|
||||||
_catalog = catalog;
|
|
||||||
_owner = owner;
|
|
||||||
}
|
|
||||||
Property(LPSTR name, LPSTR desc, LPSTR catalog, void* value, Instance * owner){
|
|
||||||
_name = name;
|
|
||||||
_desc = desc;
|
|
||||||
_catalog = catalog;
|
|
||||||
_owner = owner;
|
|
||||||
_value = value;
|
|
||||||
}
|
|
||||||
~Property(void){}
|
|
||||||
const void* getValue() {
|
|
||||||
return _value;
|
|
||||||
}
|
|
||||||
const LPSTR getName() {
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
virtual PROPGRIDITEM getPropGridItem();
|
|
||||||
virtual void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
protected:
|
|
||||||
Instance* _owner;
|
|
||||||
LPSTR _name;
|
|
||||||
LPSTR _desc;
|
|
||||||
LPSTR _catalog;
|
|
||||||
void* _value;
|
|
||||||
};
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Property.h"
|
|
||||||
|
|
||||||
class StringProperty : public Property
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void (Instance::*instanceSetter)(std::string);
|
|
||||||
~StringProperty(void){};
|
|
||||||
StringProperty(LPSTR name, LPSTR desc, LPSTR catalog, std::string value, Instance * owner, instanceSetter setterFunc)
|
|
||||||
:Property(name, desc, catalog, &_value, owner)
|
|
||||||
{
|
|
||||||
this->_value = value;
|
|
||||||
this->setterFunc = setterFunc;
|
|
||||||
}
|
|
||||||
const void setValue(std::string val){
|
|
||||||
(_owner->*setterFunc)(val);
|
|
||||||
_value = val;
|
|
||||||
}
|
|
||||||
PROPGRIDITEM getPropGridItem();
|
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
private:
|
|
||||||
std::string _value;
|
|
||||||
instanceSetter setterFunc;
|
|
||||||
};
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Property.h"
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
class Vector3Property : public Property
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
typedef void (Instance::*instanceSetter)(Vector3);
|
|
||||||
~Vector3Property(void){};
|
|
||||||
Vector3Property(LPSTR name, LPSTR desc, LPSTR catalog, Vector3 value, Instance * owner, instanceSetter setterFunc)
|
|
||||||
:Property(name, desc, catalog, &_value, owner)
|
|
||||||
{
|
|
||||||
this->_value = value;
|
|
||||||
this->setterFunc = setterFunc;
|
|
||||||
}
|
|
||||||
const void setValue(Vector3 val){
|
|
||||||
(_owner->*setterFunc)(val);
|
|
||||||
_value = val;
|
|
||||||
}
|
|
||||||
PROPGRIDITEM getPropGridItem();
|
|
||||||
void setProperty(LPPROPGRIDITEM &pItem);
|
|
||||||
private:
|
|
||||||
Vector3 _value;
|
|
||||||
std::string stringRep;
|
|
||||||
instanceSetter setterFunc;
|
|
||||||
};
|
|
||||||
@@ -15,5 +15,4 @@ private:
|
|||||||
HWND _explorerComboBox;
|
HWND _explorerComboBox;
|
||||||
void _resize();
|
void _resize();
|
||||||
void clearExplorer();
|
void clearExplorer();
|
||||||
void deleteProperties();
|
|
||||||
};
|
};
|
||||||
@@ -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);
|
||||||
|
dJointID createJoint(PartInstance *part1, PartInstance *part2);
|
||||||
|
void destroyJoints(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,11 +201,16 @@ 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));
|
||||||
test->setPosition(Vector3(0,0,0));
|
test->setPosition(Vector3(0,-10,0));
|
||||||
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0)));
|
test->setCFrame(test->getCFrame() * Matrix3::fromEulerAnglesXYZ(0,toRadians(0),toRadians(0)));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
test->setAnchored(true);
|
test->setAnchored(true);
|
||||||
@@ -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,12 @@ 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);
|
||||||
|
//JointsSvc->solvePartSnap(test3, test);
|
||||||
|
|
||||||
test = makePart();
|
test = makePart();
|
||||||
test->setParent(_dataModel->getWorkspace());
|
test->setParent(_dataModel->getWorkspace());
|
||||||
@@ -285,6 +295,8 @@ void Application::onInit() {
|
|||||||
test->setSize(Vector3(4,1,2));
|
test->setSize(Vector3(4,1,2));
|
||||||
test->setPosition(Vector3(2,7,0));
|
test->setPosition(Vector3(2,7,0));
|
||||||
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
test->setSurface(TOP, Enum::SurfaceType::Bumps);
|
||||||
|
|
||||||
|
JointsSvc->solveWorkspaceSnaps();
|
||||||
#else
|
#else
|
||||||
_dataModel->debugGetOpen();
|
_dataModel->debugGetOpen();
|
||||||
#endif
|
#endif
|
||||||
@@ -338,7 +350,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;
|
||||||
@@ -502,8 +504,12 @@ bool DataModelInstance::load(const char* filename, bool clearObjects)
|
|||||||
std::string tname = hname.substr(0, hname.length() - 5);
|
std::string tname = hname.substr(0, hname.length() - 5);
|
||||||
name = tname;
|
name = tname;
|
||||||
resetEngine();
|
resetEngine();
|
||||||
|
//HACK: we need to reset JointsService but there is no good way to do it in XplicitNgine code
|
||||||
|
jointsService = new JointsService();
|
||||||
|
jointsService->setParent(this);
|
||||||
selectionService->clearSelection();
|
selectionService->clearSelection();
|
||||||
selectionService->addSelected(this);
|
selectionService->addSelected(this);
|
||||||
|
jointsService->solveWorkspaceSnaps();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -672,6 +678,11 @@ SoundService* DataModelInstance::getSoundService()
|
|||||||
return soundService;
|
return soundService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JointsService* DataModelInstance::getJointsService()
|
||||||
|
{
|
||||||
|
return jointsService;
|
||||||
|
}
|
||||||
|
|
||||||
LightingInstance* DataModelInstance::getLighting()
|
LightingInstance* DataModelInstance::getLighting()
|
||||||
{
|
{
|
||||||
return lightingInstance;
|
return lightingInstance;
|
||||||
|
|||||||
@@ -80,13 +80,6 @@ std::vector<PROPGRIDITEM> Instance::getProperties()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<Property *> Instance::collectProperties()
|
|
||||||
{
|
|
||||||
std::vector<Property *> properties;
|
|
||||||
properties.push_back(new StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName));
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Instance::~Instance(void)
|
Instance::~Instance(void)
|
||||||
{
|
{
|
||||||
@@ -94,6 +87,7 @@ Instance::~Instance(void)
|
|||||||
{
|
{
|
||||||
delete children.at(i);
|
delete children.at(i);
|
||||||
}
|
}
|
||||||
|
setParent(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::setName(std::string newName)
|
void Instance::setName(std::string newName)
|
||||||
@@ -106,6 +100,13 @@ std::string Instance::getClassName()
|
|||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Instance::isA(std::string name)
|
||||||
|
{
|
||||||
|
if (className == name)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Instance* > Instance::getChildren()
|
std::vector<Instance* > Instance::getChildren()
|
||||||
{
|
{
|
||||||
return children;
|
return children;
|
||||||
@@ -181,5 +182,7 @@ Instance* Instance::findFirstChild(std::string name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::remove()
|
||||||
|
{
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
69
src/source/DataModelV2/JointsService.cpp
Normal file
69
src/source/DataModelV2/JointsService.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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->jPart1 == Part) || (Snap->jPart2 == Part))
|
||||||
|
{
|
||||||
|
Snap->remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JointsService::solvePartSnap(PartInstance* Part1, PartInstance* Part2)
|
||||||
|
{
|
||||||
|
XplicitNgine* Phys = g_dataModel->getEngine();
|
||||||
|
float TopSurface = (Part1->getPosition().y + Part1->getSize().y / 2);
|
||||||
|
float BottomSurface2 = (Part2->getPosition().y - Part2->getSize().y / 2);
|
||||||
|
const int N = 4;
|
||||||
|
if (TopSurface == BottomSurface2)
|
||||||
|
{
|
||||||
|
Phys->createBody(Part1);
|
||||||
|
Phys->createBody(Part2);
|
||||||
|
dContact contact[N];
|
||||||
|
int n = dCollide (Part1->physGeom[0],Part2->physGeom[0],N,&contact[0].geom,sizeof(dContact));
|
||||||
|
if (n > 0)
|
||||||
|
createSnap(Part1, Part2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JointsService::solveWorkspaceSnaps()
|
||||||
|
{
|
||||||
|
std::vector<Instance* > children = g_dataModel->getWorkspace()->getAllChildren();
|
||||||
|
for(size_t i = 0; i < children.size(); i++)
|
||||||
|
{
|
||||||
|
PartInstance* Part1 = (PartInstance*)children.at(i);
|
||||||
|
if (Part1->isA("Part"))
|
||||||
|
{
|
||||||
|
for(size_t c = 0; c < children.size(); c++) //horrible
|
||||||
|
{
|
||||||
|
PartInstance* Part2 = (PartInstance*)children.at(c);
|
||||||
|
if (Part1 != Part2)
|
||||||
|
solvePartSnap(Part1, Part2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -63,33 +63,6 @@ static Enum::Controller::Value strEnum(TCHAR * tval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<Property *> PVInstance::collectProperties()
|
|
||||||
{
|
|
||||||
std::vector<Property *> properties = Instance::collectProperties();
|
|
||||||
properties.push_back(new BoolProperty(
|
|
||||||
"NameShown",
|
|
||||||
"This chooses whether the item name is shown",
|
|
||||||
"Item",
|
|
||||||
nameShown,
|
|
||||||
this,
|
|
||||||
(BoolProperty::instanceSetter)&PVInstance::setNameShown));
|
|
||||||
properties.push_back(new BoolProperty(
|
|
||||||
"ControllerFlagShown",
|
|
||||||
"This chooses whether the item's ControllerFlag is shown",
|
|
||||||
"Item",
|
|
||||||
controllerFlagShown,
|
|
||||||
this,
|
|
||||||
(BoolProperty::instanceSetter)&PVInstance::setControllerFlagShown));
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PVInstance::setNameShown(bool nameShown){
|
|
||||||
this->nameShown = nameShown;
|
|
||||||
}
|
|
||||||
void PVInstance::setControllerFlagShown(bool controllerFlagShown){
|
|
||||||
this->controllerFlagShown = controllerFlagShown;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
||||||
{
|
{
|
||||||
@@ -117,15 +90,6 @@ std::vector<PROPGRIDITEM> PVInstance::getProperties()
|
|||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PVInstance::makeJoints()
|
|
||||||
{
|
|
||||||
for(size_t i = 0; i < children.size(); i++)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
{
|
{
|
||||||
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
|
if(strcmp(pItem->lpszPropName, "NameShown") == 0)
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -674,49 +675,6 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
else PVInstance::PropUpdate(item);
|
else PVInstance::PropUpdate(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartInstance::setColor(Color3 color)
|
|
||||||
{
|
|
||||||
this->color = color;
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<Property *> PartInstance::collectProperties()
|
|
||||||
{
|
|
||||||
std::vector<Property *> properties = PVInstance::collectProperties();
|
|
||||||
properties.push_back(new Color3Property(
|
|
||||||
"Color3",
|
|
||||||
"The color of the selected part",
|
|
||||||
"Properties",
|
|
||||||
color,
|
|
||||||
this,
|
|
||||||
(Color3Property::instanceSetter)&PartInstance::setColor));
|
|
||||||
|
|
||||||
properties.push_back(new BoolProperty(
|
|
||||||
"Anchored",
|
|
||||||
"Whether the block can move or not",
|
|
||||||
"Item",
|
|
||||||
anchored,
|
|
||||||
this,
|
|
||||||
(BoolProperty::instanceSetter)&PartInstance::setAnchored));
|
|
||||||
|
|
||||||
properties.push_back(new Vector3Property(
|
|
||||||
"Offset",
|
|
||||||
"The position of the object in the workspace",
|
|
||||||
"Item",
|
|
||||||
position,
|
|
||||||
this,
|
|
||||||
(Vector3Property::instanceSetter)&PartInstance::setPosition));
|
|
||||||
|
|
||||||
properties.push_back(new Vector3Property(
|
|
||||||
"Size",
|
|
||||||
"The size of the object in the workspace",
|
|
||||||
"Item",
|
|
||||||
size,
|
|
||||||
this,
|
|
||||||
(Vector3Property::instanceSetter)&PartInstance::setSize));
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This needs to be changed, buffer size of 12 is way too small
|
// This needs to be changed, buffer size of 12 is way too small
|
||||||
// Crash occurs if you put a huge number in
|
// Crash occurs if you put a huge number in
|
||||||
char changeTimerTxt[12];
|
char changeTimerTxt[12];
|
||||||
|
|||||||
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";
|
||||||
|
jPart1 = Part1;
|
||||||
|
jPart2 = Part2;
|
||||||
|
|
||||||
|
if (Part1->physBody == NULL)
|
||||||
|
Phys->createBody(Part1);
|
||||||
|
|
||||||
|
if (Part2->physBody == NULL)
|
||||||
|
Phys->createBody(Part2);
|
||||||
|
|
||||||
|
JointID = Phys->createJoint(Part1, Part2);
|
||||||
|
}
|
||||||
|
|
||||||
|
SnapInstance::~SnapInstance(void)
|
||||||
|
{
|
||||||
|
//XplicitNgine* Phys = g_xplicitNgine;
|
||||||
|
printf("SnapInstance destroyed...");
|
||||||
|
if (JointID != NULL)
|
||||||
|
dJointDestroy(JointID);
|
||||||
|
}
|
||||||
5
src/source/Properties/BoolProperty.cpp
Normal file
5
src/source/Properties/BoolProperty.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
//#include "Properties/BoolProperty.h"
|
||||||
|
//PROPGRIDITEM BoolProperty::getPropGridItem()
|
||||||
|
//{
|
||||||
|
//return PROPGRIDITEM();
|
||||||
|
//}
|
||||||
7
src/source/Properties/Property.cpp
Normal file
7
src/source/Properties/Property.cpp
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#include "Properties/Property.h"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Property<T>::setProperty(LPPROPGRIDITEM item)
|
||||||
|
{
|
||||||
|
_owner->propertiesChanged();
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "PropertiesV2/BoolProperty.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM BoolProperty::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.lpCurValue=_value > 0;
|
|
||||||
pItem.iItemType=PIT_CHECK;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BoolProperty::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
setValue(pItem->lpCurValue == TRUE);
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#include "PropertiesV2/Color3Property.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM Color3Property::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.lpCurValue=RGB((_value.r*255),(_value.g*255),(_value.b*255));
|
|
||||||
pItem.iItemType=PIT_COLOR;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Color3Property::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
|
|
||||||
setValue(Color3(
|
|
||||||
GetRValue(pItem->lpCurValue)/255.0F,
|
|
||||||
GetGValue(pItem->lpCurValue)/255.0F,
|
|
||||||
GetBValue(pItem->lpCurValue)/255.0F
|
|
||||||
));
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "PropertiesV2/Property.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM Property::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Property::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "PropertiesV2/StringProperty.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM StringProperty::getPropGridItem(){
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.lpCurValue=(LPARAM)_value.c_str();
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StringProperty::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
setValue((LPSTR)pItem->lpCurValue);
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#include "PropertiesV2/Vector3Property.h"
|
|
||||||
|
|
||||||
PROPGRIDITEM Vector3Property::getPropGridItem(){
|
|
||||||
std::stringstream s;
|
|
||||||
s << _value.x << ", " << _value.y << ", " << _value.z;
|
|
||||||
stringRep = s.str();
|
|
||||||
PROPGRIDITEM pItem;
|
|
||||||
PropGrid_ItemInit(pItem);
|
|
||||||
pItem.lpszCatalog=_catalog;
|
|
||||||
pItem.lpszPropName=_name;
|
|
||||||
pItem.lpszPropDesc=_desc;
|
|
||||||
pItem.lpCurValue=(LPARAM)stringRep.c_str();
|
|
||||||
pItem.iItemType=PIT_EDIT;
|
|
||||||
return pItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vector3Property::setProperty(LPPROPGRIDITEM &pItem){
|
|
||||||
|
|
||||||
std::string str = (LPTSTR)pItem->lpCurValue;
|
|
||||||
std::vector<float> vect;
|
|
||||||
std::stringstream ss(str);
|
|
||||||
float i;
|
|
||||||
while (ss >> i)
|
|
||||||
{
|
|
||||||
vect.push_back(i);
|
|
||||||
if (ss.peek() == ',')
|
|
||||||
ss.ignore();
|
|
||||||
}
|
|
||||||
if(vect.size() == 3)
|
|
||||||
{
|
|
||||||
setValue(Vector3(vect.at(0),vect.at(1),vect.at(2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "strsafe.h"
|
#include "strsafe.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
std::vector<Property*> prop;
|
std::vector<PROPGRIDITEM> prop;
|
||||||
std::vector<Instance*> children;
|
std::vector<Instance*> children;
|
||||||
Instance * selectedInstance;
|
Instance * selectedInstance;
|
||||||
Instance * parent = NULL;
|
Instance * parent = NULL;
|
||||||
@@ -186,15 +186,8 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
LPNMHDR pnm = (LPNMHDR)lParam;
|
LPNMHDR pnm = (LPNMHDR)lParam;
|
||||||
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm;
|
||||||
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex);
|
||||||
for(size_t i = 0; i < prop.size(); i++)
|
selectedInstance->PropUpdate(item);
|
||||||
{
|
//propWind->UpdateSelected(selectedInstance);
|
||||||
if(strcmp(item->lpszPropName, prop[i]->getName()) == 0)
|
|
||||||
{
|
|
||||||
prop[i]->setProperty(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//selectedInstance->PropUpdate(item);
|
|
||||||
propWind->UpdateSelected(g_dataModel->getSelectionService()->getSelection());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -349,7 +342,6 @@ void PropertyWindow::_resize()
|
|||||||
|
|
||||||
void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
||||||
{
|
{
|
||||||
deleteProperties();
|
|
||||||
if(instances.size() <= 0)
|
if(instances.size() <= 0)
|
||||||
{
|
{
|
||||||
ClearProperties();
|
ClearProperties();
|
||||||
@@ -357,13 +349,13 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
|||||||
}
|
}
|
||||||
Instance * instance = instances[0];
|
Instance * instance = instances[0];
|
||||||
PropGrid_ResetContent(_propGrid);
|
PropGrid_ResetContent(_propGrid);
|
||||||
prop = instance->collectProperties();
|
prop = instance->getProperties();
|
||||||
//if (selectedInstance != instance)
|
//if (selectedInstance != instance)
|
||||||
{
|
{
|
||||||
selectedInstance = instance;
|
selectedInstance = instance;
|
||||||
for(size_t i = 0; i < prop.size(); i++)
|
for(size_t i = 0; i < prop.size(); i++)
|
||||||
{
|
{
|
||||||
::PROPGRIDITEM item = prop.at(i)->getPropGridItem();
|
::PROPGRIDITEM item = prop.at(i);
|
||||||
PropGrid_AddItem(_propGrid, &item);
|
PropGrid_AddItem(_propGrid, &item);
|
||||||
//PRGP propgp;
|
//PRGP propgp;
|
||||||
//propgp.instance = instance;
|
//propgp.instance = instance;
|
||||||
@@ -379,16 +371,6 @@ void PropertyWindow::UpdateSelected(std::vector<Instance *> instances)
|
|||||||
|
|
||||||
void PropertyWindow::ClearProperties()
|
void PropertyWindow::ClearProperties()
|
||||||
{
|
{
|
||||||
deleteProperties();
|
|
||||||
clearExplorer();
|
clearExplorer();
|
||||||
PropGrid_ResetContent(_propGrid);
|
PropGrid_ResetContent(_propGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyWindow::deleteProperties()
|
|
||||||
{
|
|
||||||
while(prop.size() > 0) {
|
|
||||||
Property * toDelete = prop.back();
|
|
||||||
prop.pop_back();
|
|
||||||
delete toDelete;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
|
#include "DataModelV2/JointsService.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
|
||||||
XplicitNgine::XplicitNgine()
|
XplicitNgine::XplicitNgine()
|
||||||
{
|
{
|
||||||
|
|
||||||
physWorld = dWorldCreate();
|
physWorld = dWorldCreate();
|
||||||
physSpace = dHashSpaceCreate(0);
|
physSpace = dHashSpaceCreate(0);
|
||||||
contactgroup = dJointGroupCreate(0);
|
contactgroup = dJointGroupCreate(0);
|
||||||
@@ -19,6 +19,7 @@ XplicitNgine::XplicitNgine()
|
|||||||
|
|
||||||
XplicitNgine::~XplicitNgine()
|
XplicitNgine::~XplicitNgine()
|
||||||
{
|
{
|
||||||
|
g_dataModel->getJointsService()->remove();
|
||||||
dJointGroupDestroy (contactgroup);
|
dJointGroupDestroy (contactgroup);
|
||||||
dSpaceDestroy (physSpace);
|
dSpaceDestroy (physSpace);
|
||||||
dWorldDestroy (physWorld);
|
dWorldDestroy (physWorld);
|
||||||
@@ -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);
|
||||||
@@ -156,7 +158,8 @@ void XplicitNgine::createBody(PartInstance* partInstance)
|
|||||||
dGeomSetData(partInstance->physGeom[0], partInstance);
|
dGeomSetData(partInstance->physGeom[0], partInstance);
|
||||||
|
|
||||||
dMass mass;
|
dMass mass;
|
||||||
mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
|
mass.setBox(sqrt(partSize.x*20), sqrt(partSize.y*20), sqrt(partSize.z*20), 0.01F);
|
||||||
|
//mass.setBox(sqrt(partSize.x*2), sqrt(partSize.y*2), sqrt(partSize.z*2), 0.7F);
|
||||||
dBodySetMass(partInstance->physBody, &mass);
|
dBodySetMass(partInstance->physBody, &mass);
|
||||||
|
|
||||||
// Create rigid body
|
// Create rigid body
|
||||||
@@ -234,3 +237,23 @@ void XplicitNgine::updateBody(PartInstance *partInstance)
|
|||||||
dBodySetRotation(partInstance->physBody, rotation);
|
dBodySetRotation(partInstance->physBody, rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dJointID 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);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void XplicitNgine::destroyJoints(PartInstance *part)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < dBodyGetNumJoints(part->physBody); i++)
|
||||||
|
dJointDestroy(dBodyGetJoint(part->physBody, i));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user