"Delete" key also deletes
This commit is contained in:
@@ -8,6 +8,8 @@ Vector3 velocity;
|
|||||||
Vector3 rotVelocity;
|
Vector3 rotVelocity;
|
||||||
CoordinateFrame cFrame;
|
CoordinateFrame cFrame;
|
||||||
Color3 color;
|
Color3 color;
|
||||||
|
bool changed = true;
|
||||||
|
Box itemBox = Box();
|
||||||
|
|
||||||
PhysicalInstance::PhysicalInstance(void)
|
PhysicalInstance::PhysicalInstance(void)
|
||||||
{
|
{
|
||||||
@@ -31,6 +33,7 @@ void PhysicalInstance::setPosition(Vector3 pos)
|
|||||||
{
|
{
|
||||||
position = pos;
|
position = pos;
|
||||||
cFrame = CoordinateFrame(pos);
|
cFrame = CoordinateFrame(pos);
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
CoordinateFrame PhysicalInstance::getCFrame()
|
CoordinateFrame PhysicalInstance::getCFrame()
|
||||||
{
|
{
|
||||||
@@ -40,6 +43,7 @@ void PhysicalInstance::setCFrame(CoordinateFrame coordinateFrame)
|
|||||||
{
|
{
|
||||||
cFrame = coordinateFrame;
|
cFrame = coordinateFrame;
|
||||||
position = coordinateFrame.translation;
|
position = coordinateFrame.translation;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
||||||
@@ -49,9 +53,13 @@ CoordinateFrame PhysicalInstance::getCFrameRenderBased()
|
|||||||
|
|
||||||
Box PhysicalInstance::getBox()
|
Box PhysicalInstance::getBox()
|
||||||
{
|
{
|
||||||
|
if(changed)
|
||||||
|
{
|
||||||
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
Box box = Box(Vector3(0+size.x/4, 0+size.y/4, 0+size.z/4) ,Vector3(0-size.x/4,0-size.y/4,0-size.z/4));
|
||||||
CoordinateFrame c = getCFrameRenderBased();
|
CoordinateFrame c = getCFrameRenderBased();
|
||||||
return c.toWorldSpace(box);
|
itemBox = c.toWorldSpace(box);
|
||||||
|
}
|
||||||
|
return itemBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalInstance::~PhysicalInstance(void)
|
PhysicalInstance::~PhysicalInstance(void)
|
||||||
|
|||||||
33
main.cpp
33
main.cpp
@@ -283,15 +283,9 @@ void GUDButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteListener : public ButtonListener {
|
|
||||||
public:
|
|
||||||
void onButton1MouseClick(BaseButtonInstance*);
|
|
||||||
};
|
|
||||||
|
|
||||||
void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
|
void deleteInstance()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(selectedInstance != NULL)
|
if(selectedInstance != NULL)
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < instances.size(); i++)
|
for(size_t i = 0; i < instances.size(); i++)
|
||||||
@@ -303,19 +297,31 @@ void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
|
|||||||
delete deleting;
|
delete deleting;
|
||||||
selectedInstance = NULL;
|
selectedInstance = NULL;
|
||||||
AudioPlayer::PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
|
AudioPlayer::PlaySound(GetFileInPath("/content/sounds/pageturn.wav"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class DeleteListener : public ButtonListener {
|
||||||
|
public:
|
||||||
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void DeleteListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
|
{
|
||||||
|
deleteInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ModeSelectionListener : public ButtonListener {
|
class ModeSelectionListener : public ButtonListener {
|
||||||
public:
|
public:
|
||||||
void onButton1MouseClick(BaseButtonInstance*);
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
void ModeSelectionListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
||||||
@@ -953,6 +959,11 @@ void Demo::onUserInput(UserInput* ui) {
|
|||||||
cameraPos = cameraPos - frame.lookVector()*2;
|
cameraPos = cameraPos - frame.lookVector()*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ui->keyPressed(SDLK_DELETE))
|
||||||
|
{
|
||||||
|
deleteInstance();
|
||||||
|
}
|
||||||
|
|
||||||
if(ui->keyDown(SDLK_LCTRL))
|
if(ui->keyDown(SDLK_LCTRL))
|
||||||
{
|
{
|
||||||
if(ui->keyPressed('d'))
|
if(ui->keyPressed('d'))
|
||||||
@@ -1207,7 +1218,6 @@ void makeBeveledBox(Box box, RenderDevice* rd, Color4 color, CoordinateFrame cFr
|
|||||||
|
|
||||||
|
|
||||||
void Demo::onGraphics(RenderDevice* rd) {
|
void Demo::onGraphics(RenderDevice* rd) {
|
||||||
|
|
||||||
Vector2 mousepos = Vector2(0,0);
|
Vector2 mousepos = Vector2(0,0);
|
||||||
G3D::uint8 num = 0;
|
G3D::uint8 num = 0;
|
||||||
rd->window()->getRelativeMouseState(mousepos, num);
|
rd->window()->getRelativeMouseState(mousepos, num);
|
||||||
@@ -1264,6 +1274,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
Instance* instance = instances.at(i);
|
Instance* instance = instances.at(i);
|
||||||
if(instance->className == "Part" && instance->parent != NULL)
|
if(instance->className == "Part" && instance->parent != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
PhysicalInstance* part = (PhysicalInstance*)instance;
|
PhysicalInstance* part = (PhysicalInstance*)instance;
|
||||||
Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
Draw::box(part->getBox(), app->renderDevice, part->color, Color4::clear());
|
||||||
if(selectedInstance == part)
|
if(selectedInstance == part)
|
||||||
|
|||||||
Reference in New Issue
Block a user