|
@@ -19,6 +19,8 @@
|
|
|
#include "pandaFramework.h"
|
|
#include "pandaFramework.h"
|
|
|
#include "geomQuad.h"
|
|
#include "geomQuad.h"
|
|
|
#include "textureAttrib.h"
|
|
#include "textureAttrib.h"
|
|
|
|
|
+#include "cmath.h"
|
|
|
|
|
+#include "mathNumbers.h"
|
|
|
|
|
|
|
|
NodePath bogus_scene;
|
|
NodePath bogus_scene;
|
|
|
|
|
|
|
@@ -56,17 +58,34 @@ event_T(CPT_Event, void *data) {
|
|
|
GeomNode *gnode = new GeomNode("quads");
|
|
GeomNode *gnode = new GeomNode("quads");
|
|
|
bogus_scene.attach_new_node(gnode);
|
|
bogus_scene.attach_new_node(gnode);
|
|
|
|
|
|
|
|
|
|
+ PNMImage white_center(tex_x_size / 4, tex_y_size / 4);
|
|
|
|
|
+ white_center.fill(1.0f, 1.0f, 1.0f);
|
|
|
|
|
+
|
|
|
PTA_Colorf colors;
|
|
PTA_Colorf colors;
|
|
|
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
|
colors.push_back(Colorf(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
for (int yi = 0; yi < num_quads_side; yi++) {
|
|
for (int yi = 0; yi < num_quads_side; yi++) {
|
|
|
float y0 = (float)yi / (float)num_quads_side;
|
|
float y0 = (float)yi / (float)num_quads_side;
|
|
|
float y1 = (float)(yi + 1) / (float)num_quads_side;
|
|
float y1 = (float)(yi + 1) / (float)num_quads_side;
|
|
|
|
|
+
|
|
|
|
|
+ // Map the x, y vertices onto a sphere just for fun.
|
|
|
|
|
+ float px0 = ccos((y0 - 0.5f) * MathNumbers::pi_f);
|
|
|
|
|
+ float px1 = ccos((y1 - 0.5f) * MathNumbers::pi_f);
|
|
|
|
|
+ float py0 = csin((y0 - 0.5f) * MathNumbers::pi_f);
|
|
|
|
|
+ float py1 = csin((y1 - 0.5f) * MathNumbers::pi_f);
|
|
|
for (int xi = 0; xi < num_quads_side; xi++) {
|
|
for (int xi = 0; xi < num_quads_side; xi++) {
|
|
|
float x0 = (float)xi / (float)num_quads_side;
|
|
float x0 = (float)xi / (float)num_quads_side;
|
|
|
float x1 = (float)(xi + 1) / (float)num_quads_side;
|
|
float x1 = (float)(xi + 1) / (float)num_quads_side;
|
|
|
|
|
|
|
|
|
|
+ float hx0 = ccos(x0 * MathNumbers::pi_f * 2.0f);
|
|
|
|
|
+ float hx1 = ccos(x1 * MathNumbers::pi_f * 2.0f);
|
|
|
|
|
+ float hy0 = csin(x0 * MathNumbers::pi_f * 2.0f);
|
|
|
|
|
+ float hy1 = csin(x1 * MathNumbers::pi_f * 2.0f);
|
|
|
|
|
+
|
|
|
PNMImage bogus_image(tex_x_size, tex_y_size);
|
|
PNMImage bogus_image(tex_x_size, tex_y_size);
|
|
|
bogus_image.fill(x0, (xi + yi) & 1, y0);
|
|
bogus_image.fill(x0, (xi + yi) & 1, y0);
|
|
|
|
|
+ bogus_image.copy_sub_image(white_center,
|
|
|
|
|
+ (tex_x_size - white_center.get_x_size()) / 2,
|
|
|
|
|
+ (tex_y_size - white_center.get_y_size()) / 2);
|
|
|
|
|
|
|
|
PT(Texture) tex = new Texture;
|
|
PT(Texture) tex = new Texture;
|
|
|
tex->set_minfilter(Texture::FT_linear_mipmap_linear);
|
|
tex->set_minfilter(Texture::FT_linear_mipmap_linear);
|
|
@@ -74,10 +93,10 @@ event_T(CPT_Event, void *data) {
|
|
|
|
|
|
|
|
PTA_Vertexf coords;
|
|
PTA_Vertexf coords;
|
|
|
PTA_TexCoordf uvs;
|
|
PTA_TexCoordf uvs;
|
|
|
- coords.push_back(Vertexf(x0, 0.0f, y0));
|
|
|
|
|
- coords.push_back(Vertexf(x1, 0.0f, y0));
|
|
|
|
|
- coords.push_back(Vertexf(x1, 0.0f, y1));
|
|
|
|
|
- coords.push_back(Vertexf(x0, 0.0f, y1));
|
|
|
|
|
|
|
+ coords.push_back(Vertexf(hx0 * px0, hy0 * px0, py0));
|
|
|
|
|
+ coords.push_back(Vertexf(hx1 * px0, hy1 * px0, py0));
|
|
|
|
|
+ coords.push_back(Vertexf(hx1 * px1, hy1 * px1, py1));
|
|
|
|
|
+ coords.push_back(Vertexf(hx0 * px1, hy0 * px1, py1));
|
|
|
uvs.push_back(TexCoordf(0.0f, 0.0f));
|
|
uvs.push_back(TexCoordf(0.0f, 0.0f));
|
|
|
uvs.push_back(TexCoordf(1.0f, 0.0f));
|
|
uvs.push_back(TexCoordf(1.0f, 0.0f));
|
|
|
uvs.push_back(TexCoordf(1.0f, 1.0f));
|
|
uvs.push_back(TexCoordf(1.0f, 1.0f));
|
|
@@ -91,7 +110,6 @@ event_T(CPT_Event, void *data) {
|
|
|
gnode->add_geom(quad, RenderState::make(TextureAttrib::make(tex)));
|
|
gnode->add_geom(quad, RenderState::make(TextureAttrib::make(tex)));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
cerr << "Done.\n";
|
|
cerr << "Done.\n";
|
|
|
}
|
|
}
|
|
|
|
|
|