UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
g_camera.cpp
Go to the documentation of this file.
1
4
5
/*
6
Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8
This program is free software; you can redistribute it and/or
9
modify it under the terms of the GNU General Public License
10
as published by the Free Software Foundation; either version 2
11
of the License, or (at your option) any later version.
12
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17
See the GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23
*/
24
25
#include "
g_local.h
"
26
#include "
g_spawn.h
"
27
#include "
g_utils.h
"
28
#include "
g_vis.h
"
29
30
static
bool
G_CameraUse
(
Edict
* self,
Edict
* activator)
31
{
32
if
(!activator || !
G_IsActor
(activator)) {
33
return
false
;
34
}
35
36
self->
toggleActive
();
37
38
return
false
;
39
}
40
41
static
bool
Destroy_Camera
(
Edict
* self)
42
{
43
G_SpawnParticle
(self->
origin
, self->
spawnflags
, self->
particle
);
44
G_FreeEdict
(self);
45
return
true
;
46
}
47
48
#define CAMERAMODEL(X, IDX) case X: ent->model = "models/objects/cameras/camera" STRINGIFY(IDX); break
49
50
void
G_InitCamera
(
Edict
* ent,
camera_type_t
cameraType,
float
angle,
bool
rotate)
51
{
52
switch
(cameraType) {
53
CAMERAMODEL
(
CAMERA_MOBILE
, 0);
54
CAMERAMODEL
(
CAMERA_STATIONARY
, 1);
55
default
:
56
gi
.DPrintf(
"unknown camera type given: %i\n"
, cameraType);
57
G_FreeEdict
(ent);
58
return
;
59
}
60
61
AABB
modelAabb;
62
if
(
gi
.LoadModelAABB(ent->
model
, 0, modelAabb)) {
63
ent->
entBox
.
set
(modelAabb);
64
65
ent->
camera
.
cameraType
= cameraType;
66
ent->
camera
.
rotate
= rotate;
67
ent->
classname
=
"misc_camera"
;
68
ent->
type
=
ET_CAMERA
;
69
ent->
solid
=
SOLID_BBOX
;
70
ent->
flags
|=
FL_DESTROYABLE
;
71
ent->
material
=
MAT_ELECTRICAL
;
72
ent->
fieldSize
=
ACTOR_SIZE_NORMAL
;
73
ent->
destroy
=
Destroy_Camera
;
74
ent->
use
=
G_CameraUse
;
75
ent->
dir
=
AngleToDir
(angle);
76
77
/* Set the position of the entity */
78
VecToPos
(ent->
origin
, ent->
pos
);
79
80
gi
.LinkEdict(ent);
81
}
else
{
82
gi
.DPrintf(
"Could not get bounding box for model '%s'\n"
, ent->
model
);
83
G_FreeEdict
(ent);
84
}
85
}
AABB
Definition
aabb.h:42
AABB::set
void set(const AABB &other)
Copies the values from the given aabb.
Definition
aabb.h:60
Edict
Definition
g_edict.h:45
Edict::flags
int flags
Definition
g_edict.h:169
Edict::camera
camera_edict_data_t camera
Definition
g_edict.h:134
Edict::classname
const char * classname
Definition
g_edict.h:67
Edict::origin
vec3_t origin
Definition
g_edict.h:53
Edict::particle
const char * particle
Definition
g_edict.h:128
Edict::pos
pos3_t pos
Definition
g_edict.h:55
Edict::fieldSize
actorSizeEnum_t fieldSize
Definition
g_edict.h:141
Edict::dir
byte dir
Definition
g_edict.h:86
Edict::use
bool(* use)(Edict *self, Edict *activator)
Definition
g_edict.h:154
Edict::entBox
AABB entBox
Definition
g_edict.h:60
Edict::destroy
bool(* destroy)(Edict *self)
Definition
g_edict.h:155
Edict::spawnflags
int spawnflags
Definition
g_edict.h:118
Edict::solid
solid_t solid
Definition
g_edict.h:58
Edict::type
entity_type_t type
Definition
g_edict.h:81
Edict::toggleActive
void toggleActive()
Definition
g_edict.h:201
Edict::material
edictMaterial_t material
Definition
g_edict.h:133
Edict::model
const char * model
Definition
g_edict.h:74
ACTOR_SIZE_NORMAL
#define ACTOR_SIZE_NORMAL
Definition
defines.h:302
Destroy_Camera
static bool Destroy_Camera(Edict *self)
Definition
g_camera.cpp:41
G_CameraUse
static bool G_CameraUse(Edict *self, Edict *activator)
Definition
g_camera.cpp:30
G_InitCamera
void G_InitCamera(Edict *ent, camera_type_t cameraType, float angle, bool rotate)
Definition
g_camera.cpp:50
CAMERAMODEL
#define CAMERAMODEL(X, IDX)
Definition
g_camera.cpp:48
g_local.h
Local definitions for game module.
G_IsActor
#define G_IsActor(ent)
Definition
g_local.h:127
gi
game_import_t gi
Definition
g_main.cpp:39
MAT_ELECTRICAL
@ MAT_ELECTRICAL
Definition
g_local.h:270
FL_DESTROYABLE
#define FL_DESTROYABLE
If an edict is destroyable (like ET_BREAKABLE, ET_DOOR [if health set] or maybe a ET_MISSION [if heal...
Definition
g_local.h:289
G_SpawnParticle
Edict * G_SpawnParticle(const vec3_t origin, int spawnflags, const char *particle)
Definition
g_spawn.cpp:551
g_spawn.h
Brings new objects into the world.
G_FreeEdict
void G_FreeEdict(Edict *ent)
Marks the edict as free.
Definition
g_utils.cpp:41
g_utils.h
Misc utility functions for game module.
g_vis.h
SOLID_BBOX
@ SOLID_BBOX
Definition
game.h:156
AngleToDir
int AngleToDir(int angle)
Returns the index of array directionAngles[DIRECTIONS] whose value is the closest to angle.
Definition
mathlib.cpp:130
VecToPos
#define VecToPos(v, p)
Map boundary is +/- MAX_WORLD_WIDTH - to get into the positive area we add the possible max negative ...
Definition
mathlib.h:100
camera_type_t
camera_type_t
Definition
q_shared.h:178
CAMERA_STATIONARY
@ CAMERA_STATIONARY
Definition
q_shared.h:180
CAMERA_MOBILE
@ CAMERA_MOBILE
Definition
q_shared.h:179
ET_CAMERA
@ ET_CAMERA
Definition
q_shared.h:171
camera_edict_data_t::rotate
bool rotate
Definition
g_local.h:318
camera_edict_data_t::cameraType
camera_type_t cameraType
Definition
g_local.h:317
src
game
g_camera.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0