Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
geom.c File Reference

Ship velocity limits, vector arithmetic and orientation geometry. More...

#include "game.h"

Go to the source code of this file.

Functions

short get_ship_max_velocity (short obj)
void recalc_max_velocity (short ship)
void drain_fuel (short ship, short amount)
void damage_ion_drive (short ship, short amount, short maximum)
int GetShipAccelerationRate (short ship)
void point_at (short obj, FixedVector point)
void look_at (short obj)
void position_relative (FixedVector *position, FixedVector direction, short distance)
void position_relative_ijk (FixedVector *position, short obj, short right, short up, short forward)
short FixedToShortSaturating (int value)
int MinInt (int a, int b)
int MaxInt (int a, int b)
int AbsInt (int v)
unsigned int SignFixed (int v)
short WrapDegrees (short degrees)
short equ_vector (const FixedVector *left, const FixedVector *right)
void negate_vector (FixedVector *vector)
short IsPairEqualityDifferentFromFlag (const unsigned int *values)
void zero_vector (FixedVector *vector)
void AddFixedVectors (const FixedVector *left, const FixedVector *right, FixedVector *sum)
void SubtractFixedVectors (FixedVector *left, FixedVector *right, FixedVector *difference)
void ComputeVectorDelta (FixedVector *from, FixedVector *to, FixedVector *delta)
void ScaleFixedVector (FixedVector *vector, int scale, FixedVector *result)
void divide_vector (FixedVector *vector, int divisor, FixedVector *result)
short ChooseRandomSignedMagnitude (short minimum, short maximum, short allowNegative)
void MakeRandomVectorFixed (short minimum, short maximum, FixedVector *vector)
void FillFixedVectorWithRandomComponents (short limit, FixedVector *vector)
void random_radial (const FixedVector *center, short radius, FixedVector *position)
void rectangular_to_spherical (const FixedVector *rectangular, SphericalVector *spherical)
void ConvertFixedVectorToShortVector (const FixedVector *source, ShortVector *destination)
int dot_product (const FixedVector *left, const FixedVector *right)
short vector_angle (FixedVector left, FixedVector right)
void vector_cross_product (const FixedVector *left, const FixedVector *right, FixedVector *product)
short NormalizeFixedVector (FixedVector *vector)
int vector_length_in_dir (const FixedVector *vector, const FixedVector *direction)
void vector_component_in_dir (const FixedVector *vector, const FixedVector *direction, FixedVector *component)
void transform_to_objects_frame (const FixedVector *source, FixedVector *destination, short obj)
void copy_frame (short source, short destination)
void rotate_about_i (short angle, FixedVector *j, FixedVector *k)
void rotate_about_j (short angle, FixedVector *i, FixedVector *k)
void rotate_about_k (short angle, FixedVector *i, FixedVector *j)
void init_ijk (short obj)
void fix_objects_ijk (short obj)
void alter_pitch (short angle, short obj)
void alter_yaw (short angle, short obj)
void alter_roll (short angle, short obj)
short distance_between_points (const FixedVector *from, const FixedVector *to)
short distance_from_point (short obj, const FixedVector *point)
short distance_from_object (short obj, short other)
void get_facing_range_from_point (short obj, const FixedVector *point)
void get_facing_range_from_object (short obj, short other)
short facing_to_object (short obj, FixedVector *point)
short match_roll_orientation (short obj, short reference)
short set_ship_rotation_goals (short obj, short turnRate, const FixedVector *direction, short pointingMode, short *yawGoal, short *pitchGoal)
void point_ship (short obj, short turnRate, const FixedVector *direction)
void point_ship_at_point (short obj, const FixedVector *point)
void point_ship_at_object (short obj, short other)
void point_capital_ship_at_object (short obj, short other)
void point_perpendicular_to_point (short obj, const FixedVector *point)
void point_ship_behind_object (short obj, short other)
void point_ship_below_object (short obj, short other)
void point_perpendicular (short obj, short other)
void point_parallel (short obj, short other)
void NormalizeAndScaleVector (FixedVector *vector, int scale)
void SetVectorFixedPoint (unsigned int *p, short v)
short IsPointWithinRange (FixedVector *from, FixedVector *to, short range)
short check_for_collision (short obj)
void remove_object (short obj)
void position_child (short parent, short weapon, FixedVector *position)
void child_object (short hardpoint, short child, short parent)
short get_ship_slot (void)
short find_vacant_3d_object (void)
void FreePacketAndClear (void *slot, unsigned short releaseFlags)
void apply_force_to_objects_center (FixedVector *force, short obj)
void apply_force_to_object (FixedVector *point, FixedVector *force, short obj)
void rotational_acceleration (FixedVector *point, FixedVector *force, short obj)
void ClampVectorTo30 (short *p)
void ClampTo30 (short *p)
void transform_objects_to_your_view (void)
void set_background_objects_rotation (short obj, FixedVector *direction)
void get_right_shape (short obj, FixedVector *direction)

Variables

int g_nFacingRangeQueryCount = 0
int g_anCloakVisibilityPattern [20]
int g_abObjectShapeOwned [SPACE_OBJECT_COUNT] = { 0 }
FixedVector g_2_vNormalizedToTgt
int g_nUnusedGeomWord [3]

Detailed Description

Ship velocity limits, vector arithmetic and orientation geometry.

Definition in file geom.c.

Function Documentation

◆ AbsInt()

int AbsInt ( int v)

Definition at line 151 of file geom.c.

References AbsInt().

Referenced by AbsInt(), and control_speed().

◆ AddFixedVectors()

◆ alter_pitch()

◆ alter_roll()

void alter_roll ( short angle,
short obj )

◆ alter_yaw()

◆ apply_force_to_object()

◆ apply_force_to_objects_center()

◆ check_for_collision()

◆ child_object()

void child_object ( short hardpoint,
short child,
short parent )

Definition at line 822 of file geom.c.

References child_object(), g_acObjectOwner, g_aShipPosition, and position_child().

Referenced by child_object(), and fire_weapon().

◆ ChooseRandomSignedMagnitude()

short ChooseRandomSignedMagnitude ( short minimum,
short maximum,
short allowNegative )

Definition at line 253 of file geom.c.

References ChooseRandomSignedMagnitude(), and RandomInRange().

Referenced by ChooseRandomSignedMagnitude(), and MakeRandomVectorFixed().

◆ ClampTo30()

void ClampTo30 ( short * p)

Definition at line 1011 of file geom.c.

References ClampTo30().

Referenced by apply_force_to_object(), ClampTo30(), and rotational_acceleration().

◆ ClampVectorTo30()

void ClampVectorTo30 ( short * p)

Definition at line 1001 of file geom.c.

References ClampVectorTo30().

Referenced by ClampVectorTo30(), and rotate_object().

◆ ComputeVectorDelta()

◆ ConvertFixedVectorToShortVector()

void ConvertFixedVectorToShortVector ( const FixedVector * source,
ShortVector * destination )

◆ copy_frame()

◆ damage_ion_drive()

void damage_ion_drive ( short ship,
short amount,
short maximum )

◆ distance_between_points()

short distance_between_points ( const FixedVector * from,
const FixedVector * to )

◆ distance_from_object()

◆ distance_from_point()

◆ divide_vector()

◆ dot_product()

◆ drain_fuel()

void drain_fuel ( short ship,
short amount )

◆ equ_vector()

◆ facing_to_object()

short facing_to_object ( short obj,
FixedVector * point )

◆ FillFixedVectorWithRandomComponents()

void FillFixedVectorWithRandomComponents ( short limit,
FixedVector * vector )

◆ find_vacant_3d_object()

◆ fix_objects_ijk()

◆ FixedToShortSaturating()

◆ FreePacketAndClear()

void FreePacketAndClear ( void * slot,
unsigned short releaseFlags )

Definition at line 45 of file disk.c.

◆ get_facing_range_from_object()

◆ get_facing_range_from_point()

◆ get_right_shape()

◆ get_ship_max_velocity()

◆ get_ship_slot()

short get_ship_slot ( void )

Definition at line 829 of file geom.c.

References g_aeObjectClass, get_ship_slot(), and OBJECT_CLASS_NULL.

Referenced by fire_weapon(), get_ship_slot(), and initialize_ship().

◆ GetShipAccelerationRate()

◆ init_ijk()

◆ IsPairEqualityDifferentFromFlag()

short IsPairEqualityDifferentFromFlag ( const unsigned int * values)

Definition at line 191 of file geom.c.

References IsPairEqualityDifferentFromFlag().

Referenced by IsPairEqualityDifferentFromFlag().

◆ IsPointWithinRange()

short IsPointWithinRange ( FixedVector * from,
FixedVector * to,
short range )

◆ look_at()

void look_at ( short obj)

Definition at line 95 of file geom.c.

References EYE_OBJECT, g_aShipPosition, look_at(), and point_at().

Referenced by look_at(), new_view(), and set_eye_direction_and_position().

◆ MakeRandomVectorFixed()

void MakeRandomVectorFixed ( short minimum,
short maximum,
FixedVector * vector )

◆ match_roll_orientation()

◆ MaxInt()

int MaxInt ( int a,
int b )

Definition at line 142 of file geom.c.

References MaxInt().

Referenced by MaxInt(), and object_collision().

◆ MinInt()

int MinInt ( int a,
int b )

Definition at line 133 of file geom.c.

References MinInt().

Referenced by accelerate_and_move_object(), MinInt(), and object_collision().

◆ negate_vector()

◆ NormalizeAndScaleVector()

◆ NormalizeFixedVector()

◆ point_at()

◆ point_capital_ship_at_object()

void point_capital_ship_at_object ( short obj,
short other )

◆ point_parallel()

void point_parallel ( short obj,
short other )

◆ point_perpendicular()

void point_perpendicular ( short obj,
short other )

◆ point_perpendicular_to_point()

void point_perpendicular_to_point ( short obj,
const FixedVector * point )

◆ point_ship()

◆ point_ship_at_object()

◆ point_ship_at_point()

◆ point_ship_behind_object()

void point_ship_behind_object ( short obj,
short other )

◆ point_ship_below_object()

void point_ship_below_object ( short obj,
short other )

◆ position_child()

◆ position_relative()

◆ position_relative_ijk()

void position_relative_ijk ( FixedVector * position,
short obj,
short right,
short up,
short forward )

◆ random_radial()

void random_radial ( const FixedVector * center,
short radius,
FixedVector * position )

◆ recalc_max_velocity()

◆ rectangular_to_spherical()

◆ remove_object()

◆ rotate_about_i()

◆ rotate_about_j()

◆ rotate_about_k()

void rotate_about_k ( short angle,
FixedVector * i,
FixedVector * j )

◆ rotational_acceleration()

◆ ScaleFixedVector()

◆ set_background_objects_rotation()

◆ set_ship_rotation_goals()

short set_ship_rotation_goals ( short obj,
short turnRate,
const FixedVector * direction,
short pointingMode,
short * yawGoal,
short * pitchGoal )

◆ SetVectorFixedPoint()

void SetVectorFixedPoint ( unsigned int * p,
short v )

◆ SignFixed()

unsigned int SignFixed ( int v)

Definition at line 160 of file geom.c.

References SignFixed().

Referenced by approach_speed(), and SignFixed().

◆ SubtractFixedVectors()

void SubtractFixedVectors ( FixedVector * left,
FixedVector * right,
FixedVector * difference )

◆ transform_objects_to_your_view()

◆ transform_to_objects_frame()

◆ vector_angle()

short vector_angle ( FixedVector left,
FixedVector right )

Definition at line 324 of file geom.c.

References dot_product(), NormalizeFixedVector(), and vector_angle().

Referenced by hemisphere(), and vector_angle().

◆ vector_component_in_dir()

void vector_component_in_dir ( const FixedVector * vector,
const FixedVector * direction,
FixedVector * component )

◆ vector_cross_product()

void vector_cross_product ( const FixedVector * left,
const FixedVector * right,
FixedVector * product )

◆ vector_length_in_dir()

int vector_length_in_dir ( const FixedVector * vector,
const FixedVector * direction )

◆ WrapDegrees()

short WrapDegrees ( short degrees)

Definition at line 171 of file geom.c.

References WrapDegrees().

Referenced by match_roll_orientation(), set_ship_rotation_goals(), and WrapDegrees().

◆ zero_vector()

Variable Documentation

◆ g_2_vNormalizedToTgt

FixedVector g_2_vNormalizedToTgt

◆ g_abObjectShapeOwned

int g_abObjectShapeOwned[SPACE_OBJECT_COUNT] = { 0 }

Definition at line 559 of file geom.c.

Referenced by get_right_shape().

◆ g_anCloakVisibilityPattern

int g_anCloakVisibilityPattern[20]
Initial value:
= {
1, 0, 0, 0, 1, 0, 0, 1, 1, 0,
0, 0, 1, 1, 1, 0, 0, 1, 1, 0
}

Definition at line 555 of file geom.c.

Referenced by show_target_disp(), and transform_objects_to_your_view().

◆ g_nFacingRangeQueryCount

int g_nFacingRangeQueryCount = 0

Definition at line 554 of file geom.c.

Referenced by get_facing_range_from_point().

◆ g_nUnusedGeomWord

int g_nUnusedGeomWord[3]

Definition at line 1333 of file geom.c.