Add LightingInstance

Still need to work on PropertyGrid for it
This commit is contained in:
Modnark
2022-10-12 13:47:39 -04:00
parent 8916797e55
commit 0ac516618a
10 changed files with 338 additions and 150 deletions

View File

@@ -457,6 +457,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\source\DataModelV2\LightingInstance.cpp"
>
</File>
<File
RelativePath=".\src\source\DataModelV2\PartInstance.cpp"
>
@@ -874,6 +878,10 @@
RelativePath=".\src\include\DataModelV2\LevelInstance.h"
>
</File>
<File
RelativePath=".\src\include\DataModelV2\LightingInstance.h"
>
</File>
<File
RelativePath=".\src\include\DataModelV2\PartInstance.h"
>

View File

@@ -39,7 +39,7 @@ std::string ThumbnailGeneratorInstance::click(std::string fileType, int cx, int
g_usableApp->resize3DView(cx, cy);
if(hideSky)
g_usableApp->toggleSky();
g_dataModel->getLighting()->suppressSky(true);
g_usableApp->onGraphics(rd);
rd->screenshotPic(imgBuffer, true, hideSky);

View File

@@ -48,7 +48,6 @@ class Application { // : public GApp {
int getMode();
void unSetMode();
void toggleSky();
CameraController cameraController;
UserInput* userInput;
PropertyWindow* _propWindow;
@@ -56,7 +55,6 @@ class Application { // : public GApp {
RenderDevice* getRenderDevice();
void selectInstance(Instance* selectedInstance,PropertyWindow* propWindow);
void setMode(int mode);
SkyRef getSky();
void resize3DView(int w, int h);
Tool * tool;
@@ -68,7 +66,6 @@ class Application { // : public GApp {
RenderDevice* renderDevice;
//void initGUI();
HWND _hWndMain;
SkyRef sky;
bool quit;
bool mouseOnScreen;
bool rightButtonHolding;
@@ -85,7 +82,6 @@ class Application { // : public GApp {
GAppSettings _settings;
double lightProjX, lightProjY, lightProjNear, lightProjFar;
IEBrowser* webBrowser;
bool _hideSky;
protected:
Stopwatch m_graphicsWatch;
Stopwatch m_logicWatch;

View File

@@ -9,6 +9,7 @@
#include "ThumbnailGeneratorInstance.h"
#include "XplicitNgine/XplicitNgine.h"
#include "SoundService.h"
#include "LightingInstance.h"
// Libraries
#include "rapidxml/rapidxml.hpp"
@@ -36,6 +37,7 @@ public:
XplicitNgine* getEngine();
ThumbnailGeneratorInstance* getThumbnailGenerator();
SoundService* getSoundService();
LightingInstance* getLighting();
std::string message;
std::string _loadedFileName;
@@ -69,7 +71,7 @@ private:
ThumbnailGeneratorInstance* thumbnailGenerator;
XplicitNgine* xplicitNgine;
SoundService* soundService;
LightingInstance* lightingInstance;
bool running;
};

View 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;
};

View File

@@ -71,7 +71,6 @@ Application::Application(HWND parentWindow) : _propWindow(NULL) { //: GApp(setti
CreateDirectory(tempPath.c_str(), NULL);
_hWndMain = parentWindow;
_hideSky = false;
HMODULE hThisInstance = GetModuleHandle(NULL);
@@ -296,7 +295,6 @@ void Application::onInit() {
void Application::onCleanup() {
clearInstances();
sky->~Sky();
}
void Application::onLogic() {
@@ -409,90 +407,10 @@ int Application::getMode()
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::onGraphics(RenderDevice* rd) {
G3D::uint8 num = 0;
@@ -521,57 +439,11 @@ void Application::onGraphics(RenderDevice* rd) {
ScreenToClient(_hWndMain, &mousepos);
}
LightingParameters lighting(G3D::toSeconds(2, 00, 00, PM));
lighting.ambient = Color3(0.6F,0.6F,0.6F);
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
renderDevice->setProjectionAndCameraMatrix(*cameraController.getCamera());
// TODO: stick this into its own rendering thing
if(!_hideSky) {
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();
// Moved a lot of code to lighting
g_dataModel->getLighting()->update();
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();
_dataModel->getGuiRoot()->renderGUI(renderDevice, m_graphicsWatch.FPS());
renderDevice->pop2D();
@@ -655,7 +527,6 @@ void Application::run() {
cameraSound = GetFileInPath("/content/sounds/SWITCH3.wav");
clickSound = GetFileInPath("/content/sounds/switch.wav");
dingSound = GetFileInPath("/content/sounds/electronicpingshort.wav");
sky = Sky::create(NULL, ExePath() + "/content/sky/");
RealTime now=0, lastTime=0;
double simTimeRate = 1.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)
{
Rect2D newViewport = Rect2D::xywh(0, 0, w, h);

View File

@@ -1,8 +1,12 @@
#include <string>
// Instances
#include "DataModelV2/GuiRootInstance.h"
#include "DataModelV2/ToggleImageButtonInstance.h"
#include "DataModelV2/DataModelInstance.h"
#include "DataModelV2/ThumbnailGeneratorInstance.h"
#include "DataModelV2/LightingInstance.h"
#include <fstream>
#include <iostream>
#include <sstream>
@@ -23,6 +27,7 @@ DataModelInstance::DataModelInstance(void)
level = new LevelInstance();
thumbnailGenerator = new ThumbnailGeneratorInstance();
soundService = new SoundService();
lightingInstance = new LightingInstance();
selectionService = new SelectionService();
selectionService->setPropertyWindow(g_usableApp->_propWindow);
@@ -30,9 +35,12 @@ DataModelInstance::DataModelInstance(void)
showMessage = false;
canDelete = false;
_modY=0;
// Parent stuff
workspace->setParent(this);
level->setParent(this);
soundService->setParent(this);
lightingInstance->setParent(this);
_loadedFileName="..//skooter.rbxm";
listicon = 5;
@@ -662,4 +670,9 @@ ThumbnailGeneratorInstance* DataModelInstance::getThumbnailGenerator()
SoundService* DataModelInstance::getSoundService()
{
return soundService;
}
LightingInstance* DataModelInstance::getLighting()
{
return lightingInstance;
}

View File

@@ -140,6 +140,7 @@ std::vector<PROPGRIDITEM> LevelInstance::getProperties()
));
return properties;
}
void LevelInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
if(strcmp(pItem->lpszPropName, "InitialTimerValue") == 0)

View 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());
}
}
}

View File

@@ -593,7 +593,11 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
setChanged();
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)
{