aboutsummaryrefslogtreecommitdiff
path: root/cWiremesh.h
blob: 0bdfbdb91ea5e9ab515498754f16b094bb302e7e (plain)
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
#pragma once

#include <vector>
#include <cmath>

#include "cRender.h"

#define _DEPTH 99

#define PI 3.14159265

struct sCoord3d
{
  int x;
  int y;
  int z;

  sCoord3d operator+(sCoord3d p)
  {
    sCoord3d ret;
    ret.x = x + p.x;
    ret.y = y + p.y;
    ret.z = z + p.z;
    return ret;
  }

  sCoord3d operator-(sCoord3d p)
  {
    sCoord3d ret;
    ret.x = x - p.x;
    ret.y = y - p.y;
    ret.z = z - p.z;
    return ret;
  }
};

struct sVector
{
  sCoord3d origin;
  sCoord3d direction;

  char c;
  WORD color;
};

class cWiremesh
{
public:

  cWiremesh();

  virtual ~cWiremesh();

  void addVector(sCoord3d _origin, sCoord3d _vector, char _char, WORD _color);

  void rotate(sCoord3d _val);

  void scale(float _scalar);

  sCoord3d getPosition();

  void setPosition(int _x, int _y, int _z);

  void setPosition(sCoord3d _pos);

  void reset();

  void write(cRender *_render);

protected:

private:

  sPos translate(sCoord3d _coord, sCoord3d _origin);

  sCoord3d applyRotation(sCoord3d _vector, sCoord3d _angle);

  sCoord3d position;

  sCoord3d angle;

  std::vector<sVector> vectors;
};