Pan and tilt restored.
This commit is contained in:
@@ -39,6 +39,7 @@ void CameraController::lookAt(const Vector3& position) {
|
|||||||
|
|
||||||
void CameraController::setFrame(const CoordinateFrame& cf) {
|
void CameraController::setFrame(const CoordinateFrame& cf) {
|
||||||
Vector3 look = cf.getLookVector();
|
Vector3 look = cf.getLookVector();
|
||||||
|
g3dCamera.setCoordinateFrame(cf);
|
||||||
lookAt(cf.translation + look);
|
lookAt(cf.translation + look);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +71,13 @@ void CameraController::panLeft()
|
|||||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||||
float y = frame.translation.y;
|
float y = frame.translation.y;
|
||||||
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
||||||
Vector3 focus = frame.translation+frame.lookVector()*25;
|
Vector3 focus = Vector3(0,0,0); //frame.translation+frame.lookVector()*25;
|
||||||
//frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(-45),0);
|
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(-45),0);
|
||||||
frame2 = frame2 - frame2.lookVector()*25;
|
frame2 = frame2 - frame2.lookVector()*25;
|
||||||
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
||||||
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
||||||
newFrame.lookAt(focus);
|
newFrame.lookAt(focus,frame2.upVector());
|
||||||
setFrame(newFrame);
|
setFrame(CoordinateFrame(focus));
|
||||||
}
|
}
|
||||||
void CameraController::panRight()
|
void CameraController::panRight()
|
||||||
{
|
{
|
||||||
@@ -84,7 +85,7 @@ void CameraController::panRight()
|
|||||||
float y = frame.translation.y;
|
float y = frame.translation.y;
|
||||||
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
CoordinateFrame frame2 = CoordinateFrame(frame.rotation, frame.translation + frame.lookVector()*25);
|
||||||
Vector3 focus = frame.translation+frame.lookVector()*25;
|
Vector3 focus = frame.translation+frame.lookVector()*25;
|
||||||
//frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(45),0);
|
frame2 = frame2 * Matrix3::fromEulerAnglesXYZ(0,toRadians(45),0);
|
||||||
frame2 = frame2 - frame2.lookVector()*25;
|
frame2 = frame2 - frame2.lookVector()*25;
|
||||||
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
Vector3 cameraPos = Vector3(frame2.translation.x, y, frame2.translation.z);
|
||||||
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
CoordinateFrame newFrame = CoordinateFrame(frame2.rotation, Vector3(frame2.translation.x, y, frame2.translation.z));
|
||||||
@@ -94,7 +95,7 @@ void CameraController::panRight()
|
|||||||
|
|
||||||
void CameraController::tiltUp()
|
void CameraController::tiltUp()
|
||||||
{
|
{
|
||||||
//CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().rotation, g3dCamera.getCoordinateFrame().translation);
|
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().rotation, g3dCamera.getCoordinateFrame().translation);
|
||||||
Vector3 camerapoint = frame.translation;
|
Vector3 camerapoint = frame.translation;
|
||||||
|
|
||||||
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
Vector3 focalPoint = camerapoint + frame.lookVector() * 25;
|
||||||
@@ -105,12 +106,14 @@ void CameraController::tiltUp()
|
|||||||
|
|
||||||
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
CoordinateFrame newFrame = CoordinateFrame(camerapoint);
|
||||||
newFrame.lookAt(focalPoint);
|
newFrame.lookAt(focalPoint);
|
||||||
cameraPos = camerapoint;
|
Vector3 cameraPos = camerapoint;
|
||||||
frame = newFrame;
|
frame = newFrame;
|
||||||
|
setFrame(newFrame);
|
||||||
}
|
}
|
||||||
void CameraController::tiltDown()
|
void CameraController::tiltDown()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraController::centerCamera(Instance* selection)
|
void CameraController::centerCamera(Instance* selection)
|
||||||
{
|
{
|
||||||
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
CoordinateFrame frame = CoordinateFrame(g3dCamera.getCoordinateFrame().translation);
|
||||||
@@ -118,15 +121,14 @@ void CameraController::centerCamera(Instance* selection)
|
|||||||
lookAt(Vector3(0,0,0));
|
lookAt(Vector3(0,0,0));
|
||||||
else
|
else
|
||||||
lookAt(((PhysicalInstance*)selection)->getPosition()/2);
|
lookAt(((PhysicalInstance*)selection)->getPosition()/2);
|
||||||
//g3dCamera.setCoordinateFrame(frame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraController::update(Demo* demo)
|
void CameraController::update(Demo* demo)
|
||||||
{
|
{
|
||||||
|
float offsetSize = 0.05F;
|
||||||
|
|
||||||
Vector3 cameraPos = g3dCamera.getCoordinateFrame().translation;
|
Vector3 cameraPos = g3dCamera.getCoordinateFrame().translation;
|
||||||
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
CoordinateFrame frame = g3dCamera.getCoordinateFrame();
|
||||||
//CoordinateFrame cf = getCoordinateFrame();
|
|
||||||
|
|
||||||
if(GetHoldKeyState('U')) {
|
if(GetHoldKeyState('U')) {
|
||||||
forwards = true;
|
forwards = true;
|
||||||
@@ -140,7 +142,7 @@ void CameraController::update(Demo* demo)
|
|||||||
if(GetHoldKeyState('K')) {
|
if(GetHoldKeyState('K')) {
|
||||||
right = true;
|
right = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(forwards) {
|
if(forwards) {
|
||||||
forwards = false;
|
forwards = false;
|
||||||
frame.translation += frame.lookVector()*moveRate;
|
frame.translation += frame.lookVector()*moveRate;
|
||||||
@@ -167,7 +169,6 @@ void CameraController::update(Demo* demo)
|
|||||||
pitch+=(mouse.y-oldDesktopMouse.y)/100.f;
|
pitch+=(mouse.y-oldDesktopMouse.y)/100.f;
|
||||||
|
|
||||||
SetCursorPos(oldDesktopMouse.x,oldDesktopMouse.y);
|
SetCursorPos(oldDesktopMouse.x,oldDesktopMouse.y);
|
||||||
//frame.translation=cameraPos;
|
|
||||||
frame.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
|
frame.rotation = Matrix3::fromEulerAnglesZYX(0, -yaw, -pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,10 +33,6 @@ class CameraController {
|
|||||||
bool left;
|
bool left;
|
||||||
bool right;
|
bool right;
|
||||||
bool rightButtonHolding;
|
bool rightButtonHolding;
|
||||||
//bool centerCam;
|
|
||||||
//bool panRight;
|
|
||||||
//bool panLeft;
|
|
||||||
//bool tiltUp;
|
|
||||||
POINT oldDesktopMouse;
|
POINT oldDesktopMouse;
|
||||||
GCamera g3dCamera;
|
GCamera g3dCamera;
|
||||||
std::string cameraSound;
|
std::string cameraSound;
|
||||||
|
|||||||
1
Demo.h
1
Demo.h
@@ -25,7 +25,6 @@ class Demo : public GApp {
|
|||||||
void onMouseRightUp(int x, int y);
|
void onMouseRightUp(int x, int y);
|
||||||
void onMouseMoved(int x, int y);
|
void onMouseMoved(int x, int y);
|
||||||
void onMouseWheel(int x, int y, short delta);
|
void onMouseWheel(int x, int y, short delta);
|
||||||
//GCamera g3dCamera;
|
|
||||||
CameraController cameraController;
|
CameraController cameraController;
|
||||||
private:
|
private:
|
||||||
void initGUI();
|
void initGUI();
|
||||||
|
|||||||
12
main.cpp
12
main.cpp
@@ -25,8 +25,9 @@
|
|||||||
#include "AudioPlayer.h"
|
#include "AudioPlayer.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Demo.h"
|
#include "Demo.h"
|
||||||
|
#include "win32Defines.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if G3D_VER < 61000
|
#if G3D_VER < 61000
|
||||||
@@ -788,10 +789,6 @@ void Demo::onSimulation(RealTime rdt, SimTime sdt, SimTime idt) {
|
|||||||
return ::atof(version.c_str());
|
return ::atof(version.c_str());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
short GetHoldKeyState(int key)
|
|
||||||
{
|
|
||||||
return GetKeyState(key) >> 1;
|
|
||||||
}
|
|
||||||
bool IsHolding(int button)
|
bool IsHolding(int button)
|
||||||
{
|
{
|
||||||
return (GetKeyState(button) >> 1)>0;
|
return (GetKeyState(button) >> 1)>0;
|
||||||
@@ -1049,8 +1046,9 @@ void Demo::onGraphics(RenderDevice* rd) {
|
|||||||
|
|
||||||
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
renderDevice->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
|
||||||
renderDevice->setAmbientLightColor(lighting.ambient);
|
renderDevice->setAmbientLightColor(lighting.ambient);
|
||||||
|
|
||||||
|
Draw::box(Box(Vector3(-0.25, -0.25, -0.25), Vector3(0.25, 0.25, 0.25)), renderDevice, Color4(1,1,1,1), Color4::clear());
|
||||||
|
|
||||||
dataModel->getWorkspace()->render(rd);
|
dataModel->getWorkspace()->render(rd);
|
||||||
if(selectedInstance != NULL)
|
if(selectedInstance != NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user