Merge pull request #38 from Vulpovile/hypersnap-engine

Controllerflags
This commit is contained in:
Vulpovile
2020-03-09 12:02:49 -07:00
committed by GitHub
20 changed files with 513 additions and 33 deletions

View File

@@ -31,7 +31,7 @@
#include "DeleteListener.h"
#include "CameraButtonListener.h"
#include "RotateButtonListener.h"
#define LEGACY_LOAD_G3DFUN_LEVEL
Ray testRay;
static int cursorid = 0;
static int cursorOvrid = 0;
@@ -167,6 +167,7 @@ void Application::deleteInstance()
g_usableApp->_propWindow->ClearProperties();
}
void Application::onInit() {
// Called before Application::run() beings
@@ -284,16 +285,74 @@ void Application::onCleanup() {
/*
void Application::onLogic() {
// Add non-simulation game logic and AI code here
Class HyperSnapSolver
function getCollisionDepth(Part colliding, part collider);
function getFaceCollision(Part colliding, part collider);
function eject(Part colliding, Part collider)
{
if(!colliding.canCollide || !collider.canCollide)
return;
if(getCollisionDepth(colliding, collider) != 0) {
int ejectMultiplier, ejectMultipliery = 1-(collider.Friction+colliding.Friction), ejectMultiplierz = 1-(collider.Friction/2+colliding.Friction/2);
if(colliding.Anchored)
ejectMultiplier = collider.elasticity;
int faceCollided = getFaceCollision(colliding, collider);
if(faceCollided % 3 == 1)
{
ejectMultipliery = ejectMultiplier;
ejectMultiplier = 1-(collider.Friction+colliding.Friction/2);
}
else if(faceCollided % 3 == 2)
{
ejectMultiplierz = ejectMultiplier;
ejectMultiplier = 1-(collider.Friction+colliding.Friction/2);
}
collider.Velocity *= Vector3.new(colliding.Velocity.x*ejectMultiplier,colliding.Velocity.y*ejectMultipliery,colliding.Velocity.z)
}
}
*/
double grav = 0.32666666666666666666666666666667;
void simGrav(PartInstance * collider)
{
if(!collider->anchored)
{
collider->setPosition(collider->getPosition()+collider->getVelocity());
collider->setVelocity(collider->getVelocity()-Vector3(0,grav,0));
}
}
void eject(PartInstance * colliding, PartInstance * collider)
{
if(colliding == collider || !colliding->canCollide || !collider->canCollide)
return;
if(G3D::CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(collider->getBox(), colliding->getBox()))
collider->setVelocity(collider->getVelocity().reflectionDirection(colliding->cFrame.upVector())/1.3);
}
void Application::onLogic() {
//PhysicsStart
for_each (_dataModel->getWorkspace()->partObjects.begin(), _dataModel->getWorkspace()->partObjects.end(), simGrav);
for(size_t i = 0; i < _dataModel->getWorkspace()->partObjects.size(); i++)
{
for(size_t j = 0; j < _dataModel->getWorkspace()->partObjects.size(); j++)
{
eject(_dataModel->getWorkspace()->partObjects[i], _dataModel->getWorkspace()->partObjects[j]);
}
}
}
void Application::onNetwork() {
// Poll net messages here
}
@@ -310,7 +369,8 @@ std::vector<Instance*> Application::getSelection()
}
void Application::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
if(_dataModel->isRunning())
onLogic();
_dataModel->getGuiRoot()->update();
@@ -604,7 +664,8 @@ void Application::onGraphics(RenderDevice* rd) {
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
//if(_dataModel->getWorkspace() != NULL)
_dataModel->getWorkspace()->render(rd);
_dataModel->getWorkspace()->render(rd);
//else throw std::exception("Workspace not found");
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);

View File

@@ -30,9 +30,19 @@ DataModelInstance::DataModelInstance(void)
level->setParent(this);
_loadedFileName="..//skooter.rbxm";
listicon = 5;
running = false;
}
void DataModelInstance::toggleRun()
{
running = !running;
}
bool DataModelInstance::isRunning()
{
return running;
}
DataModelInstance::~DataModelInstance(void)
{
}

View File

@@ -36,6 +36,8 @@ public:
bool mouseButton1Down;
PartInstance* makePart();
void clearLevel();
void toggleRun();
bool isRunning();
#if _DEBUG
void modXMLLevel(float modY);
#endif
@@ -51,4 +53,5 @@ private:
WorkspaceInstance* workspace;
LevelInstance * level;
GuiRoot* guiRoot;
bool running;
};

6
Enum.h
View File

@@ -14,4 +14,10 @@ namespace Enum
Ball = 0, Block = 1, Cylinder = 2
};
}
namespace Controller
{
enum Value {
Player = 7, KeyboardRight = 1, KeyboardLeft = 2, Joypad1 = 3, Joypad2 = 4, Chase = 5, Flee = 6, None = 0
};
}
}

View File

@@ -250,10 +250,6 @@
RelativePath=".\BrowserCallHandler.cpp"
>
</File>
<File
RelativePath=".\ButtonListener.cpp"
>
</File>
<File
RelativePath=".\CameraController.cpp"
>
@@ -266,14 +262,6 @@
RelativePath=".\Globals.cpp"
>
</File>
<File
RelativePath=".\GroupInstance.cpp"
>
</File>
<File
RelativePath=".\GuiRoot.cpp"
>
</File>
<File
RelativePath=".\IEBrowser.cpp"
>
@@ -314,6 +302,10 @@
RelativePath=".\StringFunctions.cpp"
>
</File>
<File
RelativePath=".\ToggleImageButtonInstance.cpp"
>
</File>
<File
RelativePath=".\WindowFunctions.cpp"
>
@@ -329,6 +321,14 @@
RelativePath=".\DataModelInstance.cpp"
>
</File>
<File
RelativePath=".\GroupInstance.cpp"
>
</File>
<File
RelativePath=".\GuiRoot.cpp"
>
</File>
<File
RelativePath=".\ImageButtonInstance.cpp"
>
@@ -361,6 +361,10 @@
<Filter
Name="Listeners"
>
<File
RelativePath=".\ButtonListener.cpp"
>
</File>
<File
RelativePath=".\CameraButtonListener.cpp"
>
@@ -373,6 +377,10 @@
RelativePath=".\GUDButtonListener.cpp"
>
</File>
<File
RelativePath=".\MenuButtonListener.cpp"
>
</File>
<File
RelativePath=".\ModeSelectionListener.cpp"
>
@@ -427,10 +435,6 @@
RelativePath=".\Globals.h"
>
</File>
<File
RelativePath=".\GuiRoot.h"
>
</File>
<File
RelativePath=".\IEBrowser.h"
>
@@ -479,6 +483,10 @@
RelativePath=".\StringFunctions.h"
>
</File>
<File
RelativePath=".\ToggleImageButtonInstance.h"
>
</File>
<File
RelativePath=".\win32Defines.h"
>
@@ -502,6 +510,10 @@
RelativePath=".\GroupInstance.h"
>
</File>
<File
RelativePath=".\GuiRoot.h"
>
</File>
<File
RelativePath=".\ImageButtonInstance.h"
>
@@ -546,6 +558,10 @@
RelativePath=".\GUDButtonListener.h"
>
</File>
<File
RelativePath=".\MenuButtonListener.h"
>
</File>
<File
RelativePath=".\ModeSelectionListener.h"
>

View File

@@ -44,6 +44,10 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
if(g_selectedInstances.at(i)->canDelete)
{
g_selectedInstances.at(i)->setParent(inst);
if(PartInstance* part = dynamic_cast<PartInstance*>(g_selectedInstances.at(i)))
{
inst->primaryPart = part;
}
}
/*tempinst->setPosition(Vector3(tempPos.x, tempPos.y + tempSize.y, tempPos.z));
g_usableApp->cameraController.centerCamera(g_selectedInstances.at(0));*/

View File

@@ -6,6 +6,7 @@ GroupInstance::GroupInstance(void)
name = "Model";
className = "GroupInstance";
listicon = 12;
primaryPart = NULL;
}
GroupInstance::GroupInstance(const GroupInstance &oinst)
@@ -14,6 +15,7 @@ GroupInstance::GroupInstance(const GroupInstance &oinst)
name = "Model";
className = "GroupInstance";
listicon = 12;
primaryPart = NULL;
}
GroupInstance::~GroupInstance(void)
@@ -39,4 +41,37 @@ std::vector<Instance *> GroupInstance::unGroup()
children[0]->setParent(parent);
}
return child;
}
void GroupInstance::render(RenderDevice * rd)
{
Instance::render(rd);
if(primaryPart != NULL && controllerFlagShown && getControllerColor(controller) != Color3::gray())
{
rd->disableLighting();
Vector3 vec = Vector3(0,0,0);
Vector3 up = Vector3(0,8,0);
rd->setColor(getControllerColor(controller));
rd->setObjectToWorldMatrix(primaryPart->cFrame);
rd->beforePrimitive();
glBegin(GL_LINES);
glVertex3f(vec.x, vec.y, vec.z);
glVertex3f(up.x, up.y, up.z);
glEnd();
glBegin( GL_TRIANGLES );
glVertex3f(up.x, up.y-2, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y, up.z);
glVertex3f(up.x, up.y-1, up.z-2);
glVertex3f(up.x, up.y-2, up.z);
glEnd();
rd->afterPrimitive();
rd->setColor(Color3::white());
rd->enableLighting();
}
}

View File

@@ -1,5 +1,5 @@
#pragma once
#include "PVInstance.h"
#include "PartInstance.h"
class GroupInstance :
public PVInstance
@@ -11,4 +11,6 @@ public:
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
std::vector<Instance *> unGroup();
PartInstance * primaryPart;
void render(RenderDevice * r);
};

View File

@@ -4,12 +4,14 @@
#include "BaseButtonInstance.h"
#include "TextButtonInstance.h"
#include "ImageButtonInstance.h"
#include "ToggleImageButtonInstance.h"
#include "GuiRoot.h"
#include "Globals.h"
#include "StringFunctions.h"
#include "GUDButtonListener.h"
#include "ModeSelectionListener.h"
#include "MenuButtonListener.h"
#include "RotateButtonListener.h"
#include "CameraButtonListener.h"
#include "DeleteListener.h"
@@ -210,10 +212,16 @@ GuiRoot::GuiRoot() : _message(""), _messageTime(0)
button->name = "Duplicate";
button->setButtonListener(new GUDButtonListener());
ImageButtonInstance* instance = makeImageButton(
ImageButtonInstance* instance = new ToggleImageButtonInstance(
Texture::fromFile(GetFileInPath("/content/images/Run.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")));
Texture::fromFile(GetFileInPath("/content/images/Run_dn.png")),
NULL,
Texture::fromFile(GetFileInPath("/content/images/Stop.png")),
Texture::fromFile(GetFileInPath("/content/images/Stop_ovr.png")),
Texture::fromFile(GetFileInPath("/content/images/Stop_dn.png"))
);
instance->setButtonListener(new MenuButtonListener());
instance->name = "go";
instance->size = Vector2(65,65);
instance->position = Vector2(6.5, 25);

View File

@@ -3,6 +3,7 @@
#include "Instance.h"
Instance::Instance(void)
{
parent = NULL;

View File

@@ -1,6 +1,7 @@
#pragma once
#include <G3DAll.h>
#include "propertyGrid.h"
#include "map"
class Instance
{
@@ -17,7 +18,7 @@ public:
Instance* findFirstChild(std::string);
std::vector<Instance* > getChildren();
std::vector<Instance* > getAllChildren();
void setParent(Instance*);
virtual void setParent(Instance*);
void setName(std::string newName);
void addChild(Instance*);
void removeChild(Instance*);
@@ -31,5 +32,6 @@ protected:
std::string className;
Instance* parent; // Another pointer.
PROPGRIDITEM createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, LPARAM curVal, INT type, TCHAR choices[] = NULL);
private:
static const std::map<std::string, Instance> g_logLevelsDescriptions;
};

11
MenuButtonListener.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "MenuButtonListener.h"
#include "toggleimagebuttoninstance.h"
#include "Globals.h"
void MenuButtonListener::onButton1MouseClick(BaseButtonInstance* button)
{
if(button->name == "go")
{
g_dataModel->toggleRun();
((ToggleImageButtonInstance*)button)->checked = g_dataModel->isRunning();
}
}

8
MenuButtonListener.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
#include "buttonlistener.h"
class MenuButtonListener :
public ButtonListener
{
public:
void onButton1MouseClick(BaseButtonInstance*);
};

View File

@@ -4,8 +4,10 @@ PVInstance::PVInstance(void)
{
Instance::Instance();
nameShown = false;
controllerFlagShown = true;
className = "PVInstance";
listicon = 0;
controller = (Enum::Controller::Value)0;
}
PVInstance::PVInstance(const PVInstance &oinst)
@@ -21,6 +23,46 @@ void PVInstance::postRender(RenderDevice* rd)
{
}
static TCHAR* enumStr(int controller)
{
switch(controller)
{
case Enum::Controller::None:
return "None";
case Enum::Controller::KeyboardLeft:
return "KeyboardLeft";
case Enum::Controller::KeyboardRight:
return "KeyboardRight";
case Enum::Controller::Joypad1:
return "Joypad1";
case Enum::Controller::Joypad2:
return "Joypad2";
case Enum::Controller::Chase:
return "Joypad1";
case Enum::Controller::Flee:
return "Joypad2";
}
}
static Enum::Controller::Value strEnum(TCHAR * tval)
{
if(strcmp(tval, "KeyboardLeft") == 0)
return Enum::Controller::KeyboardLeft;
if(strcmp(tval, "KeyboardRight") == 0)
return Enum::Controller::KeyboardRight;
if(strcmp(tval, "Joypad1") == 0)
return Enum::Controller::Joypad1;
if(strcmp(tval, "Joypad2") == 0)
return Enum::Controller::Joypad2;
if(strcmp(tval, "Chase") == 0)
return Enum::Controller::Chase;
if(strcmp(tval, "Flee") == 0)
return Enum::Controller::Flee;
return Enum::Controller::None;
}
std::vector<PROPGRIDITEM> PVInstance::getProperties()
{
std::vector<PROPGRIDITEM> properties = Instance::getProperties();
@@ -30,6 +72,21 @@ std::vector<PROPGRIDITEM> PVInstance::getProperties()
"This chooses whether the item name is shown",
nameShown,
PIT_CHECK));
properties.push_back(createPGI(
"Item",
"ControllerFlagShown",
"This chooses whether the item's ControllerFlag is shown",
controllerFlagShown,
PIT_CHECK));
properties.push_back(createPGI(
"Behaviour",
"Controller",
"This chooses what type of controller is used",
(LPARAM)enumStr(controller),
PIT_COMBO,
TEXT("None\0KeyboardRight\0KeyboardLeft\0Joypad1\0Joypad2\0Chase\0Flee")
));
return properties;
}
void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
@@ -38,5 +95,13 @@ void PVInstance::PropUpdate(LPPROPGRIDITEM &pItem)
{
nameShown = (bool)pItem->lpCurValue;
}
if(strcmp(pItem->lpszPropName, "ControllerFlagShown") == 0)
{
controllerFlagShown = (bool)pItem->lpCurValue;
}
if(strcmp(pItem->lpszPropName, "Controller") == 0)
{
controller = strEnum((TCHAR *)pItem->lpCurValue);
}
else Instance::PropUpdate(pItem);
}

View File

@@ -1,5 +1,6 @@
#pragma once
#include "instance.h"
#include "enum.h"
class PVInstance :
public Instance
@@ -12,4 +13,22 @@ public:
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
bool nameShown;
bool controllerFlagShown;
Enum::Controller::Value controller;
protected:
static G3D::Color3 getControllerColor(int controller)
{
switch(controller)
{
case Enum::Controller::KeyboardLeft:
return Color3::red();
case Enum::Controller::KeyboardRight:
return Color3::blue();
case Enum::Controller::Chase:
return Color3::black();
case Enum::Controller::Flee:
return Color3::yellow();
}
return Color3::gray();
}
};

View File

@@ -11,7 +11,7 @@ PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer
name = "Unnamed PVItem";
className = "Part";
canCollide = true;
anchored = true;
anchored = false;
size = Vector3(2,1,4);
setCFrame(CoordinateFrame(Vector3(0,0,0)));
color = Color3::gray();
@@ -26,6 +26,25 @@ PartInstance::PartInstance(void) : _bevelSize(0.07f), _parseVert(0), _debugTimer
shape = Enum::Shape::Block;
}
Vector3 PartInstance::getVelocity()
{
return velocity;
}
Vector3 PartInstance::getRotVelocity()
{
return rotVelocity;
}
void PartInstance::setVelocity(Vector3 v)
{
velocity = v;
}
void PartInstance::setRotVelocity(Vector3 v)
{
rotVelocity = v;
}
void PartInstance::postRender(RenderDevice *rd)
{
if(!nameShown)
@@ -57,6 +76,30 @@ void PartInstance::postRender(RenderDevice *rd)
}
}
void PartInstance::setParent(Instance* parent)
{
Instance * cparent = this->parent;
while(cparent != NULL)
{
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
{
workspace->partObjects.erase(std::remove(workspace->partObjects.begin(), workspace->partObjects.end(), this), workspace->partObjects.end());
break;
}
cparent = cparent->getParent();
}
Instance::setParent(parent);
while(parent != NULL)
{
if(WorkspaceInstance* workspace = dynamic_cast<WorkspaceInstance*>(parent))
{
workspace->partObjects.push_back(this);
break;
}
parent = parent->getParent();
}
}
PartInstance::PartInstance(const PartInstance &oinst) : _bevelSize(0.07f), _parseVert(0), _debugTimer(0)
{
PVInstance::PVInstance(oinst);
@@ -145,7 +188,7 @@ void PartInstance::setShape(Enum::Shape::Value shape)
void PartInstance::setPosition(Vector3 pos)
{
position = pos;
cFrame = CoordinateFrame(pos);
cFrame = CoordinateFrame(cFrame.rotation, pos);
changed = true;
}
@@ -1048,6 +1091,11 @@ void PartInstance::PropUpdate(LPPROPGRIDITEM &item)
color = Color3(GetRValue(item->lpCurValue)/255.0F,GetGValue(item->lpCurValue)/255.0F,GetBValue(item->lpCurValue)/255.0F);
changed=true;
}
if(strcmp(item->lpszPropName, "Anchored") == 0)
{
anchored=(bool)item->lpCurValue;
changed=true;
}
else if(strcmp(item->lpszPropName, "Offset") == 0)
{
std::string str = (LPTSTR)item->lpCurValue;
@@ -1127,8 +1175,14 @@ std::vector<PROPGRIDITEM> PartInstance::getProperties()
RGB((color.r*255),(color.g*255),(color.b*255)),
PIT_COLOR
));
sprintf_s(pto, "%g, %g, %g", cFrame.translation.x, cFrame.translation.y, cFrame.translation.z);
properties.push_back(createPGI(
"Item",
"Anchored",
"Whether the block can move or not",
(LPARAM)anchored,
PIT_CHECK
));
sprintf_s(pto, "%g, %g, %g", position.x, position.y, position.z);
properties.push_back(createPGI(
"Item",
"Offset",

View File

@@ -16,7 +16,6 @@ public:
virtual void PartInstance::postRender(RenderDevice* rd);
~PartInstance(void);
virtual void render(RenderDevice*);
Vector3 velocity;
Enum::SurfaceType::Value top;
Enum::SurfaceType::Value front;
Enum::SurfaceType::Value right;
@@ -27,7 +26,12 @@ public:
CoordinateFrame cFrame;
Color3 color;
Vector3 getPosition();
Vector3 getVelocity();
Vector3 getRotVelocity();
void setParent(Instance* parent);
void setPosition(Vector3);
void setVelocity(Vector3);
void setRotVelocity(Vector3);
CoordinateFrame getCFrame();
void setCFrame(CoordinateFrame);
Box getBox();
@@ -38,7 +42,6 @@ public:
void setShape(Enum::Shape::Value shape);
bool canCollide;
bool anchored;
Vector3 rotVelocity;
bool collides(Box);
virtual std::vector<PROPGRIDITEM> getProperties();
virtual void PropUpdate(LPPROPGRIDITEM &pItem);
@@ -61,6 +64,8 @@ public:
private:
Vector3 position;
Vector3 size;
Vector3 velocity;
Vector3 rotVelocity;
float _bevelSize;
int _parseVert;
int _debugTimer;

View File

@@ -0,0 +1,139 @@
#include "ToggleImageButtonInstance.h"
ToggleImageButtonInstance::ToggleImageButtonInstance(G3D::TextureRef newImage,
G3D::TextureRef overImage,
G3D::TextureRef downImage,
G3D::TextureRef disableImage,
G3D::TextureRef newImage2,
G3D::TextureRef overImage2,
G3D::TextureRef downImage2,
G3D::TextureRef disableImage2) : ImageButtonInstance(newImage, overImage, downImage, disableImage)
{
image2 = newImage2;
openGLID2 = image2->getOpenGLID();
image_ovr2 = overImage2;
if(!image_ovr2.isNull())
openGLID2_ovr = image_ovr2->getOpenGLID();
image_dn2 = downImage2;
if(!image_dn2.isNull())
openGLID2_dn = image_dn2->getOpenGLID();
image_ds2 = disableImage2;
if(!image_ds2.isNull())
openGLID2_ds = image_ds2->getOpenGLID();
checked = false;
className = "ToggleImageButton";
}
ToggleImageButtonInstance::~ToggleImageButtonInstance(void)
{
//Delete everything on destruction
image2.~ReferenceCountedPointer();
delete image2.getPointer();
image_ovr2.~ReferenceCountedPointer();
delete image_ovr2.getPointer();
image_ds2.~ReferenceCountedPointer();
delete image_ds2.getPointer();
image_dn2.~ReferenceCountedPointer();
delete image_dn2.getPointer();
image = NULL;
image_ovr = NULL;
image_ds = NULL;
image_dn = NULL;
delete listener;
listener = NULL;
selected = false;
}
void ToggleImageButtonInstance::drawObj(RenderDevice* rd, Vector2 mousePos, bool mouseDown)
{
bool drawDisabledBox = false;
Vector2 positionRelative = position;
if(floatRight && floatBottom)
{
positionRelative = Vector2(rd->getWidth() + position.x, rd->getHeight() + position.y);
}
else if(floatBottom)
{
positionRelative = Vector2(position.x, rd->getHeight() + position.y);
}
else if(floatRight)
{
positionRelative = Vector2(rd->getWidth() + position.x, position.y);
}
int renderimage = openGLID;
if(checked)
{
renderimage = openGLID2;
if(selected == true && !image_dn2.isNull() && !disabled)
{
renderimage = openGLID2_dn;
}
else if(disabled)
{
if(!image_ds2.isNull())
renderimage = openGLID2_ds;
else
drawDisabledBox = true;
}
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
{
if(mouseDown && !image_dn2.isNull())
{
renderimage = openGLID2_dn;
}
else if(!image_ovr2.isNull())
{
renderimage = openGLID2_ovr;
}
}
}
else
{
if(selected == true && !image_dn.isNull() && !disabled)
{
renderimage = openGLID_dn;
}
else if(disabled)
{
if(!image_ds.isNull())
renderimage = openGLID_ds;
else
drawDisabledBox = true;
}
else if(mouseInArea(positionRelative.x, positionRelative.y, positionRelative.x + size.x, positionRelative.y + size.y, mousePos.x, mousePos.y))
{
if(mouseDown && !image_dn.isNull())
{
renderimage = openGLID_dn;
}
else if(!image_ovr.isNull())
{
renderimage = openGLID_ovr;
}
}
}
glEnable( GL_TEXTURE_2D );
glEnable(GL_BLEND);// you enable blending function
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture( GL_TEXTURE_2D, renderimage);
glBegin( GL_QUADS );
glTexCoord2d(0.0,0.0);
glVertex2f( positionRelative.x, positionRelative.y );
glTexCoord2d( 1.0,0.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y );
glTexCoord2d( 1.0,1.0 );
glVertex2f( positionRelative.x + size.x, positionRelative.y + size.y );
glTexCoord2d( 0.0,1.0 );
glVertex2f( positionRelative.x, positionRelative.y + size.y );
glEnd();
glDisable( GL_TEXTURE_2D );
if(drawDisabledBox)
{
Draw::box(Box(Vector3(positionRelative.x, positionRelative.y, 0), Vector3(positionRelative.x+size.x, positionRelative.y+size.y, 0)), rd, Color4(0.7F,0.7F,0.7F,0.3F), Color4::clear());
}
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "imagebuttoninstance.h"
class ToggleImageButtonInstance : public ImageButtonInstance
{
public:
//ImageButtonInstance(G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef);
//ImageButtonInstance(G3D::TextureRef,G3D::TextureRef,G3D::TextureRef);
ToggleImageButtonInstance(G3D::TextureRef newImage,G3D::TextureRef overImage = NULL,
G3D::TextureRef downImage = NULL,
G3D::TextureRef disableImage = NULL,
G3D::TextureRef newImage2 = NULL,
G3D::TextureRef overImage2 = NULL,
G3D::TextureRef downImage2 = NULL,
G3D::TextureRef disableImage2 = NULL);
~ToggleImageButtonInstance(void);
void drawObj(RenderDevice*, Vector2, bool);
bool checked;
G3D::TextureRef image2;
int openGLID2;
G3D::TextureRef image_ovr2;
int openGLID2_ovr;
G3D::TextureRef image_dn2;
int openGLID2_dn;
G3D::TextureRef image_ds2;
int openGLID2_ds;
};

View File

@@ -1,5 +1,6 @@
#pragma once
#include "GroupInstance.h"
#include "PartInstance.h"
class WorkspaceInstance :
public GroupInstance
@@ -7,4 +8,5 @@ class WorkspaceInstance :
public:
WorkspaceInstance(void);
~WorkspaceInstance(void);
std::vector<PartInstance *> partObjects;
};