Implemented SelectionService
This commit is contained in:
@@ -303,24 +303,12 @@
|
|||||||
<Filter
|
<Filter
|
||||||
Name="DataModelV2"
|
Name="DataModelV2"
|
||||||
Filter="">
|
Filter="">
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\BaseButtonInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\BaseGuiInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\DataModelInstance.h">
|
RelativePath=".\src\include\DataModelV2\DataModelInstance.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\GroupInstance.h">
|
RelativePath=".\src\include\DataModelV2\GroupInstance.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\GuiRootInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\ImageButtonInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\Instance.h">
|
RelativePath=".\src\include\DataModelV2\Instance.h">
|
||||||
</File>
|
</File>
|
||||||
@@ -345,21 +333,37 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\SoundService.h">
|
RelativePath=".\src\include\DataModelV2\SoundService.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\TextButtonInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\ThumbnailGeneratorInstance.h">
|
RelativePath=".\src\include\DataModelV2\ThumbnailGeneratorInstance.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\src\include\DataModelV2\ToggleImageButtonInstance.h">
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\WorkspaceInstance.h">
|
RelativePath=".\src\include\DataModelV2\WorkspaceInstance.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\XplicitNgine\XplicitNgine.h">
|
RelativePath=".\src\include\XplicitNgine\XplicitNgine.h">
|
||||||
</File>
|
</File>
|
||||||
|
<Filter
|
||||||
|
Name="Gui"
|
||||||
|
Filter="">
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\BaseButtonInstance.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\BaseGuiInstance.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\GuiRootInstance.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\ImageButtonInstance.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\TextButtonInstance.h">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\ToggleImageButtonInstance.h">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Helpers">
|
Name="Helpers">
|
||||||
@@ -401,12 +405,18 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV3\LevelInstance.h">
|
RelativePath=".\src\include\DataModelV3\LevelInstance.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV3\LightingInstance.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV3\PartInstance.h">
|
RelativePath=".\src\include\DataModelV3\PartInstance.h">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV3\PVInstance.h">
|
RelativePath=".\src\include\DataModelV3\PVInstance.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV3\SelectionService.h">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV3\WorkspaceInstance.h">
|
RelativePath=".\src\include\DataModelV3\WorkspaceInstance.h">
|
||||||
</File>
|
</File>
|
||||||
@@ -684,12 +694,42 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV3\LevelInstance.cpp">
|
RelativePath=".\src\source\DataModelV3\LevelInstance.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV3\LightingInstance.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV3\PartInstance.cpp">
|
RelativePath=".\src\source\DataModelV3\PartInstance.cpp">
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV3\PVInstance.cpp">
|
RelativePath=".\src\source\DataModelV3\PVInstance.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV3\SelectionService.cpp">
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Release|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
<FileConfiguration
|
||||||
|
Name="Debug|Win32">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
|
||||||
|
</FileConfiguration>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV3\WorkspaceInstance.cpp">
|
RelativePath=".\src\source\DataModelV3\WorkspaceInstance.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
21631
Physics Test/phys-test-tower-stable-small.rbxl
Normal file
21631
Physics Test/phys-test-tower-stable-small.rbxl
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,15 +4,15 @@ using namespace B3D;
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// Instances
|
// Instances
|
||||||
//#include "WorkspaceInstance.h"
|
#include "WorkspaceInstance.h"
|
||||||
#include "LevelInstance.h"
|
#include "LevelInstance.h"
|
||||||
#include "PartInstance.h"
|
#include "PartInstance.h"
|
||||||
//#include "SelectionService.h"
|
#include "SelectionService.h"
|
||||||
//#include "GuiRootInstance.h"
|
//#include "GuiRootInstance.h"
|
||||||
//#include "ThumbnailGeneratorInstance.h"
|
//#include "ThumbnailGeneratorInstance.h"
|
||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
//#include "SoundService.h"
|
//#include "SoundService.h"
|
||||||
//#include "LightingInstance.h"
|
#include "LightingInstance.h"
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
//#include "rapidxml/rapidxml.hpp"
|
//#include "rapidxml/rapidxml.hpp"
|
||||||
@@ -28,36 +28,35 @@ namespace B3D {
|
|||||||
void drawMessage(RenderDevice*);
|
void drawMessage(RenderDevice*);
|
||||||
|
|
||||||
// Instance getters
|
// Instance getters
|
||||||
// WorkspaceInstance* getWorkspace();
|
WorkspaceInstance* getWorkspace();
|
||||||
LevelInstance* getLevel();
|
LevelInstance* getLevel();
|
||||||
XplicitNgine* getEngine();
|
XplicitNgine* getEngine();
|
||||||
// ThumbnailGeneratorInstance* getThumbnailGenerator();
|
// ThumbnailGeneratorInstance* getThumbnailGenerator();
|
||||||
// SoundService* getSoundService();
|
// SoundService* getSoundService();
|
||||||
// LightingInstance* getLighting();
|
LightingInstance* getLighting();
|
||||||
|
|
||||||
std::string message;
|
std::string message;
|
||||||
bool showMessage;
|
bool showMessage;
|
||||||
//Should probably not be here???
|
//Should probably not be here???
|
||||||
G3D::GFontRef font;
|
G3D::GFontRef font;
|
||||||
// GuiRootInstance* getGuiRoot();
|
// GuiRootInstance* getGuiRoot();
|
||||||
// SelectionService* getSelectionService();
|
SelectionService* getSelectionService();
|
||||||
// PartInstance* makePart();
|
|
||||||
void clearLevel();
|
void clearLevel();
|
||||||
void toggleRun();
|
void toggleRun();
|
||||||
bool isRunning();
|
bool isRunning();
|
||||||
// void resetEngine();
|
void resetEngine();
|
||||||
private:
|
private:
|
||||||
bool isBrickCount;
|
bool isBrickCount;
|
||||||
Color3 DataModelInstance::bcToRGB(short bc);
|
Color3 DataModelInstance::bcToRGB(short bc);
|
||||||
// Instances
|
// Instances
|
||||||
// WorkspaceInstance* workspace;
|
WorkspaceInstance* workspace;
|
||||||
LevelInstance* level;
|
LevelInstance* level;
|
||||||
// GuiRootInstance* guiRoot;
|
// GuiRootInstance* guiRoot;
|
||||||
// SelectionService* selectionService;
|
SelectionService* selectionService;
|
||||||
// ThumbnailGeneratorInstance* thumbnailGenerator;
|
// ThumbnailGeneratorInstance* thumbnailGenerator;
|
||||||
XplicitNgine* xplicitNgine;
|
XplicitNgine* xplicitNgine;
|
||||||
// SoundService* soundService;
|
// SoundService* soundService;
|
||||||
// LightingInstance* lightingInstance;
|
LightingInstance* lightingInstance;
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
41
src/include/DataModelV3/LightingInstance.h
Normal file
41
src/include/DataModelV3/LightingInstance.h
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
|
||||||
|
namespace B3D
|
||||||
|
{
|
||||||
|
class LightingInstance : public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LightingInstance(void);
|
||||||
|
~LightingInstance(void);
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
G3D::Color3 getTopAmbient();
|
||||||
|
G3D::Color3 getBottomAmbient();
|
||||||
|
G3D::Color3 getSpotLight();
|
||||||
|
G3D::Color4 getClearColor();
|
||||||
|
G3D::SkyRef getSky();
|
||||||
|
G3D::LightingParameters getLightingParameters();
|
||||||
|
|
||||||
|
// Setters
|
||||||
|
void setTopAmbient(G3D::Color3 newValue);
|
||||||
|
void setBottomAmbient(G3D::Color3 newValue);
|
||||||
|
void setSpotLight(G3D::Color3 newValue);
|
||||||
|
void setClearColor(G3D::Color3 clearColor);
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
void drawSky(RenderDevice* rd);
|
||||||
|
void suppressSky(bool doSuppress);
|
||||||
|
void update(RenderDevice* rd);
|
||||||
|
void drawEffects(RenderDevice* rd);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Reflection::ReflectionProperty<G3D::Color3> topAmbient;
|
||||||
|
Reflection::ReflectionProperty<G3D::Color3> bottomAmbient;
|
||||||
|
Reflection::ReflectionProperty<G3D::Color3> spotLight;
|
||||||
|
Reflection::ReflectionProperty<G3D::Color4> clearColor;
|
||||||
|
G3D::SkyRef sky;
|
||||||
|
G3D::LightingParameters lighting;
|
||||||
|
bool _hideSky;
|
||||||
|
};
|
||||||
|
}
|
||||||
30
src/include/DataModelV3/SelectionService.h
Normal file
30
src/include/DataModelV3/SelectionService.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
//#include "PropertyWindow.h"
|
||||||
|
|
||||||
|
namespace B3D{
|
||||||
|
class SelectionService : public Instance
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SelectionService(void);
|
||||||
|
~SelectionService(void);
|
||||||
|
SelectionService(const SelectionService &oinst);
|
||||||
|
std::vector<Instance *> getSelection();
|
||||||
|
void clearSelection();
|
||||||
|
bool isSelected(Instance * instance);
|
||||||
|
void addSelected(Instance * instance);
|
||||||
|
void removeSelected(Instance * instance);
|
||||||
|
void addSelected(const std::vector<Instance *> &instances);
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
//void setPropertyWindow(PropertyWindow * propertyWindow);
|
||||||
|
void render(RenderDevice * rd);
|
||||||
|
private:
|
||||||
|
void drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c);
|
||||||
|
|
||||||
|
std::vector<Instance *> selection;
|
||||||
|
int mode;
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
//PropertyWindow * propertyWindow;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -17,14 +17,16 @@ namespace B3D{
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum ReflectionType {
|
enum ReflectionType {
|
||||||
TYPE_INT = 0,
|
TYPE_INT,
|
||||||
TYPE_FLOAT = 1,
|
TYPE_FLOAT,
|
||||||
TYPE_STRING = 2,
|
TYPE_STRING,
|
||||||
TYPE_VECTOR3 = 3,
|
TYPE_VECTOR3,
|
||||||
TYPE_COLOR3 = 4,
|
TYPE_COLOR3,
|
||||||
TYPE_CFRAME = 5,
|
TYPE_COLOR4,
|
||||||
TYPE_BOOLEAN = 6,
|
TYPE_CFRAME,
|
||||||
TYPE_ENUM = 7
|
TYPE_BOOLEAN,
|
||||||
|
TYPE_ENUM,
|
||||||
|
LENGTH
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,44 +8,45 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
name = "Level";
|
name = "Level";
|
||||||
|
|
||||||
parentDataModel = this;
|
parentDataModel = this;
|
||||||
//workspace = new WorkspaceInstance();
|
workspace = new WorkspaceInstance();
|
||||||
//guiRoot = new GuiRootInstance();
|
//guiRoot = new GuiRootInstance();
|
||||||
level = new LevelInstance();
|
level = new LevelInstance();
|
||||||
//thumbnailGenerator = new ThumbnailGeneratorInstance();
|
//thumbnailGenerator = new ThumbnailGeneratorInstance();
|
||||||
//soundService = new SoundService();
|
//soundService = new SoundService();
|
||||||
//lightingInstance = new LightingInstance();
|
lightingInstance = new LightingInstance();
|
||||||
|
|
||||||
//selectionService = new SelectionService();
|
selectionService = new SelectionService();
|
||||||
|
|
||||||
|
//TODO change how property window is either passed or accessed
|
||||||
//selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
//selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
||||||
showMessage = false;
|
showMessage = false;
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
|
|
||||||
// Parent stuff
|
// Parent stuff
|
||||||
//workspace->setParent(this);
|
workspace->setParent(this);
|
||||||
level->setParent(this);
|
level->setParent(this);
|
||||||
//soundService->setParent(this);
|
//soundService->setParent(this);
|
||||||
//lightingInstance->setParent(this);
|
lightingInstance->setParent(this);
|
||||||
|
|
||||||
running = false;
|
running = false;
|
||||||
//xplicitNgine = NULL;
|
xplicitNgine = NULL;
|
||||||
//resetEngine();
|
resetEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
/*
|
|
||||||
void DataModelInstance::resetEngine()
|
void DataModelInstance::resetEngine()
|
||||||
{
|
{
|
||||||
if(xplicitNgine != NULL)
|
if(xplicitNgine != NULL)
|
||||||
delete xplicitNgine;
|
delete xplicitNgine;
|
||||||
xplicitNgine = new XplicitNgine();
|
xplicitNgine = new XplicitNgine();
|
||||||
g_xplicitNgine = xplicitNgine;
|
|
||||||
for(size_t i = 0; i < getWorkspace()->partObjects.size(); i++)
|
for(size_t i = 0; i < getWorkspace()->partObjects.size(); i++)
|
||||||
{
|
{
|
||||||
PartInstance* partInstance = getWorkspace()->partObjects[i];
|
PartInstance* partInstance = getWorkspace()->partObjects[i];
|
||||||
partInstance->physBody = NULL;
|
partInstance->physBody = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
XplicitNgine * DataModelInstance::getEngine()
|
XplicitNgine * DataModelInstance::getEngine()
|
||||||
{
|
{
|
||||||
@@ -57,8 +58,8 @@ void DataModelInstance::toggleRun()
|
|||||||
running = !running;
|
running = !running;
|
||||||
|
|
||||||
//TODO implement (in RunService!!!)
|
//TODO implement (in RunService!!!)
|
||||||
//if(!running)
|
if(!running)
|
||||||
//resetEngine();
|
resetEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataModelInstance::isRunning()
|
bool DataModelInstance::isRunning()
|
||||||
@@ -68,8 +69,8 @@ bool DataModelInstance::isRunning()
|
|||||||
|
|
||||||
DataModelInstance::~DataModelInstance(void)
|
DataModelInstance::~DataModelInstance(void)
|
||||||
{
|
{
|
||||||
//TODO implement
|
//TODO implement in run service
|
||||||
//delete xplicitNgine;
|
delete xplicitNgine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataModelInstance::clearLevel()
|
void DataModelInstance::clearLevel()
|
||||||
@@ -88,6 +89,7 @@ void DataModelInstance::clearLevel()
|
|||||||
workspace->clearChildren();*/
|
workspace->clearChildren();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO move elsewhere
|
||||||
Color3 DataModelInstance::bcToRGB(short bc)
|
Color3 DataModelInstance::bcToRGB(short bc)
|
||||||
{
|
{
|
||||||
switch(bc)
|
switch(bc)
|
||||||
@@ -261,8 +263,7 @@ void DataModelInstance::setMessageBrickCount()
|
|||||||
|
|
||||||
void DataModelInstance::drawMessage(RenderDevice* rd)
|
void DataModelInstance::drawMessage(RenderDevice* rd)
|
||||||
{
|
{
|
||||||
//TODO implement
|
if(isBrickCount)
|
||||||
/*if(isBrickCount)
|
|
||||||
{
|
{
|
||||||
int brickCount = 0;
|
int brickCount = 0;
|
||||||
int instCount = 0;
|
int instCount = 0;
|
||||||
@@ -295,14 +296,13 @@ void DataModelInstance::drawMessage(RenderDevice* rd)
|
|||||||
int height = width / 3;
|
int height = width / 3;
|
||||||
Draw::box(Box(Vector3(x-(width/2), y-(height/2), 0), Vector3(x+(width/2), y+(height/2), 0)), rd, Color4::fromARGB(0x55B2B2B2), Color3::fromARGB(0xB2B2B2));
|
Draw::box(Box(Vector3(x-(width/2), y-(height/2), 0), Vector3(x+(width/2), y+(height/2), 0)), rd, Color4::fromARGB(0x55B2B2B2), Color3::fromARGB(0xB2B2B2));
|
||||||
font->draw2D(rd, message, Vector2(x,y), height/8, Color3::white(), Color4::clear(), GFont::XALIGN_CENTER, GFont::YALIGN_CENTER);
|
font->draw2D(rd, message, Vector2(x,y), height/8, Color3::white(), Color4::clear(), GFont::XALIGN_CENTER, GFont::YALIGN_CENTER);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement
|
WorkspaceInstance* DataModelInstance::getWorkspace()
|
||||||
/*WorkspaceInstance* DataModelInstance::getWorkspace()
|
|
||||||
{
|
{
|
||||||
return workspace;
|
return workspace;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
/*GuiRootInstance* DataModelInstance::getGuiRoot()
|
/*GuiRootInstance* DataModelInstance::getGuiRoot()
|
||||||
@@ -310,11 +310,10 @@ void DataModelInstance::drawMessage(RenderDevice* rd)
|
|||||||
return guiRoot;
|
return guiRoot;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
//TODO implement
|
SelectionService* DataModelInstance::getSelectionService()
|
||||||
/*SelectionService* DataModelInstance::getSelectionService()
|
|
||||||
{
|
{
|
||||||
return selectionService;
|
return selectionService;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
LevelInstance* DataModelInstance::getLevel()
|
LevelInstance* DataModelInstance::getLevel()
|
||||||
{
|
{
|
||||||
@@ -334,7 +333,7 @@ LevelInstance* DataModelInstance::getLevel()
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
//TODO implement
|
//TODO implement
|
||||||
/*LightingInstance* DataModelInstance::getLighting()
|
LightingInstance* DataModelInstance::getLighting()
|
||||||
{
|
{
|
||||||
return lightingInstance;
|
return lightingInstance;
|
||||||
}*/
|
}
|
||||||
106
src/source/DataModelV3/LightingInstance.cpp
Normal file
106
src/source/DataModelV3/LightingInstance.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
#include "DataModelV3/LightingInstance.h"
|
||||||
|
#include "DataModelV3/DataModelInstance.h"
|
||||||
|
|
||||||
|
#include "StringFunctions.h"
|
||||||
|
//#include "Listener/ModeSelectionListener.h"
|
||||||
|
|
||||||
|
using namespace B3D;
|
||||||
|
|
||||||
|
LightingInstance::LightingInstance(void)
|
||||||
|
{
|
||||||
|
Instance::Instance("Lighting");
|
||||||
|
name = "Lighting";
|
||||||
|
canDelete = false;
|
||||||
|
_hideSky = false;
|
||||||
|
|
||||||
|
|
||||||
|
topAmbient = Reflection::ReflectionProperty<Color3>("TopAmbient", Color3(0.5F, 0.5F, 0.5F), TYPE_COLOR3, this->dataTable);
|
||||||
|
bottomAmbient = Reflection::ReflectionProperty<Color3>("BottomAmbient", Color3(0.8F, 0.8F, 0.8F), TYPE_COLOR3, this->dataTable);
|
||||||
|
spotLight = Reflection::ReflectionProperty<Color3>("SpotLight", Color3(0.5F, 0.5F, 0.5F), TYPE_COLOR3, this->dataTable);
|
||||||
|
clearColor = Reflection::ReflectionProperty<Color4>("ClearColor", Color4(0.0F, 0.0F, 0.0F, 0.0F), TYPE_COLOR4, this->dataTable);
|
||||||
|
|
||||||
|
|
||||||
|
lighting.setTime(G3D::toSeconds(2, 00, 00, PM));
|
||||||
|
|
||||||
|
// Maybe this is Top and Bottom Ambient?
|
||||||
|
lighting.ambient = topAmbient.getValue();
|
||||||
|
lighting.lightColor = bottomAmbient.getValue();
|
||||||
|
|
||||||
|
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
||||||
|
}
|
||||||
|
|
||||||
|
LightingInstance::~LightingInstance(void)
|
||||||
|
{
|
||||||
|
sky->~Sky();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
G3D::SkyRef LightingInstance::getSky()
|
||||||
|
{
|
||||||
|
return sky;
|
||||||
|
}
|
||||||
|
|
||||||
|
G3D::LightingParameters LightingInstance::getLightingParameters()
|
||||||
|
{
|
||||||
|
return lighting;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
void LightingInstance::suppressSky(bool doSuppress)
|
||||||
|
{
|
||||||
|
_hideSky = doSuppress;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightingInstance::update(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if(!_hideSky) {
|
||||||
|
rd->clear(sky.isNull(), true, true);
|
||||||
|
if (sky.notNull()) sky->render(rd, lighting);
|
||||||
|
} else {
|
||||||
|
rd->setColorClearValue(clearColor.getValue());
|
||||||
|
rd->clear(true, true, true);
|
||||||
|
suppressSky(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup lighting
|
||||||
|
rd->enableLighting();
|
||||||
|
|
||||||
|
rd->setShadeMode(RenderDevice::SHADE_SMOOTH);
|
||||||
|
rd->setAmbientLightColor(Color3(1,1,1));
|
||||||
|
|
||||||
|
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
|
||||||
|
rd->setAmbientLightColor(lighting.ambient);
|
||||||
|
|
||||||
|
rd->beforePrimitive();
|
||||||
|
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
glEnableClientState(GL_NORMAL_ARRAY);
|
||||||
|
parentDataModel->getWorkspace()->render(rd);
|
||||||
|
parentDataModel->getWorkspace()->renderName(rd);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
rd->setObjectToWorldMatrix(forDraw);
|
||||||
|
rd->afterPrimitive();
|
||||||
|
|
||||||
|
// TODO implement
|
||||||
|
//parentDataModel->getSelectionService()->render(rd);
|
||||||
|
|
||||||
|
// TODO Mouse and tool will be handled by datamodel
|
||||||
|
//g_usableApp->tool->render(rd, g_usableApp->mouse);
|
||||||
|
|
||||||
|
|
||||||
|
rd->disableLighting();
|
||||||
|
|
||||||
|
drawEffects(rd);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightingInstance::drawEffects(RenderDevice* rd)
|
||||||
|
{
|
||||||
|
if (sky.notNull()) {
|
||||||
|
sky->renderLensFlare(rd, lighting);
|
||||||
|
}
|
||||||
|
}
|
||||||
163
src/source/DataModelV3/SelectionService.cpp
Normal file
163
src/source/DataModelV3/SelectionService.cpp
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#include "DataModelV3/SelectionService.h"
|
||||||
|
#include "DataModelV3/PartInstance.h"
|
||||||
|
|
||||||
|
//This is absolutely disgusting, and will not last long
|
||||||
|
//#include "Application.h"
|
||||||
|
//#include "Globals.h"
|
||||||
|
#define CURSOR 0
|
||||||
|
#define ARROWS 1
|
||||||
|
#define RESIZE 2
|
||||||
|
|
||||||
|
using namespace B3D;
|
||||||
|
|
||||||
|
SelectionService::SelectionService(void){
|
||||||
|
Instance::Instance();
|
||||||
|
mode = CURSOR;
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
//propertyWindow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectionService::~SelectionService(void){
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectionService::SelectionService(const SelectionService &oinst){
|
||||||
|
Instance::Instance(oinst);
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
//propertyWindow = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::vector<Instance *> SelectionService::getSelection(){
|
||||||
|
return this->selection;
|
||||||
|
}
|
||||||
|
void SelectionService::clearSelection(){
|
||||||
|
this->selection.clear();
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
/*if(propertyWindow != NULL)
|
||||||
|
propertyWindow->ClearProperties();*/
|
||||||
|
}
|
||||||
|
bool SelectionService::isSelected(Instance * instance){
|
||||||
|
return std::find(selection.begin(), selection.end(), instance) != selection.end();
|
||||||
|
}
|
||||||
|
void SelectionService::addSelected(Instance * instance){
|
||||||
|
if(!isSelected(instance))
|
||||||
|
this->selection.push_back(instance);
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
/*if(propertyWindow != NULL)
|
||||||
|
propertyWindow->UpdateSelected(selection);*/
|
||||||
|
}
|
||||||
|
void SelectionService::removeSelected(Instance * instance){
|
||||||
|
selection.erase(std::remove(selection.begin(), selection.end(), instance), selection.end());
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
/*if(propertyWindow != NULL)
|
||||||
|
propertyWindow->UpdateSelected(selection);*/
|
||||||
|
}
|
||||||
|
void SelectionService::addSelected(const std::vector<Instance *> &instances){
|
||||||
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
|
{
|
||||||
|
if(!isSelected(instances[i]))
|
||||||
|
this->selection.push_back(instances[i]);
|
||||||
|
}
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
/*if(propertyWindow != NULL)
|
||||||
|
propertyWindow->UpdateSelected(selection);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Port PropertyWindow
|
||||||
|
/*void SelectionService::setPropertyWindow(PropertyWindow * propertyWindow)
|
||||||
|
{
|
||||||
|
this->propertyWindow = propertyWindow;
|
||||||
|
if(propertyWindow != NULL)
|
||||||
|
propertyWindow->ClearProperties();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
void SelectionService::render(RenderDevice * rd)
|
||||||
|
{
|
||||||
|
for(size_t i = 0; i < selection.size(); i++)
|
||||||
|
{
|
||||||
|
if(PartInstance* part = dynamic_cast<PartInstance*>(selection[i]))
|
||||||
|
{
|
||||||
|
Vector3 size = part->getSize();
|
||||||
|
Vector3 pos = part->getPosition();
|
||||||
|
drawOutline(Vector3(0+size.x/2, 0+size.y/2, 0+size.z/2) ,Vector3(0-size.x/2,0-size.y/2,0-size.z/2), rd, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SelectionService::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c)
|
||||||
|
{
|
||||||
|
Color3 outline = Color3::cyan();//Color3(0.098F,0.6F,1.0F);
|
||||||
|
float offsetSize = 0.1F;
|
||||||
|
//X
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, from.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, to.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, to.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x - offsetSize, from.y + offsetSize, to.z + offsetSize), Vector3(to.x + offsetSize, from.y - offsetSize, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
//Y
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.2, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize-0.1, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y - offsetSize + 0.2, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.2, to.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
|
||||||
|
//Z
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(from.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(from.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, from.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, to.y + offsetSize, from.z - offsetSize), Vector3(to.x - offsetSize, to.y - offsetSize, to.z + offsetSize))), rd, outline, Color4::clear());
|
||||||
|
|
||||||
|
if(mode == ARROWS)
|
||||||
|
{
|
||||||
|
|
||||||
|
AABox box;
|
||||||
|
c.toWorldSpace(Box(from, to)).getBounds(box);
|
||||||
|
float max = box.high().y - pos.y;
|
||||||
|
|
||||||
|
Draw::arrow(pos, Vector3(0, 1.5+max, 0), rd);
|
||||||
|
Draw::arrow(pos, Vector3(0, (-1.5)-max, 0), rd);
|
||||||
|
|
||||||
|
max = box.high().x - pos.x;
|
||||||
|
|
||||||
|
Draw::arrow(pos, Vector3(1.5+max, 0, 0), rd);
|
||||||
|
Draw::arrow(pos, Vector3((-1.5)-max, 0, 0), rd);
|
||||||
|
|
||||||
|
max = box.high().z - pos.z;
|
||||||
|
|
||||||
|
Draw::arrow(pos, Vector3(0, 0, 1.5+max), rd);
|
||||||
|
Draw::arrow(pos, Vector3(0, 0, (-1.5)-max), rd);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(mode == RESIZE)
|
||||||
|
{
|
||||||
|
Color3 sphereColor = outline;
|
||||||
|
Vector3 gamepoint = pos;
|
||||||
|
Vector3 camerapoint = rd->getCameraToWorldMatrix().translation;
|
||||||
|
float distance = pow(pow((double)gamepoint.x - (double)camerapoint.x, 2) + pow((double)gamepoint.y - (double)camerapoint.y, 2) + pow((double)gamepoint.z - (double)camerapoint.z, 2), 0.5);
|
||||||
|
if(distance < 200)
|
||||||
|
{
|
||||||
|
|
||||||
|
float multiplier = distance * 0.050F/2;
|
||||||
|
if(multiplier < 0.50F)
|
||||||
|
multiplier = 0.50F;
|
||||||
|
Vector3 position = pos + (c.lookVector()*((size.z)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.lookVector()*((size.z)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
|
position = pos + (c.rightVector()*((size.x)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.rightVector()*((size.x)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
|
position = pos + (c.upVector()*((size.y)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.upVector()*((size.y)+2));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user