-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScene.h
76 lines (67 loc) · 2.39 KB
/
Scene.h
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
#pragma once
#include "Vector3D.h"
#include "SceneObject.h"
#include "Camera.h"
namespace Bladestick
{
namespace Drawing
{
public ref class SceneMarks
{
public:
static initonly System::String ^ CAMERA_POSITION = "cpos ";
static initonly System::String ^ CAMERA_TARGET = "ctar ";
static initonly System::String ^ FUSTRUM = "frst ";
static initonly System::String ^ FOV = "fov ";
static initonly System::String ^ PROJ_TYPE = "cper ";
static initonly System::String ^ BG_COLOR = "bc ";
static initonly System::String ^ LINE_COLOR = "lc ";
static initonly System::String ^ OBJ_COUNT = "obc ";
static initonly System::String ^ END_OF_OBJECT = "eoo";
};
public enum DrawFlags
{
DRAW_EDGES = 1,
DRAW_FILL = 1 << 1,
USE_RND_COLORS = 1 << 2,
SIMULATE_LIGHT = 1 << 3
};
public ref class Scene
{
private:
bool isPointInRect(Vector3D ^ p);
Vector3D ^ getPointAtY(Vector3D ^ A, Vector3D ^ B, double y);
Vector3D ^ getPointAtX(Vector3D ^ A, Vector3D ^ B, double x);
array<Vector3D ^> ^ clipLineXY(Vector3D ^ p1, Vector3D ^ p2);
internal:
System::Drawing::Bitmap ^ bitmap;
array<double> ^ zbuffer;
System::Drawing::Color bgColor;
System::Drawing::Color edgeColor;
int width;
int height;
Camera ^ camera;
int objTotalCount;
System::ComponentModel::BindingList<SceneObject ^> ^ objects;
void setPixel(int x, int y, double z, System::Drawing::Color color);
void drawLine(double x0, double y0, double z0, double x1, double y1, double z1, System::Drawing::Color color);
void drawLine(Vector3D ^ p1, Vector3D ^ p2, System::Drawing::Color color);
void drawTriangle(Vector3D ^ p1, Vector3D ^ p2, Vector3D ^ p3, System::Drawing::Color color, char drawFlags);
public:
Scene(int width, int height, System::Drawing::Color bgColor, System::Drawing::Color edgeColor);
Scene(int width, int height);
Scene();
void setSize(int width, int height);
int getWidth();
int getHeight();
void clear();
void drawToBuffer(SceneObject ^ obj, char drawFlags);
void drawObjectsToBuffer(char drawFlags);
void render(System::Drawing::Graphics ^ g);
System::Drawing::Color getBgColor();
void setBgColor(System::Drawing::Color color);
void saveToStream(System::IO::StreamWriter ^ stream);
void loadFromStream(System::IO::Stream ^ stream);
};
}
}