Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/graphics/Camera.cpp
/* Copyright (C) 2010 Wildfire Games. | /* Copyright (C) 2017 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CCamera::LookAt(const CVector3D& camera, const CVector3D& target, const CVector3D& up) | void CCamera::LookAt(const CVector3D& camera, const CVector3D& target, const CVector3D& up) | ||||
{ | { | ||||
CVector3D delta = target - camera; | CVector3D delta = target - camera; | ||||
LookAlong(camera, delta, up); | LookAlong(camera, delta, up); | ||||
} | } | ||||
void CCamera::LookAlong(CVector3D camera, CVector3D orientation, CVector3D up) | void CCamera::LookAlong(const CVector3D& camera, CVector3D orientation, CVector3D up) | ||||
{ | { | ||||
orientation.Normalize(); | orientation.Normalize(); | ||||
up.Normalize(); | up.Normalize(); | ||||
CVector3D s = orientation.Cross(up); | CVector3D s = orientation.Cross(up); | ||||
m_Orientation._11 = -s.X; m_Orientation._12 = up.X; m_Orientation._13 = orientation.X; m_Orientation._14 = camera.X; | m_Orientation._11 = -s.X; m_Orientation._12 = up.X; m_Orientation._13 = orientation.X; m_Orientation._14 = camera.X; | ||||
m_Orientation._21 = -s.Y; m_Orientation._22 = up.Y; m_Orientation._23 = orientation.Y; m_Orientation._24 = camera.Y; | m_Orientation._21 = -s.Y; m_Orientation._22 = up.Y; m_Orientation._23 = orientation.Y; m_Orientation._24 = camera.Y; | ||||
m_Orientation._31 = -s.Z; m_Orientation._32 = up.Z; m_Orientation._33 = orientation.Z; m_Orientation._34 = camera.Z; | m_Orientation._31 = -s.Z; m_Orientation._32 = up.Z; m_Orientation._33 = orientation.Z; m_Orientation._34 = camera.Z; | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator