mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 07:24:59 +02:00
Added test routine makecubes() and key handlers
This commit is contained in:
parent
4226886042
commit
e5c94d6c69
6 changed files with 96 additions and 6 deletions
Binary file not shown.
|
@ -16,5 +16,18 @@
|
||||||
landmarkName = "field_avg_neighbors(int index, glm::vec3 * result)"
|
landmarkName = "field_avg_neighbors(int index, glm::vec3 * result)"
|
||||||
landmarkType = "7">
|
landmarkType = "7">
|
||||||
</FileBreakpoint>
|
</FileBreakpoint>
|
||||||
|
<FileBreakpoint
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "util.cpp"
|
||||||
|
timestampString = "375575185.217506"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "28"
|
||||||
|
endingLineNumber = "28"
|
||||||
|
landmarkName = "makeCubes(float location[3], float scale, int * index, float * cubes_position, float * cubes_scale, float * cubes_color)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</FileBreakpoint>
|
||||||
</FileBreakpoints>
|
</FileBreakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
|
51
main.cpp
51
main.cpp
|
@ -95,11 +95,16 @@ ParticleSystem balls(0,
|
||||||
0.0 // Gravity
|
0.0 // Gravity
|
||||||
);
|
);
|
||||||
|
|
||||||
Cloud cloud(300000, // Particles
|
Cloud cloud(0, // Particles
|
||||||
box, // Bounding Box
|
box, // Bounding Box
|
||||||
false // Wrap
|
false // Wrap
|
||||||
);
|
);
|
||||||
|
|
||||||
|
float cubes_position[MAX_CUBES*3];
|
||||||
|
float cubes_scale[MAX_CUBES];
|
||||||
|
float cubes_color[MAX_CUBES*3];
|
||||||
|
int cube_count = 0;
|
||||||
|
|
||||||
#define RENDER_FRAME_MSECS 10
|
#define RENDER_FRAME_MSECS 10
|
||||||
#define SLEEP 0
|
#define SLEEP 0
|
||||||
|
|
||||||
|
@ -271,6 +276,18 @@ void init(void)
|
||||||
myHead.setNoise(noise);
|
myHead.setNoise(noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
|
float location[] = {0,0,0};
|
||||||
|
float scale = 10.0;
|
||||||
|
int j = 0;
|
||||||
|
while (index < (MAX_CUBES/2)) {
|
||||||
|
index = 0;
|
||||||
|
j++;
|
||||||
|
makeCubes(location, scale, &index, cubes_position, cubes_scale, cubes_color);
|
||||||
|
std::cout << "Run " << j << " Made " << index << " cubes\n";
|
||||||
|
cube_count = index;
|
||||||
|
}
|
||||||
|
|
||||||
//load_png_as_texture(texture_filename);
|
//load_png_as_texture(texture_filename);
|
||||||
|
|
||||||
if (serial_on)
|
if (serial_on)
|
||||||
|
@ -492,6 +509,20 @@ void display(void)
|
||||||
glRotatef(render_yaw, 0, 1, 0);
|
glRotatef(render_yaw, 0, 1, 0);
|
||||||
glTranslatef(location[0], location[1], location[2]);
|
glTranslatef(location[0], location[1], location[2]);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(WORLD_SIZE/2, WORLD_SIZE/2, WORLD_SIZE/2);
|
||||||
|
int i = 0;
|
||||||
|
while (i < cube_count) {
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(cubes_position[i*3], cubes_position[i*3+1], cubes_position[i*3+2]);
|
||||||
|
glColor3fv(&cubes_color[i*3]);
|
||||||
|
glutSolidCube(cubes_scale[i]);
|
||||||
|
glPopMatrix();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
|
||||||
/* Draw Point Sprites */
|
/* Draw Point Sprites */
|
||||||
|
|
||||||
load_png_as_texture(texture_filename);
|
load_png_as_texture(texture_filename);
|
||||||
|
@ -587,7 +618,20 @@ void display(void)
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
framecount++;
|
framecount++;
|
||||||
}
|
}
|
||||||
|
void specialkey(int k, int x, int y)
|
||||||
|
{
|
||||||
|
if (k == GLUT_KEY_UP) fwd_vel += 0.05;
|
||||||
|
if (k == GLUT_KEY_DOWN) fwd_vel -= 0.05;
|
||||||
|
if (k == GLUT_KEY_LEFT) {
|
||||||
|
if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) lateral_vel -= 0.02;
|
||||||
|
else render_yaw_rate -= 0.25;
|
||||||
|
}
|
||||||
|
if (k == GLUT_KEY_RIGHT) {
|
||||||
|
if (glutGetModifiers() == GLUT_ACTIVE_SHIFT) lateral_vel += 0.02;
|
||||||
|
else render_yaw_rate += 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
void key(unsigned char k, int x, int y)
|
void key(unsigned char k, int x, int y)
|
||||||
{
|
{
|
||||||
// Process keypresses
|
// Process keypresses
|
||||||
|
@ -728,8 +772,8 @@ void reshape(int width, int height)
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(45, //view angle
|
gluPerspective(45, //view angle
|
||||||
1.0, //aspect ratio
|
1.0, //aspect ratio
|
||||||
1.0, //near clip
|
0.1, //near clip
|
||||||
200.0);//far clip
|
50.0);//far clip
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
@ -810,6 +854,7 @@ int main(int argc, char** argv)
|
||||||
glutDisplayFunc(display);
|
glutDisplayFunc(display);
|
||||||
glutReshapeFunc(reshape);
|
glutReshapeFunc(reshape);
|
||||||
glutKeyboardFunc(key);
|
glutKeyboardFunc(key);
|
||||||
|
glutSpecialFunc(specialkey);
|
||||||
glutMotionFunc(motionFunc);
|
glutMotionFunc(motionFunc);
|
||||||
glutMouseFunc(mouseFunc);
|
glutMouseFunc(mouseFunc);
|
||||||
glutIdleFunc(idle);
|
glutIdleFunc(idle);
|
||||||
|
|
28
util.cpp
28
util.cpp
|
@ -15,11 +15,37 @@
|
||||||
#include "world.h"
|
#include "world.h"
|
||||||
#include "glm/glm.hpp"
|
#include "glm/glm.hpp"
|
||||||
|
|
||||||
|
|
||||||
float randFloat () {
|
float randFloat () {
|
||||||
return (rand()%10000)/10000.f;
|
return (rand()%10000)/10000.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void makeCubes(float location[3], float scale, int * index,
|
||||||
|
float * cubes_position, float * cubes_scale, float * cubes_color) {
|
||||||
|
int i;
|
||||||
|
float spot[3];
|
||||||
|
//std::cout << "loc: " << location[0] << ","
|
||||||
|
//<< location[1] << "," << location[2] << "\n";
|
||||||
|
if ((*index >= MAX_CUBES) || (scale < SMALLEST_CUBE)) return;
|
||||||
|
if (randFloat() < 0.5) {
|
||||||
|
// Make a cube
|
||||||
|
for (i = 0; i < 3; i++) cubes_position[*index*3 + i] = location[i];
|
||||||
|
cubes_scale[*index] = scale;
|
||||||
|
cubes_color[*index*3] = randFloat();
|
||||||
|
cubes_color[*index*3 + 1] = randFloat();
|
||||||
|
cubes_color[*index*3 + 2] = randFloat();
|
||||||
|
*index += 1;
|
||||||
|
//std::cout << "Quad made at scale " << scale << "\n";
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
spot[0] = location[0] + (i%2)*scale/2.0;
|
||||||
|
spot[1] = location[1] + ((i/2)%2)*scale/2.0;
|
||||||
|
spot[2] = location[2] + ((i/4)%2)*scale/2.0;
|
||||||
|
//std::cout << spot[0] << "," << spot[1] << "," << spot[2] << "\n";
|
||||||
|
makeCubes(spot, scale/2.0, index, cubes_position, cubes_scale, cubes_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void render_vector(glm::vec3 * vec)
|
void render_vector(glm::vec3 * vec)
|
||||||
{
|
{
|
||||||
// Show edge of world
|
// Show edge of world
|
||||||
|
|
4
util.h
4
util.h
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#ifndef interface_util_h
|
#ifndef interface_util_h
|
||||||
#define interface_util_h
|
#define interface_util_h
|
||||||
|
|
||||||
#include "glm/glm.hpp"
|
#include "glm/glm.hpp"
|
||||||
|
|
||||||
void outstring(char * string, int length);
|
void outstring(char * string, int length);
|
||||||
|
@ -20,4 +21,7 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl
|
||||||
float r=1.0, float g=1.0, float b=1.0);
|
float r=1.0, float g=1.0, float b=1.0);
|
||||||
double diffclock(timeval clock1,timeval clock2);
|
double diffclock(timeval clock1,timeval clock2);
|
||||||
|
|
||||||
|
void makeCubes(float location[3], float scale, int * index,
|
||||||
|
float * cubes_position, float * cubes_scale, float * cubes_color);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
2
world.h
2
world.h
|
@ -14,5 +14,7 @@
|
||||||
const float WORLD_SIZE = 10.0;
|
const float WORLD_SIZE = 10.0;
|
||||||
#define PI 3.14159265
|
#define PI 3.14159265
|
||||||
|
|
||||||
|
#define MAX_CUBES 2000
|
||||||
|
#define SMALLEST_CUBE 0.01
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue