first wall of LightBox done
git-svn-id: svn://anubis/dwscr/trunk@92 5bef9df8-b654-44bb-925b-0ff18baa8f8c
This commit is contained in:
parent
4ed97f09f6
commit
126b75fb56
1
Makefile
1
Makefile
@ -11,6 +11,7 @@ export CXXFLAGS := -O2 -Wall
|
|||||||
export CPPFLAGS
|
export CPPFLAGS
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
CPPFLAGS += -DDEBUG
|
CPPFLAGS += -DDEBUG
|
||||||
|
CPPFLAGS += -g
|
||||||
endif
|
endif
|
||||||
ifdef WITHOUT_ODE
|
ifdef WITHOUT_ODE
|
||||||
CPPFLAGS += -DWITHOUT_ODE
|
CPPFLAGS += -DWITHOUT_ODE
|
||||||
|
@ -8,8 +8,11 @@
|
|||||||
#include "LightBounce.h"
|
#include "LightBounce.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#define SIZE 5
|
||||||
|
|
||||||
/* construct screensaver mode and do some basic OpenGL setup */
|
/* construct screensaver mode and do some basic OpenGL setup */
|
||||||
LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
||||||
{
|
{
|
||||||
@ -22,13 +25,38 @@ LightBounce::LightBounce(SSMain * _SSMain) : SSMode(_SSMain)
|
|||||||
0.01,
|
0.01,
|
||||||
1000.01);
|
1000.01);
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
|
||||||
|
LogoBox tmp;
|
||||||
|
float box_stride = tmp.getWidth() * 1.2;
|
||||||
|
float half_size = SIZE * box_stride / 2.0;
|
||||||
|
float y = -half_size;
|
||||||
|
int rot = false;
|
||||||
|
for (int i = 0; i < SIZE; i++)
|
||||||
|
{
|
||||||
|
float x = -half_size;
|
||||||
|
for (int j = 0; j < SIZE; j++)
|
||||||
|
{
|
||||||
|
LightBounce_Box * box = new LightBounce_Box;
|
||||||
|
box->logoBox = new LogoBox();
|
||||||
|
box->x = x;
|
||||||
|
box->y = y;
|
||||||
|
box->z = -half_size;
|
||||||
|
box->xr = 0;
|
||||||
|
box->yr = 0;
|
||||||
|
box->zr = rot ? 90.0 : 0;
|
||||||
|
m_boxes.push_back(box);
|
||||||
|
x += box_stride;
|
||||||
|
rot = !rot;
|
||||||
|
}
|
||||||
|
y += box_stride;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called every time this screensaver mode should redraw the screen */
|
/* called every time this screensaver mode should redraw the screen */
|
||||||
void LightBounce::update()
|
void LightBounce::update()
|
||||||
{
|
{
|
||||||
SSMode::update();
|
SSMode::update();
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
int numMonitors = m_SSMain->getNumMonitors();
|
int numMonitors = m_SSMain->getNumMonitors();
|
||||||
int width = m_SSMain->getWidth();
|
int width = m_SSMain->getWidth();
|
||||||
int height = m_SSMain->getHeight();
|
int height = m_SSMain->getHeight();
|
||||||
@ -36,9 +64,21 @@ void LightBounce::update()
|
|||||||
{
|
{
|
||||||
glViewport(i*width/numMonitors, 0, width/numMonitors, height);
|
glViewport(i*width/numMonitors, 0, width/numMonitors, height);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluLookAt(0, 0, 12, 0, 0, 0, 0, 1, 0);
|
gluLookAt(0, 0, SIZE * 5.0, 0, 0, 0, 0, 1, 0);
|
||||||
glRotatef(m_elapsed/33.0f, 0, 1, 0);
|
glRotatef(m_elapsed/33.0f, 0, 1, 0);
|
||||||
m_logoBox.draw();
|
int sz = m_boxes.size();
|
||||||
|
for (int i = 0; i < sz; i++)
|
||||||
|
{
|
||||||
|
glPushMatrix();
|
||||||
|
glTranslatef(m_boxes[i]->x,
|
||||||
|
m_boxes[i]->y,
|
||||||
|
m_boxes[i]->z);
|
||||||
|
glRotatef(m_boxes[i]->xr, 1, 0, 0);
|
||||||
|
glRotatef(m_boxes[i]->yr, 0, 1, 0);
|
||||||
|
glRotatef(m_boxes[i]->zr, 0, 0, 1);
|
||||||
|
m_boxes[i]->logoBox->draw();
|
||||||
|
glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,20 @@
|
|||||||
#include "SSMain.h"
|
#include "SSMain.h"
|
||||||
#include "SSMode.h"
|
#include "SSMode.h"
|
||||||
#include "LogoBox.h"
|
#include "LogoBox.h"
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LogoBox * logoBox;
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
float xr;
|
||||||
|
float yr;
|
||||||
|
float zr;
|
||||||
|
float dist;
|
||||||
|
} LightBounce_Box;
|
||||||
|
|
||||||
class LightBounce : public SSMode
|
class LightBounce : public SSMode
|
||||||
{
|
{
|
||||||
@ -16,7 +30,7 @@ public:
|
|||||||
LightBounce(SSMain * _SSMain);
|
LightBounce(SSMain * _SSMain);
|
||||||
void update();
|
void update();
|
||||||
protected:
|
protected:
|
||||||
LogoBox m_logoBox;
|
vector<LightBounce_Box *> m_boxes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -137,7 +137,7 @@ void TumblingLogos::update()
|
|||||||
for (unsigned int i = 0; i < delta / 2; i++)
|
for (unsigned int i = 0; i < delta / 2; i++)
|
||||||
worldStep();
|
worldStep();
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
int numMonitors = m_SSMain->getNumMonitors();
|
int numMonitors = m_SSMain->getNumMonitors();
|
||||||
int width = m_SSMain->getWidth();
|
int width = m_SSMain->getWidth();
|
||||||
int height = m_SSMain->getHeight();
|
int height = m_SSMain->getHeight();
|
||||||
@ -190,36 +190,36 @@ void TumblingLogos::update()
|
|||||||
void TumblingLogos_collide_callback(void * data, dGeomID o1, dGeomID o2)
|
void TumblingLogos_collide_callback(void * data, dGeomID o1, dGeomID o2)
|
||||||
{
|
{
|
||||||
TumblingLogos * tl = (TumblingLogos *) data;
|
TumblingLogos * tl = (TumblingLogos *) data;
|
||||||
static dContact contact[4];
|
static dContact contact[4];
|
||||||
dBodyID b1 = dGeomGetBody(o1);
|
dBodyID b1 = dGeomGetBody(o1);
|
||||||
dBodyID b2 = dGeomGetBody(o2);
|
dBodyID b2 = dGeomGetBody(o2);
|
||||||
if (b1 && b2 && dAreConnected(b1, b2))
|
if (b1 && b2 && dAreConnected(b1, b2))
|
||||||
return;
|
return;
|
||||||
int num = dCollide(o1, o2, 4, &contact[0].geom, sizeof(dContact));
|
int num = dCollide(o1, o2, 4, &contact[0].geom, sizeof(dContact));
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < num; i++)
|
for (i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
contact[i].surface.mode =
|
contact[i].surface.mode =
|
||||||
dContactSlip1 | dContactSlip2 | dContactBounce |
|
dContactSlip1 | dContactSlip2 | dContactBounce |
|
||||||
dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
dContactSoftERP | dContactSoftCFM | dContactApprox1;
|
||||||
contact[i].surface.mu = 0.5;
|
contact[i].surface.mu = 0.5;
|
||||||
contact[i].surface.slip1 = 0.0;
|
contact[i].surface.slip1 = 0.0;
|
||||||
contact[i].surface.slip2 = 0.0;
|
contact[i].surface.slip2 = 0.0;
|
||||||
contact[i].surface.soft_erp = 0.8;
|
contact[i].surface.soft_erp = 0.8;
|
||||||
contact[i].surface.soft_cfm = 0.01;
|
contact[i].surface.soft_cfm = 0.01;
|
||||||
contact[i].surface.bounce = 0.4;
|
contact[i].surface.bounce = 0.4;
|
||||||
dJointID joint = dJointCreateContact(tl->m_world,
|
dJointID joint = dJointCreateContact(tl->m_world,
|
||||||
tl->m_contactJointGroup, contact + i);
|
tl->m_contactJointGroup, contact + i);
|
||||||
dJointAttach(joint, b1, b2);
|
dJointAttach(joint, b1, b2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invokes ODE to do physics on our world */
|
/* invokes ODE to do physics on our world */
|
||||||
void TumblingLogos::worldStep()
|
void TumblingLogos::worldStep()
|
||||||
{
|
{
|
||||||
dSpaceCollide(m_space, this, TumblingLogos_collide_callback);
|
dSpaceCollide(m_space, this, TumblingLogos_collide_callback);
|
||||||
dWorldQuickStep(m_world, WORLD_STEP);
|
dWorldQuickStep(m_world, WORLD_STEP);
|
||||||
dJointGroupEmpty(m_contactJointGroup);
|
dJointGroupEmpty(m_contactJointGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* randomly chooses a gravity direction */
|
/* randomly chooses a gravity direction */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user