Add LightingInstance
Still need to work on PropertyGrid for it
This commit is contained in:
@@ -457,6 +457,10 @@
|
|||||||
/>
|
/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\source\DataModelV2\LightingInstance.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\source\DataModelV2\PartInstance.cpp"
|
RelativePath=".\src\source\DataModelV2\PartInstance.cpp"
|
||||||
>
|
>
|
||||||
@@ -874,6 +878,10 @@
|
|||||||
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
|
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\include\DataModelV2\LightingInstance.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\include\DataModelV2\PartInstance.h"
|
RelativePath=".\src\include\DataModelV2\PartInstance.h"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ std::string ThumbnailGeneratorInstance::click(std::string fileType, int cx, int
|
|||||||
g_usableApp->resize3DView(cx, cy);
|
g_usableApp->resize3DView(cx, cy);
|
||||||
|
|
||||||
if(hideSky)
|
if(hideSky)
|
||||||
g_usableApp->toggleSky();
|
g_dataModel->getLighting()->suppressSky(true);
|
||||||
|
|
||||||
g_usableApp->onGraphics(rd);
|
g_usableApp->onGraphics(rd);
|
||||||
rd->screenshotPic(imgBuffer, true, hideSky);
|
rd->screenshotPic(imgBuffer, true, hideSky);
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ class Application { // : public GApp {
|
|||||||
int getMode();
|
int getMode();
|
||||||
void unSetMode();
|
void unSetMode();
|
||||||
|
|
||||||
void toggleSky();
|
|
||||||
CameraController cameraController;
|
CameraController cameraController;
|
||||||
UserInput* userInput;
|
UserInput* userInput;
|
||||||
PropertyWindow* _propWindow;
|
PropertyWindow* _propWindow;
|
||||||
@@ -56,7 +55,6 @@ class Application { // : public GApp {
|
|||||||
RenderDevice* getRenderDevice();
|
RenderDevice* getRenderDevice();
|
||||||
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
|
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
|
||||||
void setMode(int mode);
|
void setMode(int mode);
|
||||||
SkyRef getSky();
|
|
||||||
void resize3DView(int w, int h);
|
void resize3DView(int w, int h);
|
||||||
|
|
||||||
Tool * tool;
|
Tool * tool;
|
||||||
@@ -68,7 +66,6 @@ class Application { // : public GApp {
|
|||||||
RenderDevice* renderDevice;
|
RenderDevice* renderDevice;
|
||||||
//void initGUI();
|
//void initGUI();
|
||||||
HWND _hWndMain;
|
HWND _hWndMain;
|
||||||
SkyRef sky;
|
|
||||||
bool quit;
|
bool quit;
|
||||||
bool mouseOnScreen;
|
bool mouseOnScreen;
|
||||||
bool rightButtonHolding;
|
bool rightButtonHolding;
|
||||||
@@ -85,7 +82,6 @@ class Application { // : public GApp {
|
|||||||
GAppSettings _settings;
|
GAppSettings _settings;
|
||||||
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
||||||
IEBrowser* webBrowser;
|
IEBrowser* webBrowser;
|
||||||
bool _hideSky;
|
|
||||||
protected:
|
protected:
|
||||||
Stopwatch m_graphicsWatch;
|
Stopwatch m_graphicsWatch;
|
||||||
Stopwatch m_logicWatch;
|
Stopwatch m_logicWatch;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "ThumbnailGeneratorInstance.h"
|
#include "ThumbnailGeneratorInstance.h"
|
||||||
#include "XplicitNgine/XplicitNgine.h"
|
#include "XplicitNgine/XplicitNgine.h"
|
||||||
#include "SoundService.h"
|
#include "SoundService.h"
|
||||||
|
#include "LightingInstance.h"
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include "rapidxml/rapidxml.hpp"
|
#include "rapidxml/rapidxml.hpp"
|
||||||
@@ -36,6 +37,7 @@ public:
|
|||||||
XplicitNgine* getEngine();
|
XplicitNgine* getEngine();
|
||||||
ThumbnailGeneratorInstance* getThumbnailGenerator();
|
ThumbnailGeneratorInstance* getThumbnailGenerator();
|
||||||
SoundService* getSoundService();
|
SoundService* getSoundService();
|
||||||
|
LightingInstance* getLighting();
|
||||||
|
|
||||||
std::string message;
|
std::string message;
|
||||||
std::string _loadedFileName;
|
std::string _loadedFileName;
|
||||||
@@ -69,7 +71,7 @@ private:
|
|||||||
ThumbnailGeneratorInstance* thumbnailGenerator;
|
ThumbnailGeneratorInstance* thumbnailGenerator;
|
||||||
XplicitNgine* xplicitNgine;
|
XplicitNgine* xplicitNgine;
|
||||||
SoundService* soundService;
|
SoundService* soundService;
|
||||||
|
LightingInstance* lightingInstance;
|
||||||
bool running;
|
bool running;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
44
src/include/DataModelV2/LightingInstance.h
Normal file
44
src/include/DataModelV2/LightingInstance.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Instance.h"
|
||||||
|
|
||||||
|
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::Color4 clearColor);
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
void drawSky();
|
||||||
|
void suppressSky(bool doSuppress);
|
||||||
|
void update();
|
||||||
|
void drawEffects();
|
||||||
|
void drawOutlines(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
void PropUpdate(LPPROPGRIDITEM &pItem);
|
||||||
|
std::vector<PROPGRIDITEM> getProperties();
|
||||||
|
|
||||||
|
private:
|
||||||
|
G3D::Color3 topAmbient;
|
||||||
|
G3D::Color3 bottomAmbient;
|
||||||
|
G3D::Color3 spotLight;
|
||||||
|
G3D::Color4 clearColor;
|
||||||
|
G3D::SkyRef sky;
|
||||||
|
G3D::LightingParameters lighting;
|
||||||
|
bool _hideSky;
|
||||||
|
};
|
||||||
@@ -71,7 +71,6 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
|
|||||||
CreateDirectory(tempPath.c_str(), NULL);
|
CreateDirectory(tempPath.c_str(), NULL);
|
||||||
|
|
||||||
_hWndMain = parentWindow;
|
_hWndMain = parentWindow;
|
||||||
_hideSky = false;
|
|
||||||
|
|
||||||
HMODULE hThisInstance = GetModuleHandle(NULL);
|
HMODULE hThisInstance = GetModuleHandle(NULL);
|
||||||
|
|
||||||
@@ -296,7 +295,6 @@ void Application::onInit() {
|
|||||||
|
|
||||||
void Application::onCleanup() {
|
void Application::onCleanup() {
|
||||||
clearInstances();
|
clearInstances();
|
||||||
sky->~Sky();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::onLogic() {
|
void Application::onLogic() {
|
||||||
@@ -409,90 +407,10 @@ int Application::getMode()
|
|||||||
return _mode;
|
return _mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Application::drawOutline(Vector3 from, Vector3 to, RenderDevice* rd, LightingParameters lighting, Vector3 size, Vector3 pos, CoordinateFrame c)
|
|
||||||
{
|
|
||||||
rd->disableLighting();
|
|
||||||
Color3 outline = Color3::cyan();
|
|
||||||
float offsetSize = 0.05F;
|
|
||||||
//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.1, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
|
||||||
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, 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.1, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, 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.025F/2;
|
|
||||||
if(multiplier < 0.25F)
|
|
||||||
multiplier = 0.25F;
|
|
||||||
Vector3 position = pos + (c.lookVector()*((size.z)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
position = pos - (c.lookVector()*((size.z)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
|
|
||||||
position = pos + (c.rightVector()*((size.x)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
position = pos - (c.rightVector()*((size.x)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
|
|
||||||
position = pos + (c.upVector()*((size.y)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
position = pos - (c.upVector()*((size.y)+1));
|
|
||||||
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rd->enableLighting();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::exitApplication()
|
void Application::exitApplication()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Application::onGraphics(RenderDevice* rd) {
|
void Application::onGraphics(RenderDevice* rd) {
|
||||||
|
|
||||||
G3D::uint8 num = 0;
|
G3D::uint8 num = 0;
|
||||||
@@ -521,57 +439,11 @@ void Application::onGraphics(RenderDevice* rd) {
|
|||||||
ScreenToClient(_hWndMain, &mousepos);
|
ScreenToClient(_hWndMain, &mousepos);
|
||||||
}
|
}
|
||||||
|
|
||||||
LightingParameters lighting(G3D::toSeconds(2, 00, 00, PM));
|
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
|
||||||
lighting.ambient = Color3(0.6F,0.6F,0.6F);
|
|
||||||
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
|
|
||||||
|
|
||||||
// TODO: stick this into its own rendering thing
|
// Moved a lot of code to lighting
|
||||||
if(!_hideSky) {
|
g_dataModel->getLighting()->update();
|
||||||
renderDevice->clear(sky.isNull(), true, true);
|
|
||||||
if (sky.notNull()) sky->render(renderDevice, lighting);
|
|
||||||
} else {
|
|
||||||
rd->setColorClearValue(Color4(0.0f, 0.0f, 0.0f, 0.0f));
|
|
||||||
renderDevice->clear(true, true, true);
|
|
||||||
toggleSky();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup lighting
|
|
||||||
renderDevice->enableLighting();
|
|
||||||
|
|
||||||
renderDevice->setShadeMode(RenderDevice::SHADE_SMOOTH);
|
|
||||||
renderDevice->setAmbientLightColor(Color3(1,1,1));
|
|
||||||
|
|
||||||
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor, true, true));
|
|
||||||
renderDevice->setAmbientLightColor(lighting.ambient);
|
|
||||||
|
|
||||||
rd->beforePrimitive();
|
|
||||||
CoordinateFrame forDraw = rd->getObjectToWorldMatrix();
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
|
||||||
glEnableClientState(GL_NORMAL_ARRAY);
|
|
||||||
_dataModel->getWorkspace()->render(rd);
|
|
||||||
_dataModel->getWorkspace()->renderName(rd);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
|
||||||
glDisableClientState(GL_NORMAL_ARRAY);
|
|
||||||
rd->setObjectToWorldMatrix(forDraw);
|
|
||||||
rd->afterPrimitive();
|
|
||||||
|
|
||||||
for(size_t i = 0; i < _dataModel->getSelectionService()->getSelection().size(); i++)
|
|
||||||
{
|
|
||||||
if(PartInstance* part = dynamic_cast<PartInstance*>(g_dataModel->getSelectionService()->getSelection()[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, lighting, Vector3(size.x/2, size.y/2, size.z/2), Vector3(pos.x, pos.y, pos.z), part->getCFrame());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderDevice->disableLighting();
|
|
||||||
|
|
||||||
if (sky.notNull()) {
|
|
||||||
sky->renderLensFlare(renderDevice, lighting);
|
|
||||||
}
|
|
||||||
renderDevice->push2D();
|
renderDevice->push2D();
|
||||||
_dataModel->getGuiRoot()->renderGUI(renderDevice, m_graphicsWatch.FPS());
|
_dataModel->getGuiRoot()->renderGUI(renderDevice, m_graphicsWatch.FPS());
|
||||||
renderDevice->pop2D();
|
renderDevice->pop2D();
|
||||||
@@ -655,7 +527,6 @@ void Application::run() {
|
|||||||
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
|
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
|
||||||
clickSound = GetFileInPath("/content/sounds/switch.wav");
|
clickSound = GetFileInPath("/content/sounds/switch.wav");
|
||||||
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
|
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
|
||||||
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
|
||||||
RealTime now=0, lastTime=0;
|
RealTime now=0, lastTime=0;
|
||||||
double simTimeRate = 1.0f;
|
double simTimeRate = 1.0f;
|
||||||
float fps=30.0f;
|
float fps=30.0f;
|
||||||
@@ -734,17 +605,6 @@ void Application::resizeWithParent(HWND parentWindow)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These should be moved into a "Lighting" class
|
|
||||||
G3D::SkyRef Application::getSky()
|
|
||||||
{
|
|
||||||
return sky;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::toggleSky()
|
|
||||||
{
|
|
||||||
_hideSky = !_hideSky;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::resize3DView(int w, int h)
|
void Application::resize3DView(int w, int h)
|
||||||
{
|
{
|
||||||
Rect2D newViewport = Rect2D::xywh(0, 0, w, h);
|
Rect2D newViewport = Rect2D::xywh(0, 0, w, h);
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
// Instances
|
||||||
#include "DataModelV2/GuiRootInstance.h"
|
#include "DataModelV2/GuiRootInstance.h"
|
||||||
#include "DataModelV2/ToggleImageButtonInstance.h"
|
#include "DataModelV2/ToggleImageButtonInstance.h"
|
||||||
#include "DataModelV2/DataModelInstance.h"
|
#include "DataModelV2/DataModelInstance.h"
|
||||||
#include "DataModelV2/ThumbnailGeneratorInstance.h"
|
#include "DataModelV2/ThumbnailGeneratorInstance.h"
|
||||||
|
#include "DataModelV2/LightingInstance.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -23,6 +27,7 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
level = new LevelInstance();
|
level = new LevelInstance();
|
||||||
thumbnailGenerator = new ThumbnailGeneratorInstance();
|
thumbnailGenerator = new ThumbnailGeneratorInstance();
|
||||||
soundService = new SoundService();
|
soundService = new SoundService();
|
||||||
|
lightingInstance = new LightingInstance();
|
||||||
|
|
||||||
selectionService = new SelectionService();
|
selectionService = new SelectionService();
|
||||||
selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
selectionService->setPropertyWindow(g_usableApp->_propWindow);
|
||||||
@@ -30,9 +35,12 @@ DataModelInstance::DataModelInstance(void)
|
|||||||
showMessage = false;
|
showMessage = false;
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
_modY=0;
|
_modY=0;
|
||||||
|
|
||||||
|
// Parent stuff
|
||||||
workspace->setParent(this);
|
workspace->setParent(this);
|
||||||
level->setParent(this);
|
level->setParent(this);
|
||||||
soundService->setParent(this);
|
soundService->setParent(this);
|
||||||
|
lightingInstance->setParent(this);
|
||||||
|
|
||||||
_loadedFileName="..//skooter.rbxm";
|
_loadedFileName="..//skooter.rbxm";
|
||||||
listicon = 5;
|
listicon = 5;
|
||||||
@@ -662,4 +670,9 @@ ThumbnailGeneratorInstance* DataModelInstance::getThumbnailGenerator()
|
|||||||
SoundService* DataModelInstance::getSoundService()
|
SoundService* DataModelInstance::getSoundService()
|
||||||
{
|
{
|
||||||
return soundService;
|
return soundService;
|
||||||
|
}
|
||||||
|
|
||||||
|
LightingInstance* DataModelInstance::getLighting()
|
||||||
|
{
|
||||||
|
return lightingInstance;
|
||||||
}
|
}
|
||||||
@@ -140,6 +140,7 @@ std::vector<PROPGRIDITEM> LevelInstance::getProperties()
|
|||||||
));
|
));
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
|
||||||
{
|
{
|
||||||
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)
|
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)
|
||||||
|
|||||||
260
src/source/DataModelV2/LightingInstance.cpp
Normal file
260
src/source/DataModelV2/LightingInstance.cpp
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
#include "DataModelV2/LightingInstance.h"
|
||||||
|
#include "Application.h"
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "StringFunctions.h"
|
||||||
|
#include "Listener/ModeSelectionListener.h"
|
||||||
|
|
||||||
|
LightingInstance::LightingInstance(void)
|
||||||
|
{
|
||||||
|
Instance::Instance();
|
||||||
|
name = "Lighting";
|
||||||
|
className = "Lighting";
|
||||||
|
listicon = 10;
|
||||||
|
canDelete = false;
|
||||||
|
|
||||||
|
_hideSky = false;
|
||||||
|
|
||||||
|
lighting.setTime(G3D::toSeconds(2, 00, 00, PM));
|
||||||
|
|
||||||
|
// Maybe this is Top and Bottom Ambient?
|
||||||
|
lighting.ambient = Color3(0.5F, 0.5F, 0.5F);
|
||||||
|
lighting.lightColor = Color3(0.8F, 0.8F, 0.8F);
|
||||||
|
|
||||||
|
sky = Sky::create(NULL, ExePath() + "/content/sky/");
|
||||||
|
clearColor = Color4(0.0F, 0.0F, 0.0F, 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
LightingInstance::~LightingInstance(void)
|
||||||
|
{
|
||||||
|
sky->~Sky();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Getters
|
||||||
|
G3D::SkyRef LightingInstance::getSky()
|
||||||
|
{
|
||||||
|
return sky;
|
||||||
|
}
|
||||||
|
|
||||||
|
G3D::LightingParameters LightingInstance::getLightingParameters()
|
||||||
|
{
|
||||||
|
return lighting;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<PROPGRIDITEM> LightingInstance::getProperties()
|
||||||
|
{
|
||||||
|
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Appearance",
|
||||||
|
"TopAmbient",
|
||||||
|
"The color of the TopAmbient for 3D Objects",
|
||||||
|
RGB((topAmbient.r*255),(topAmbient.g*255),(topAmbient.b*255)),
|
||||||
|
PIT_COLOR
|
||||||
|
));
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Appearance",
|
||||||
|
"BottomAmbient",
|
||||||
|
"The color of the BottomAmbient for 3D Objects",
|
||||||
|
RGB((bottomAmbient.r*255),(bottomAmbient.g*255),(bottomAmbient.b*255)),
|
||||||
|
PIT_COLOR
|
||||||
|
));
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Appearance",
|
||||||
|
"SpotLight",
|
||||||
|
"The color of the SpotLight",
|
||||||
|
RGB((spotLight.r*255),(spotLight.g*255),(spotLight.b*255)),
|
||||||
|
PIT_COLOR
|
||||||
|
));
|
||||||
|
|
||||||
|
properties.push_back(createPGI("Appearance",
|
||||||
|
"ClearColor",
|
||||||
|
"",
|
||||||
|
RGB((clearColor.r*255),(clearColor.g*255),(clearColor.b*255)),
|
||||||
|
PIT_COLOR
|
||||||
|
));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LightingInstance::PropUpdate(LPPROPGRIDITEM &item)
|
||||||
|
{
|
||||||
|
if(strcmp(item->lpszPropName, "TopAmbient") == 0)
|
||||||
|
{
|
||||||
|
topAmbient = Color3(
|
||||||
|
GetRValue(item->lpCurValue)/255.0F,
|
||||||
|
GetGValue(item->lpCurValue)/255.0F,
|
||||||
|
GetBValue(item->lpCurValue)/255.0F
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(strcmp(item->lpszPropName, "BottomAmbient") == 0)
|
||||||
|
{
|
||||||
|
bottomAmbient = Color3(
|
||||||
|
GetRValue(item->lpCurValue)/255.0F,
|
||||||
|
GetGValue(item->lpCurValue)/255.0F,
|
||||||
|
GetBValue(item->lpCurValue)/255.0F
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(strcmp(item->lpszPropName, "SpotLight") == 0)
|
||||||
|
{
|
||||||
|
spotLight = Color3(
|
||||||
|
GetRValue(item->lpCurValue)/255.0F,
|
||||||
|
GetGValue(item->lpCurValue)/255.0F,
|
||||||
|
GetBValue(item->lpCurValue)/255.0F
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(strcmp(item->lpszPropName, "ClearColor") == 0)
|
||||||
|
{
|
||||||
|
clearColor = Color3(
|
||||||
|
GetRValue(item->lpCurValue)/255.0F,
|
||||||
|
GetGValue(item->lpCurValue)/255.0F,
|
||||||
|
GetBValue(item->lpCurValue)/255.0F
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
Instance::PropUpdate(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
void LightingInstance::suppressSky(bool doSuppress)
|
||||||
|
{
|
||||||
|
_hideSky = doSuppress;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightingInstance::update()
|
||||||
|
{
|
||||||
|
RenderDevice* rd = g_usableApp->getRenderDevice();
|
||||||
|
|
||||||
|
|
||||||
|
if(!_hideSky) {
|
||||||
|
rd->clear(sky.isNull(), true, true);
|
||||||
|
if (sky.notNull()) sky->render(rd, lighting);
|
||||||
|
} else {
|
||||||
|
rd->setColorClearValue(clearColor);
|
||||||
|
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);
|
||||||
|
g_dataModel->getWorkspace()->render(rd);
|
||||||
|
g_dataModel->getWorkspace()->renderName(rd);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
glDisableClientState(GL_NORMAL_ARRAY);
|
||||||
|
rd->setObjectToWorldMatrix(forDraw);
|
||||||
|
rd->afterPrimitive();
|
||||||
|
|
||||||
|
// Draw outlines
|
||||||
|
for(size_t i = 0; i < g_dataModel->getSelectionService()->getSelection().size(); i++)
|
||||||
|
{
|
||||||
|
if(PartInstance* part = dynamic_cast<PartInstance*>(g_dataModel->getSelectionService()->getSelection()[i]))
|
||||||
|
{
|
||||||
|
Vector3 size = part->getSize();
|
||||||
|
Vector3 pos = part->getPosition();
|
||||||
|
drawOutlines(
|
||||||
|
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()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rd->disableLighting();
|
||||||
|
|
||||||
|
drawEffects();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightingInstance::drawEffects()
|
||||||
|
{
|
||||||
|
RenderDevice* rd = g_usableApp->getRenderDevice();
|
||||||
|
if (sky.notNull()) {
|
||||||
|
sky->renderLensFlare(rd, lighting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LightingInstance::drawOutlines(Vector3 from, Vector3 to, RenderDevice* rd, Vector3 size, Vector3 pos, CoordinateFrame c)
|
||||||
|
{
|
||||||
|
Color3 outline = Color3::cyan();
|
||||||
|
float offsetSize = 0.05F;
|
||||||
|
|
||||||
|
//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.1, from.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, from.z + offsetSize), Vector3(to.x - offsetSize, to.y + offsetSize - 0.1, from.z - offsetSize))), rd, outline, Color4::clear());
|
||||||
|
Draw::box(c.toWorldSpace(Box(Vector3(to.x + offsetSize, from.y - offsetSize + 0.1, 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.1, to.z + offsetSize), Vector3(from.x - offsetSize, to.y + offsetSize - 0.1, 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(g_usableApp->getMode() == 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(g_usableApp->getMode() == 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.025F/2;
|
||||||
|
if(multiplier < 0.25F)
|
||||||
|
multiplier = 0.25F;
|
||||||
|
Vector3 position = pos + (c.lookVector()*((size.z)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.lookVector()*((size.z)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
|
position = pos + (c.rightVector()*((size.x)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.rightVector()*((size.x)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
|
||||||
|
position = pos + (c.upVector()*((size.y)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
position = pos - (c.upVector()*((size.y)+1));
|
||||||
|
Draw::sphere(Sphere(position, multiplier), rd, sphereColor, Color4::clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -593,7 +593,11 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
|
|||||||
setChanged();
|
setChanged();
|
||||||
if(strcmp(item->lpszPropName, "Color3") == 0)
|
if(strcmp(item->lpszPropName, "Color3") == 0)
|
||||||
{
|
{
|
||||||
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
|
color = Color3(
|
||||||
|
GetRValue(item->lpCurValue)/255.0F,
|
||||||
|
GetGValue(item->lpCurValue)/255.0F,
|
||||||
|
GetBValue(item->lpCurValue)/255.0F
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else if(strcmp(item->lpszPropName, "Anchored") == 0)
|
else if(strcmp(item->lpszPropName, "Anchored") == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user