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

Vector, angle and fixed-point geometry, and ship speed and fuel limits. More...

#include "wc1.h"

Go to the source code of this file.

Functions

short __stdcall MeasureTextPixelWidthClamped (const char *text)
int __stdcall SeekPacketSection (PacketSectionHandle *handle, int offset, short origin)
unsigned short GetMusicDriverPresent (short mode)
short __stdcall CollectActivePaletteIndices (Viewport *viewport, unsigned char *indices, short capacity)
short get_ship_max_velocity (short obj)
short 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)
int intfract_sign (int sign, int magnitude)
unsigned short SignShort (short v)
unsigned int SignFixed (int v)
short WrapDegrees (short degrees)
int equ_vector (const FixedVector *left, const FixedVector *right)
int IsPairEqualityDifferentFromFlag (const unsigned int *values)
void zero_vector (FixedVector *vector)
void negate_vector (FixedVector *vector)
void AddFixedVectors (const FixedVector *left, const FixedVector *right, FixedVector *sum)
void SubtractFixedVectors (FixedVector *left, FixedVector *right, FixedVector *difference)
void ComputeVectorDelta (const FixedVector *from, const FixedVector *to, FixedVector *delta)
void ScaleFixedVector (const FixedVector *vector, int scale, FixedVector *result)
void divide_vector (FixedVector *vector, int divisor, FixedVector *result)
short ChooseRandomSignedMagnitude (short minimum, short maximum, int 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 MakeRandomNormalizedVector (FixedVector *vector)
void rectangular_to_spherical (const FixedVector *rectangular, SphericalVector *spherical)
long SinFixed (short degrees)
void ConvertSphericalToRectangular (const SphericalVector *spherical, FixedVector *rectangular)
void ConvertShortVectorToFixedVector (const ShortVector *source, FixedVector *destination)
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 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 copy_frame (short source, short destination)
void fix_objects_ijk (short obj)
void transform_to_objects_frame (const FixedVector *source, FixedVector *destination, 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)
void ship_vs_point (short obj, const FixedVector *point)
void ship_vs_ship (short obj, short other)
short facing_to_object (short obj, FixedVector *point)
short match_roll_orientation (short obj, short reference)
int 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_ship_behind_object (short obj, short other)
void point_ship_below_object (short obj, short other)
void point_perpendicular_to_point (short obj, const FixedVector *point)
void point_perpendicular (short obj, short other)
void point_parallel (short obj, short other)
void MoveObjectAlongDirection (short obj, const FixedVector *direction, short distance)
void ComputeObjectToPointDelta (short obj, FixedVector *point, FixedVector *delta)
void ComputeObjectToObjectDelta (short obj, short other, FixedVector *delta)
void NormalizeAndScaleVector (FixedVector *vector, int scale)
void SetVectorFixedPoint (FixedVector *p, short v)
unsigned int IsPointWithinRange (const FixedVector *from, const FixedVector *to, short range)
short check_for_collision (short obj)
void position_child (short parent, short hardpoint, FixedVector *position)
void child_object (short hardpoint, short child, short parent)
short get_ship_slot (void)
short find_vacant_3d_object (void)
void remove_object (short obj)
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)
unsigned short IsPointWithinEyeViewCone (const FixedVector *point)
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

signed char cCapitalShipLogicalFile
FixedVector vNormalizedToTarget

Detailed Description

Vector, angle and fixed-point geometry, and ship speed and fuel limits.

Address range 418080-41a9cf. Text, packet, music and palette helpers open the range and get_right_shape closes it; the modal-panel block at 41a9d0 belongs with the barracks data and save/load routines.

Definition in file geom.c.

Function Documentation

◆ AbsInt()

int AbsInt ( int v)

Definition at line 217 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()

void apply_force_to_objects_center ( FixedVector * force,
short obj )

◆ check_for_collision()

◆ child_object()

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

Definition at line 969 of file geom.c.

References acObjOwnersTable, aShipPositionsArray, child_object(), and position_child().

Referenced by child_object(), drop_mine(), and fire_weapon().

◆ ChooseRandomSignedMagnitude()

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

Definition at line 338 of file geom.c.

References ChooseRandomSignedMagnitude(), and RandomInRange().

Referenced by ChooseRandomSignedMagnitude(), and MakeRandomVectorFixed().

◆ ClampTo30()

void ClampTo30 ( short * p)

Definition at line 1150 of file geom.c.

References ClampTo30().

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

◆ ClampVectorTo30()

void ClampVectorTo30 ( short * p)

Definition at line 1137 of file geom.c.

References ClampVectorTo30().

Referenced by ClampVectorTo30(), and rotate_object().

◆ CollectActivePaletteIndices()

short __stdcall CollectActivePaletteIndices ( Viewport * viewport,
unsigned char * indices,
short capacity )

◆ ComputeObjectToObjectDelta()

void ComputeObjectToObjectDelta ( short obj,
short other,
FixedVector * delta )

◆ ComputeObjectToPointDelta()

void ComputeObjectToPointDelta ( short obj,
FixedVector * point,
FixedVector * delta )

Definition at line 886 of file geom.c.

References aShipPositionsArray, ComputeObjectToPointDelta(), and ComputeVectorDelta().

Referenced by ComputeObjectToPointDelta().

◆ ComputeVectorDelta()

◆ ConvertFixedVectorToShortVector()

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

◆ ConvertShortVectorToFixedVector()

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

◆ ConvertSphericalToRectangular()

◆ 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()

int equ_vector ( const FixedVector * left,
const FixedVector * right )

◆ 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()

◆ 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 976 of file geom.c.

References aeObjectClass, get_ship_slot(), nFreeShipSlot, and OBJECT_CLASS_NULL.

Referenced by get_ship_slot(), and initialize_ship().

◆ GetMusicDriverPresent()

unsigned short GetMusicDriverPresent ( short mode)

Definition at line 65 of file geom.c.

References GetMusicDriverPresent().

Referenced by GetMusicDriverPresent(), and LoadOriginFxDrivers().

◆ GetShipAccelerationRate()

◆ init_ijk()

◆ intfract_sign()

int intfract_sign ( int sign,
int magnitude )

Definition at line 227 of file geom.c.

References intfract_sign().

Referenced by intfract_sign().

◆ IsPairEqualityDifferentFromFlag()

int IsPairEqualityDifferentFromFlag ( const unsigned int * values)

Definition at line 274 of file geom.c.

References IsPairEqualityDifferentFromFlag().

Referenced by IsPairEqualityDifferentFromFlag().

◆ IsPointWithinEyeViewCone()

◆ IsPointWithinRange()

unsigned int IsPointWithinRange ( const FixedVector * from,
const FixedVector * to,
short range )

◆ look_at()

void look_at ( short obj)

Definition at line 166 of file geom.c.

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

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

◆ MakeRandomNormalizedVector()

void MakeRandomNormalizedVector ( FixedVector * vector)

◆ MakeRandomVectorFixed()

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

◆ match_roll_orientation()

◆ MaxInt()

int MaxInt ( int a,
int b )

Definition at line 210 of file geom.c.

References MaxInt().

Referenced by MaxInt(), and object_collision().

◆ MeasureTextPixelWidthClamped()

◆ MinInt()

int MinInt ( int a,
int b )

Definition at line 203 of file geom.c.

References MinInt().

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

◆ MoveObjectAlongDirection()

void MoveObjectAlongDirection ( short obj,
const FixedVector * direction,
short distance )

◆ negate_vector()

◆ NormalizeAndScaleVector()

void NormalizeAndScaleVector ( FixedVector * vector,
int scale )

◆ 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()

◆ SeekPacketSection()

int __stdcall SeekPacketSection ( PacketSectionHandle * handle,
int offset,
short origin )

◆ set_background_objects_rotation()

◆ set_ship_rotation_goals()

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

◆ SetVectorFixedPoint()

void SetVectorFixedPoint ( FixedVector * p,
short v )

◆ ship_vs_point()

void ship_vs_point ( short obj,
const FixedVector * point )

◆ ship_vs_ship()

◆ SignFixed()

unsigned int SignFixed ( int v)

Definition at line 246 of file geom.c.

References SignFixed().

Referenced by approach_speed(), and SignFixed().

◆ SignShort()

unsigned short SignShort ( short v)

Definition at line 238 of file geom.c.

References SignShort().

Referenced by SignShort().

◆ SinFixed()

long SinFixed ( short degrees)

Definition at line 89 of file mathfp.c.

◆ SubtractFixedVectors()

◆ transform_objects_to_your_view()

◆ transform_to_objects_frame()

◆ vector_angle()

short vector_angle ( FixedVector left,
FixedVector right )

Definition at line 451 of file geom.c.

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

Referenced by fire(), 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 255 of file geom.c.

References WrapDegrees().

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

◆ zero_vector()

Variable Documentation

◆ cCapitalShipLogicalFile

signed char cCapitalShipLogicalFile

Definition at line 14 of file geom.c.

Referenced by get_right_shape().

◆ vNormalizedToTarget

FixedVector vNormalizedToTarget

Definition at line 15 of file geom.c.

Referenced by get_facing_range_from_object(), and get_facing_range_from_point().