-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderDriverOpenGL1DebugDrawRays.cpp
122 lines (90 loc) · 2.63 KB
/
RenderDriverOpenGL1DebugDrawRays.cpp
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
#include "HydraRenderDriverAPI.h"
#include "RenderDriverOpenGL1.h"
#include <GL/gl.h>
#include <GL/glu.h>
#include "LiteMath.h"
using namespace LiteMath;
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <string>
extern int g_drawBVHIdInput;
struct RD_OGL1_DebugDrawRays : public RD_OGL1_Debug
{
constexpr static int DEBUG_PATH_MAX_DEPTH = 6; ///< this is for debug needs only
constexpr static int DEBUG_PATH_MAX_NUMBER = 1024; ///< this is for debug needs only
typedef RD_OGL1_Debug Base;
RD_OGL1_DebugDrawRays() : m_numDebugRays(0), m_rayDepth(0)
{
m_drawWire = true;
LoadRays();
}
~RD_OGL1_DebugDrawRays() = default;
void GetRenderDriverName(std::wstring &name) override { name = std::wstring(L"opengl1DrawRays");};
void BeginScene(pugi::xml_node a_sceneNode) override;
void EndScene () override;
protected:
void LoadRays();
int m_numDebugRays;
int m_rayDepth;
std::vector<float4> m_raysPos;
std::vector<float4> m_raysDir;
};
void RD_OGL1_DebugDrawRays::BeginScene(pugi::xml_node a_sceneNode)
{
m_drawWire = true;
Base::BeginScene(a_sceneNode);
}
void RD_OGL1_DebugDrawRays::EndScene()
{
Base::EndScene();
glDisable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
//int rayIndex = g_drawBVHIdInput;
glColor3f(1, 1, 1);
// glBegin(GL_LINE_STRIP);
// for (int vIndex = 0; vIndex < m_raysPos[rayIndex].size(); vIndex++)
// {
// if (m_raysPos[rayIndex][vIndex].w < 0.0f)
// glColor3f(1, 0, 0);
// else
// glColor3f(0, 1, 0);
//
// glVertex3fv(&m_raysPos[rayIndex][vIndex].x);
// }
// glEnd();
glColor3f(1, 0, 0);
glBegin(GL_LINES);
for (size_t i = 0; i < m_raysPos.size(); i++)
{
if (i % 100 == 0)
{
float3 point2 = to_float3(m_raysPos[i]) + to_float3(m_raysDir[i]) * 1.25f;
glVertex3fv(&m_raysPos[i].x);
glVertex3fv(&point2.x);
}
}
glEnd();
}
void RD_OGL1_DebugDrawRays::LoadRays()
{
std::string path1 = "D:/PROG/HydraCore/hydra_app/z_rpos.array4f";
std::string path2 = "D:/PROG/HydraCore/hydra_app/z_rdir.array4f";
std::ifstream fin1(path1.c_str(), std::iostream::binary);
std::ifstream fin2(path2.c_str(), std::iostream::binary);
int size1 = 0, size2 = 0;
fin1.read((char*)&size1, sizeof(int));
fin2.read((char*)&size2, sizeof(int));
m_raysPos.resize(size1);
m_raysDir.resize(size2);
fin1.read((char*)&m_raysPos[0], size1*sizeof(float)*4);
fin2.read((char*)&m_raysDir[0], size2*sizeof(float)*4);
fin1.close();
fin2.close();
std::cout << "after loading rays ... " << std::endl;
}
IHRRenderDriver* CreateOpenGL1DrawRays_RenderDriver()
{
return new RD_OGL1_DebugDrawRays;
}