Changed some images, Added camera button listeners
|
Before Width: | Height: | Size: 599 B After Width: | Height: | Size: 576 B |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 792 B |
42
main.cpp
@@ -54,6 +54,7 @@ static bool forwards = false;
|
|||||||
static bool backwards = false;
|
static bool backwards = false;
|
||||||
static bool left = false;
|
static bool left = false;
|
||||||
static bool right = false;
|
static bool right = false;
|
||||||
|
static bool centerCam = false;
|
||||||
static const int CURSOR = 0;
|
static const int CURSOR = 0;
|
||||||
static const int ARROWS = 1;
|
static const int ARROWS = 1;
|
||||||
static const int RESIZE = 2;
|
static const int RESIZE = 2;
|
||||||
@@ -233,16 +234,20 @@ ImageButtonInstance* makeImageButton(G3D::TextureRef newImage = NULL, G3D::Textu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ForwardButtonListener : public ButtonListener {
|
class CameraButtonListener : public ButtonListener {
|
||||||
public:
|
public:
|
||||||
void onButton1MouseClick(BaseButtonInstance*);
|
void onButton1MouseClick(BaseButtonInstance*);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ForwardButtonListener::onButton1MouseClick(BaseButtonInstance*)
|
void CameraButtonListener::onButton1MouseClick(BaseButtonInstance* button)
|
||||||
{
|
{
|
||||||
|
CoordinateFrame frame = usableApp->debugCamera.getCoordinateFrame();
|
||||||
CoordinateFrame frame = usableApp->renderDevice->getCameraToWorldMatrix();
|
if(button->name == "CenterCam")
|
||||||
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.lookVector()*2;
|
centerCam = true;
|
||||||
|
else if(button->name == "ZoomIn")
|
||||||
|
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.lookVector()*2;
|
||||||
|
else if(button->name == "ZoomOut")
|
||||||
|
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) - frame.lookVector()*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -451,7 +456,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-77, -90);
|
instance->position = Vector2(-77, -90);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
instance->setButtonListener(new ForwardButtonListener());
|
instance->name = "ZoomIn";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraZoomOut.png")),
|
||||||
@@ -462,6 +468,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-77, -31);
|
instance->position = Vector2(-77, -31);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "ZoomOut";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraPanLeft.png")),
|
||||||
@@ -472,6 +480,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-110, -50);
|
instance->position = Vector2(-110, -50);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "PanLeft";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraPanRight.png")),
|
||||||
@@ -482,6 +492,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-45, -50);
|
instance->position = Vector2(-45, -50);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "PanRight";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraCenter.png")),
|
||||||
@@ -492,6 +504,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-77, -60);
|
instance->position = Vector2(-77, -60);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "CenterCam";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraTiltUp.png")),
|
||||||
@@ -502,6 +516,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-105, -75);
|
instance->position = Vector2(-105, -75);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "TiltUp";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
|
|
||||||
instance = makeImageButton(
|
instance = makeImageButton(
|
||||||
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
|
Texture::fromFile(GetFileInPath("/content/images/CameraTiltDown.png")),
|
||||||
@@ -512,6 +528,8 @@ void initGUI()
|
|||||||
instance->floatRight = true;
|
instance->floatRight = true;
|
||||||
instance->position = Vector2(-40, -75);
|
instance->position = Vector2(-40, -75);
|
||||||
instance->parent = dataModel;
|
instance->parent = dataModel;
|
||||||
|
instance->name = "TiltDown";
|
||||||
|
instance->setButtonListener(new CameraButtonListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -679,6 +697,17 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.rightVector()*moveRate;
|
cameraPos = Vector3(cameraPos.x, cameraPos.y, cameraPos.z) + frame.rightVector()*moveRate;
|
||||||
}
|
}
|
||||||
app->debugCamera.setPosition(cameraPos);
|
app->debugCamera.setPosition(cameraPos);
|
||||||
|
if(centerCam)
|
||||||
|
{
|
||||||
|
CoordinateFrame frame = CoordinateFrame(app->debugCamera.getCoordinateFrame().translation);
|
||||||
|
if(selectedInstance == NULL)
|
||||||
|
frame.lookAt(Vector3(0,0,0));
|
||||||
|
else
|
||||||
|
frame.lookAt(((PhysicalInstance*)selectedInstance)->getPosition());
|
||||||
|
app->debugController.setCoordinateFrame(frame);
|
||||||
|
centerCam = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -989,6 +1018,7 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Cyan background
|
// Cyan background
|
||||||
app->renderDevice->setColorClearValue(Color3(0.0f, 0.5f, 1.0f));
|
app->renderDevice->setColorClearValue(Color3(0.0f, 0.5f, 1.0f));
|
||||||
|
|
||||||
|
|||||||