Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
|
#include "gfxlib.h"
#include "gfx/vec.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include "gl_matrix.h"
#include "vs_globals.h"
Go to the source code of this file.
Macros | |
#define | M(row, col) rotview[col*4+row] |
#define | M(row, col) m[col*4+row] |
#define | M(row, col) i[col*4+row] |
#define | M(row, col) m[col*4+row] |
#define | M(row, col) m[col*4+row] |
#define | M(row, col) tm[col*4+row] |
Functions | |
void | Zero (float matrix[]) |
void | Identity (float matrix[]) |
float | Magnitude (Vector v) |
float | DotProduct (Vector &a, Vector &b) |
void | MultMatrix (float dest[], const float m1[], const float m2[]) |
void | CopyMatrix (Matrix dest, const Matrix source) |
void | evaluateViews () |
void | getInverseProjection (float *&inv) |
float | GFXGetZPerspective (const float z) |
Given the current projection matrix, how much will the model be divided by. More... | |
float | GFXGetXInvPerspective () |
Screen to eye. More... | |
float | GFXGetYInvPerspective () |
void | GFXTranslate (const MATRIXMODE mode, const Vector &a) |
void | GFXMultMatrix (const MATRIXMODE mode, const Matrix matrix) |
void | GFXLoadMatrix (const MATRIXMODE mode, const Matrix matrix) |
void | GFXViewPort (int minx, int miny, int maxx, int maxy) |
Sets the final translation to screen coordinates, Also adjusts range of clearing. More... | |
void | GFXHudMode (const bool Enter) |
void | GFXLoadIdentity (const MATRIXMODE mode) |
Loads the identity matrix for the given mode. More... | |
void | GFXGetMatrix (const MATRIXMODE mode, Matrix matrix) |
static void | gl_Frustum (float left, float right, float bottom, float top, float nearval, float farval) |
void | GFXGetFrustumVars (bool retr, float *l, float *r, float *b, float *t, float *n, float *f) |
Saves and restores last used left,right,bot,top,near,far vals (internal use) More... | |
void | GFXFrustum (float *m, float *i, float left, float right, float bottom, float top, float nearval, float farval) |
Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates. More... | |
void | GFXPerspective (float fov, float aspect, float znear, float zfar, float cockpit_offset) |
Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes. More... | |
void | GFXParallel (float left, float right, float bottom, float top, float nearval, float farval) |
Sets the Projection matrix to a parallel view with given paramters. More... | |
static void | LookAtHelper (float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) |
void | GFXLookAt (Vector eye, Vector center, Vector up) |
float | GFXSphereInFrustum (const Vector &Cnt, float radius) |
float | GFXSphereInFrustum (float f[6][4], const Vector &Cnt, float radius) |
void | GFXGetFrustum (float f[6][4]) |
void | GFXCalculateFrustum () |
Calculates frustum matrix (internal use) More... | |
void | GFXCalculateFrustum (float frustum[6][4], float *modl, float *proj) |
Variables | |
float | centerx |
float | centery |
float | centerz |
Vector | eye |
Vector | center |
Vector | up |
float | frust [6][4] |
#define M | ( | row, | |
col | |||
) | rotview[col*4+row] |
#define M | ( | row, | |
col | |||
) | m[col*4+row] |
#define M | ( | row, | |
col | |||
) | i[col*4+row] |
#define M | ( | row, | |
col | |||
) | m[col*4+row] |
#define M | ( | row, | |
col | |||
) | m[col*4+row] |
#define M | ( | row, | |
col | |||
) | tm[col*4+row] |
Definition at line 134 of file gl_matrix_hack.cpp.
Definition at line 100 of file gl_matrix_hack.cpp.
Referenced by Camera::GetZDist(), ZoneMgr::isVisible(), linear_interpolate_uncapped(), and Quaternion::operator*().
void evaluateViews | ( | ) |
Definition at line 162 of file gl_matrix_hack.cpp.
References Identity(), GFXMatrices::rotview, and GFXMatrices::view.
Referenced by GFXLoadMatrix(), and GFXMultMatrix().
void getInverseProjection | ( | float *& | inv) |
Definition at line 185 of file gl_matrix_hack.cpp.
References GFXMatrices::invprojection.
void GFXCalculateFrustum | ( | ) |
Calculates frustum matrix (internal use)
Definition at line 725 of file gl_matrix_hack.cpp.
References frust, GFXCalculateFrustum(), GFXMatrices::projection, and GFXMatrices::view.
Referenced by GFXBoxInFrustumModel(), GFXCalculateFrustum(), ClickList::requestIterator(), and Camera::UpdateGFX().
Definition at line 730 of file gl_matrix_hack.cpp.
void GFXFrustum | ( | float * | m, |
float * | i, | ||
float | left, | ||
float | right, | ||
float | bottom, | ||
float | top, | ||
float | nearval, | ||
float | farval | ||
) |
Given matrices, calculates the matrix and inverse matrix of a projection matrix to go from screen to 3-space coordinates.
Definition at line 449 of file gl_matrix_hack.cpp.
References a, b, c, d, float, M, x, and y.
Referenced by gl_Frustum(), and ClickList::requestIterator().
void GFXGetFrustum | ( | float | f[6][4]) |
void GFXGetFrustumVars | ( | bool | retr, |
float * | l, | ||
float * | r, | ||
float * | b, | ||
float * | t, | ||
float * | n, | ||
float * | f | ||
) |
Saves and restores last used left,right,bot,top,near,far vals (internal use)
Definition at line 428 of file gl_matrix_hack.cpp.
References b.
Referenced by GFXBeginPick(), GFXDeviceToEye(), GFXGetZPerspective(), GFXParallel(), gl_Frustum(), ClickList::requestIterator(), and CoordinateSelect::UpdateMouse().
void GFXGetMatrix | ( | const MATRIXMODE | mode, |
Matrix | matrix | ||
) |
Definition at line 400 of file gl_matrix_hack.cpp.
References centerx, centery, centerz, CopyMatrix(), Identity(), MODEL, MultMatrix(), GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, and VIEW.
float GFXGetXInvPerspective | ( | ) |
Screen to eye.
Definition at line 218 of file gl_matrix_hack.cpp.
References GFXMatrices::invprojection.
Referenced by LocationSelect::Draw().
float GFXGetYInvPerspective | ( | ) |
Definition at line 223 of file gl_matrix_hack.cpp.
References GFXMatrices::invprojection.
Referenced by LocationSelect::Draw().
Given the current projection matrix, how much will the model be divided by.
GFXGetXPerspective () returns the number that x/z is multiplied by to land a pixel on the screen. | xs 0 a 0 |[x] [xs + az] [1/xs 0 0 a/xs][x] [x/xs+ aw/xs] | 0 ys b 0 |[y] = [ys + bz] ^-1 [ 0 1/ys 0 b/ys][y] = [y/ys+ bw/ys] | 0 0 c d |[z] [cz + dw] [ 0 0 0 -1 ][z] [0 ] | 0 0 -1 0 |[w] [-z ] [ 0 0 1/d c/d ][w] [z/d + cw/d ] therefore return 1/(xs *d) and 1/(ys * d) I'm not good with matrix math...tell me if I should ret 1/xs+c/d instead for test cases I can think of, it doesn't matter—
Definition at line 200 of file gl_matrix_hack.cpp.
References a, and GFXGetFrustumVars().
Referenced by perspectiveFactor().
void GFXHudMode | ( | const bool | Enter) |
Hud Mode saves the current matrices and sets projection and view matrices to identity. Caution: use of other matrix functions in HudMode could alter state.
Definition at line 353 of file gl_matrix_hack.cpp.
Referenced by bootstrap_draw(), WindowManager::draw(), GameCockpit::Draw(), BaseInterface::Room::BaseShip::Draw(), NavigationSystem::Draw(), EndGUIFrame(), and StartGUIFrame().
void GFXLoadIdentity | ( | const MATRIXMODE | mode) |
Loads the identity matrix for the given mode.
Definition at line 370 of file gl_matrix_hack.cpp.
References Identity(), GFXMatrices::model, MODEL, GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, GFXMatrices::view, and VIEW.
Referenced by bootstrap_draw(), CoordinateSelect::Draw(), LocationSelect::Draw(), GamePlanet::Draw(), Stars::Draw(), GameCockpit::Draw(), ParticleTrail::DrawAndUpdate(), Mesh::DrawNow(), GamePlanet::DrawTerrain(), GFXBeginScene(), GFXCenterCamera(), GFXUploadLightState(), Halo::ProcessDrawQueue(), Camera::UpdateGFX(), and Camera::UpdateGLCenter().
void GFXLoadMatrix | ( | const MATRIXMODE | mode, |
const Matrix | matrix | ||
) |
Definition at line 303 of file gl_matrix_hack.cpp.
References centerx, centery, centerz, CopyMatrix(), evaluateViews(), GFXMatrices::model, MODEL, MultMatrix(), GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, GFXMatrices::view, and VIEW.
Referenced by GFXLookAt(), and GFXParallel().
Definition at line 686 of file gl_matrix_hack.cpp.
References centerx, centery, centerz, GFXLoadMatrix(), LookAtHelper(), GFXMatrices::view, and VIEW.
void GFXMultMatrix | ( | const MATRIXMODE | mode, |
const Matrix | matrix | ||
) |
Definition at line 264 of file gl_matrix_hack.cpp.
References CopyMatrix(), evaluateViews(), GFXMatrices::model, MODEL, MultMatrix(), GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, GFXMatrices::view, and VIEW.
Sets the Projection matrix to a parallel view with given paramters.
Definition at line 516 of file gl_matrix_hack.cpp.
References GFXGetFrustumVars(), GFXLoadMatrix(), M, GFXMatrices::projection, PROJECTION, x, y, and z.
Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().
Sets the Projection matrix to have fov and aspect as follows (fov is field of view in radians, aspect is width/height znear and zfar are clip planes.
Definition at line 502 of file gl_matrix_hack.cpp.
References gl_Frustum(), M_PI, and GFXMatrices::projection.
Referenced by Camera::UpdateGFX(), and Camera::UpdateGLCenter().
Definition at line 702 of file gl_matrix_hack.cpp.
References frust, and GFXSphereInFrustum().
void GFXTranslate | ( | const MATRIXMODE | mode, |
const Vector & | a | ||
) |
Definition at line 228 of file gl_matrix_hack.cpp.
References GFXMatrices::model, MODEL, MultMatrix(), GFXMatrices::projection, PROJECTION, GFXMatrices::rotview, GFXMatrices::view, and VIEW.
Sets the final translation to screen coordinates, Also adjusts range of clearing.
Definition at line 348 of file gl_matrix_hack.cpp.
Referenced by GameCockpit::SetupViewPort().
|
static |
Definition at line 422 of file gl_matrix_hack.cpp.
References GFXFrustum(), GFXGetFrustumVars(), GFXMatrices::invprojection, and GFXMatrices::projection.
Referenced by GFXPerspective().
|
inline |
Definition at line 66 of file gl_matrix_hack.cpp.
|
static |
Definition at line 547 of file gl_matrix_hack.cpp.
References centerx, centery, centerz, GFXActiveTexture(), M, MultMatrix(), Vector, GFXMatrices::view, x, y, z, and ZeroMemory().
Referenced by GFXLookAt().
Definition at line 89 of file gl_matrix_hack.cpp.
Referenced by AllUnitsCloseAndEngage(), MissileEffect::ApplyDamage(), GameCockpit::Autopilot(), Unit::AutoPilotToErrorMessage(), Bolt::Bolt(), SphericalTransform::BoxInFrustum(), calculatenormscale(), ChooseNearNavPoint(), Beam::Collide(), DistanceTwoTargets(), dockingdistance(), WarpTrail::Draw(), GameStarSystem::Draw(), Animation::Draw(), GameUnit< UnitType >::Draw(), GameUnit< UnitType >::DrawNow(), DrawOneTargetBox(), Briefing::Ship::EnqueueOrder(), EstimateGain(), PlanetaryOrbit::Execute(), Orders::FaceDirection::Execute(), anonymous_namespace{autodocking.cpp}::FindDockingPort(), findObjectsFromPosition(), Mesh::Fork(), getAtmospheric(), UnitUtil::getDistance(), getNearestTarget(), getNearestTargetUnit(), CommunicatingAI::GetRandomUnit(), GetThreat(), GFXCircle(), Unit::InRange(), Unit::InsideCollideTree(), GameCockpit::LookupUnitStat(), FlyByWire::MatchSpeed(), Orders::DockingOps::Movement(), Mesh::PostProcessLoading(), Animation::ProcessDrawQueue(), Unit::querySphereNoRecurse(), Unit::rayCollide(), UniverseUtil::SafeStarSystemEntrancePoint(), Point::SetLength(), GameUnit< UnitType >::TransferUnitToSystem(), Cockpit::Update(), GameMissile::UpdatePhysics2(), Missile::UpdatePhysics2(), WarpPursuit(), and WarpToP().
Definition at line 105 of file gl_matrix_hack.cpp.
|
inline |
Definition at line 43 of file gl_matrix_hack.cpp.
Vector center |
Definition at line 183 of file gl_matrix_hack.cpp.
Referenced by StarSystemGent::beginStar(), ScrollerButton::draw(), Radar::SphereDisplay::DrawBackground(), Radar::BubbleDisplay::DrawBackground(), DrawOneTargetBox(), Radar::PlaneDisplay::DrawTrack(), StarSystemGent::MakeBigUnit(), StarSystemGent::MakeJump(), StarSystemGent::MakePlanet(), StarSystemGent::MakeSmallUnit(), OPC_PointAABBSqrDist(), UnitUtil::orbit(), Sphere::Set(), Sphere::SetCenter(), csBox3::SetSize(), SqrDistance(), and AABBCollider::TriBoxOverlap().
float centerx |
Definition at line 161 of file gl_matrix_hack.cpp.
Referenced by GFXGetMatrix(), GFXLoadMatrix(), GFXLookAt(), and LookAtHelper().
float centery |
Definition at line 161 of file gl_matrix_hack.cpp.
Referenced by GFXGetMatrix(), GFXLoadMatrix(), GFXLookAt(), and LookAtHelper().
float centerz |
Definition at line 161 of file gl_matrix_hack.cpp.
Referenced by GFXGetMatrix(), GFXLoadMatrix(), GFXLookAt(), and LookAtHelper().
Vector eye |
Definition at line 183 of file gl_matrix_hack.cpp.
float frust[6][4] |
Definition at line 700 of file gl_matrix_hack.cpp.
Vector up |
Definition at line 183 of file gl_matrix_hack.cpp.
Referenced by aim_assist_debug(), NavComputer::constructControls(), ContinuousTerrain::ContinuousTerrain(), Scroller::createControls(), Gauge::Gauge(), Camera::LookDirection(), Orders::DockingOps::PerformDockingOperations(), Audio::Listener::setOrientation(), TargUn(), and Audio::OpenALRenderableListener::updateImpl().