mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 22:39:04 -06:00
Fixed bug in DU mesh rendering.
This commit is contained in:
@@ -111,6 +111,7 @@ function postInitialization()
|
||||
openspace.setPropertyValue("Tully Galaxies.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("Tully Galaxies Pics.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("Constellations EXGAL.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("Constellations.renderable.Enabled", false)
|
||||
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Atmosphere", true)
|
||||
openspace.setPropertyValue("Earth.RenderableGlobe.Debug.LevelByProjectedAreaElseDistance", false)
|
||||
@@ -121,6 +122,11 @@ function postInitialization()
|
||||
openspace.setPropertyValue("Equatorial Grid Labels.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("Galactic Grid.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("Galactic Grid Labels.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("100kly Grid.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("1Mly Grid.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("10Mly Grid.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("100Mly Grid.renderable.Enabled", false)
|
||||
openspace.setPropertyValue("20Gly Grid.renderable.Enabled", false)
|
||||
|
||||
openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000)
|
||||
|
||||
@@ -156,7 +162,8 @@ return {
|
||||
-- "satellites"
|
||||
|
||||
--"constellationbounds",
|
||||
--"grids",
|
||||
--"constellations/digitaluniverse",
|
||||
"grids",
|
||||
|
||||
-- # Milkyway objects
|
||||
"stars/digitaluniverse",
|
||||
@@ -176,8 +183,7 @@ return {
|
||||
--"supernovaremnants/digitaluniverse",
|
||||
--"h2regions/digitaluniverse",
|
||||
|
||||
-- # Extragalactic objects
|
||||
"constellations/digitaluniverse",
|
||||
-- # Extragalactic objects
|
||||
--"groups/digitaluniverse",
|
||||
--"clusters/digitaluniverse",
|
||||
--"voids/digitaluniverse",
|
||||
|
||||
@@ -93,6 +93,96 @@ return {
|
||||
TextMinSize = 5.0,
|
||||
Unit = "pc",
|
||||
},
|
||||
}
|
||||
|
||||
},
|
||||
-- Plane Grids
|
||||
{
|
||||
Name = "100kly Grid",
|
||||
Parent = "Root",
|
||||
--Parent = "SolarSystem",
|
||||
Renderable = {
|
||||
Type = "RenderableDUMeshes",
|
||||
Color = {1.0, 1.0, 1.0},
|
||||
Transparency = 0.4,
|
||||
ScaleFactor = 1.0,
|
||||
File = "speck/100kly.speck",
|
||||
MeshColor = {{0.1, 0.5, 0.6}},
|
||||
LabelFile = "speck/100kly.label",
|
||||
TextColor = {0.0, 0.2, 0.5, 1.0},
|
||||
TextSize = 18.6,
|
||||
TextMinSize = 7.0,
|
||||
Unit = "Mpc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name = "1Mly Grid",
|
||||
Parent = "Root",
|
||||
--Parent = "SolarSystem",
|
||||
Renderable = {
|
||||
Type = "RenderableDUMeshes",
|
||||
Color = {1.0, 1.0, 1.0},
|
||||
Transparency = 0.4,
|
||||
ScaleFactor = 1.0,
|
||||
File = "speck/1Mly.speck",
|
||||
MeshColor = {{0.1, 0.5, 0.6}},
|
||||
LabelFile = "speck/1Mly.label",
|
||||
TextColor = {0.0, 0.2, 0.5, 1.0},
|
||||
TextSize = 19.6,
|
||||
TextMinSize = 7.0,
|
||||
Unit = "Mpc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name = "10Mly Grid",
|
||||
Parent = "Root",
|
||||
--Parent = "SolarSystem",
|
||||
Renderable = {
|
||||
Type = "RenderableDUMeshes",
|
||||
Color = {1.0, 1.0, 1.0},
|
||||
Transparency = 0.4,
|
||||
ScaleFactor = 1.0,
|
||||
File = "speck/10Mly.speck",
|
||||
MeshColor = {{0.1, 0.5, 0.6}},
|
||||
LabelFile = "speck/10Mly.label",
|
||||
TextColor = {0.0, 0.2, 0.5, 1.0},
|
||||
TextSize = 20.6,
|
||||
TextMinSize = 7.0,
|
||||
Unit = "Mpc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name = "100Mly Grid",
|
||||
Parent = "Root",
|
||||
--Parent = "SolarSystem",
|
||||
Renderable = {
|
||||
Type = "RenderableDUMeshes",
|
||||
Color = {1.0, 1.0, 1.0},
|
||||
Transparency = 0.4,
|
||||
ScaleFactor = 1.0,
|
||||
File = "speck/100Mly.speck",
|
||||
MeshColor = {{0.1, 0.5, 0.6}},
|
||||
LabelFile = "speck/100Mly.label",
|
||||
TextColor = {0.0, 0.2, 0.5, 1.0},
|
||||
TextSize = 21.6,
|
||||
TextMinSize = 7.0,
|
||||
Unit = "Mpc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name = "20Gly Grid",
|
||||
Parent = "Root",
|
||||
--Parent = "SolarSystem",
|
||||
Renderable = {
|
||||
Type = "RenderableDUMeshes",
|
||||
Color = {1.0, 1.0, 1.0},
|
||||
Transparency = 0.4,
|
||||
ScaleFactor = 1.0,
|
||||
File = "speck/20Gly.speck",
|
||||
MeshColor = {{0.1, 0.5, 0.6}},
|
||||
LabelFile = "speck/20Gly.label",
|
||||
TextColor = {0.0, 0.2, 0.5, 1.0},
|
||||
TextSize = 23.6,
|
||||
TextMinSize = 7.0,
|
||||
Unit = "Mpc",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -370,8 +370,10 @@ namespace openspace {
|
||||
|
||||
void RenderableDUMeshes::deinitialize() {
|
||||
for (auto pair : _renderingMeshesMap) {
|
||||
glDeleteVertexArrays(1, &pair.second.vao);
|
||||
glDeleteBuffers(1, &pair.second.vbo);
|
||||
for (int i = 0; i < pair.second.numU; ++i) {
|
||||
glDeleteVertexArrays(1, &pair.second.vaoArray[i]);
|
||||
glDeleteBuffers(1, &pair.second.vboArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
RenderEngine& renderEngine = OsEng.renderEngine();
|
||||
@@ -415,21 +417,22 @@ namespace openspace {
|
||||
|
||||
for (auto pair : _renderingMeshesMap) {
|
||||
_program->setUniform("color", _meshColorMap[pair.second.colorIndex]);
|
||||
glBindVertexArray(pair.second.vao);
|
||||
switch (pair.second.style)
|
||||
{
|
||||
case Solid:
|
||||
break;
|
||||
case Wire:
|
||||
glDrawArrays(GL_LINE_STRIP, 0, pair.second.numU * pair.second.numV);
|
||||
break;
|
||||
case Point:
|
||||
glDrawArrays(GL_POINTS, 0, pair.second.numU * pair.second.numV);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pair.second.numU; ++i) {
|
||||
glBindVertexArray(pair.second.vaoArray[i]);
|
||||
switch (pair.second.style)
|
||||
{
|
||||
case Solid:
|
||||
break;
|
||||
case Wire:
|
||||
glDrawArrays(GL_LINE_STRIP, 0, pair.second.numV);
|
||||
break;
|
||||
case Point:
|
||||
glDrawArrays(GL_POINTS, 0, pair.second.numV);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -856,10 +859,7 @@ namespace openspace {
|
||||
std::unordered_map<int, RenderingMesh>::iterator it = _renderingMeshesMap.begin();
|
||||
std::unordered_map<int, RenderingMesh>::iterator itEnd = _renderingMeshesMap.end();
|
||||
|
||||
for (; it != itEnd; ++it) {
|
||||
glGenVertexArrays(1, &(it->second.vao));
|
||||
glGenBuffers(1, &(it->second.vbo));
|
||||
|
||||
for (; it != itEnd; ++it) {
|
||||
float scale = 0.0;
|
||||
switch (_unit) {
|
||||
case Meter:
|
||||
@@ -889,45 +889,54 @@ namespace openspace {
|
||||
it->second.vertices[v] *= scale;
|
||||
}
|
||||
|
||||
glBindVertexArray(it->second.vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, it->second.vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, it->second.vertices.size() * sizeof(GLfloat),
|
||||
&it->second.vertices[0], GL_STATIC_DRAW);
|
||||
// in_position
|
||||
glEnableVertexAttribArray(0);
|
||||
// U and V may not be given by the user
|
||||
if (it->second.vertices.size() / (it->second.numU * it->second.numV) > 3) {
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 5,
|
||||
nullptr
|
||||
);
|
||||
for (int i = 0; i < it->second.numU; ++i) {
|
||||
GLuint vao, vbo;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glGenBuffers(1, &vbo);
|
||||
it->second.vaoArray.push_back(vao);
|
||||
it->second.vboArray.push_back(vbo);
|
||||
|
||||
// texture coords
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 4)
|
||||
);
|
||||
}
|
||||
else { // no U and V:
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
0,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
}
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
//glBufferData(GL_ARRAY_BUFFER, it->second.numV * sizeof(GLfloat),
|
||||
glBufferData(GL_ARRAY_BUFFER, it->second.vertices.size() * sizeof(GLfloat),
|
||||
&it->second.vertices[0], GL_STATIC_DRAW);
|
||||
// in_position
|
||||
glEnableVertexAttribArray(0);
|
||||
// U and V may not be given by the user
|
||||
if (it->second.vertices.size() / (it->second.numU * it->second.numV) > 3) {
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 5,
|
||||
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * i * it->second.numV)
|
||||
);
|
||||
|
||||
// texture coords
|
||||
glEnableVertexAttribArray(1);
|
||||
glVertexAttribPointer(
|
||||
1,
|
||||
2,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
sizeof(GLfloat) * 6,
|
||||
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i * it->second.numV)
|
||||
);
|
||||
}
|
||||
else { // no U and V:
|
||||
glVertexAttribPointer(
|
||||
0,
|
||||
3,
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
0,
|
||||
reinterpret_cast<GLvoid*>(sizeof(GLfloat) * 3 * i * it->second.numV)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ namespace openspace {
|
||||
// then numU numU will both equal 21
|
||||
int numU, numV;
|
||||
MeshType style;
|
||||
GLuint vao;
|
||||
GLuint vbo;
|
||||
std::vector<GLuint> vaoArray;
|
||||
std::vector<GLuint> vboArray;
|
||||
std::vector<GLfloat> vertices;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user