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