aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
blob: 470fe66156da5cf9f3e95c6f5e268975e539bac9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#define _POSIX_C_SOURCE 200809L //for fileno and strdup
#include <string.h>
#include "config.h"
#include "math.h"

#ifndef _HACKVR_COMMON_H_
#define _HACKVR_COMMON_H_

#include <hashtable.h>

#define TOP     240.0
#define BOTTOM  -240.0
#define RIGHT   320.0
#define LEFT    -320.0

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

typedef double real;

typedef struct {
 real r;
} radians;

typedef struct {
 int d;
} degrees;

typedef struct {
 real x;
 real y;
 real z;
} c3_t;

typedef struct {
 real x;
 real y;
} c2_t;

typedef struct {//x11 wants coords to be integers. let's make this that.
 int x;
 int y;
} cs_t;

typedef struct {
  degrees x;
  degrees y;
  degrees z;
} c3_rot_t;

typedef struct {
  char *id;//for the camera this is $USER, right?
  char *parent;//the position is relative to the parent's data.
  c3_rot_t r;//rotation
  c3_t p;//position
  c3_t s;//??? shape??? I dunno. really. wtf was this for? PROBABLY SCALE. DUH. that's what it is going to bed used for now anyway.
  c3_t v;//velocity
} c3_group_rel_t;

//typedef struct c3_line {//is this even used? I think I just use c3_s_t with 2 points.
// char *id;
// c3_t p1;
// c3_t p2;
//} cs_l_t;

struct attrib {
  char col;//color. not sure how I plan on using this.
  char lum;//brightness. 1 - 200 atm because X11 has grey1 - grey200
};

//not used yet. will be later I guess. if I ever get around to doing bezier curves.
typedef enum shape_flavor {POLYGON,ELLIPTIC_ARC,CUBIC_BEZIER,QUAD_BEZIER} shape_flavor;

typedef struct cs_shape {
  char *id;
  shape_flavor type;
  unsigned char len;
  cs_t p[MAX_SIDES];
  struct attrib attrib;
} cs_s_t;

typedef struct c2_shape {
  char *id;
  shape_flavor type;
  unsigned char len;
  c2_t p[MAX_SIDES];
  struct attrib attrib;
} c2_s_t;

typedef struct c3_shape {//use array or linked list?
  char *id;
  shape_flavor type;
  unsigned char len;
  c3_t p[MAX_SIDES];
  c3_t v;//velocities.
  struct attrib attrib;
} c3_s_t;

typedef enum hvr_state {
  HVR_STATE_INIT,
  HVR_STATE_RUN,
  HVR_STATE_EXIT
} hvr_state;

struct hvr_global {
  int x;
  int y;
  c3_rot_t old_r;
  c3_t old_p;
  char beep;//1 or 0
  int math_error;
  char *user;
  char headless;
  char debug;//flag
  char selected_object[2000];//meh
  int periodic_output;//if false, we output commands from keypresses as they're being sent to the command interpreter. if true we output every value amount of time. miliseconds probably.
  real mmz;
  int lps;//loops per second. same as frame per second but also works for headless.
  char *active;
  struct c3_shape *shape[SHAPES];
  int shapes;
  struct hashtable ht_group;
  c3_group_rel_t eye[MAX_SIDES];//lol. 1000 eyes! array of group_rels for each eye. how to arrange eyes?
  c3_group_rel_t camera;//should there be an array for this? camera has .s which is a shape struct. each point is the eye?
  hvr_state state;//I dunno.
  real zoom;
  int derp;
  real split;
  char localecho;
  int selfpipe[2];
  char *version;
  char *title;
};

int selfcommand(char *);
void set_title(char *);//fuck if I know where the right spot to put this is.

#endif