mirror of
https://github.com/nasa/trick.git
synced 2025-02-12 05:25:35 +00:00
Took the ODE bouncing ball tutorial sim and interfaced it within Trick. Created classes to handle interfacing with ODE and the DrawStuff graphics that comes with ODE. Created classes to contain the ball and the drawstuff graphics for the ball. refs #172
48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
#include "DrawStuff.hh"
|
|
|
|
std::vector<DrawStuffObject *> DrawStuff::objects ;
|
|
|
|
void DrawStuff::start() {
|
|
static float xyz[3] = {2.0f,-2.0f,1.7600f};
|
|
static float hpr[3] = {140.000f,-17.0000f,0.0000f};
|
|
dsSetViewpoint (xyz,hpr);
|
|
}
|
|
|
|
void DrawStuff::step(int) {
|
|
std::vector<DrawStuffObject *>::iterator it ;
|
|
for( it = objects.begin() ; it != objects.end() ; it++ ) {
|
|
(*it)->draw() ;
|
|
}
|
|
}
|
|
|
|
DrawStuff::DrawStuff() :
|
|
fn(),
|
|
window_width(1024),
|
|
window_height(768)
|
|
{
|
|
fn.version = DS_VERSION;
|
|
fn.path_to_textures = "/users/alin/ode-0.14/drawstuff/textures";
|
|
|
|
fn.start = &DrawStuff::start ;
|
|
fn.step = &DrawStuff::step ;
|
|
}
|
|
|
|
int DrawStuff::draw() {
|
|
dsSimulationLoop(0 , NULL, window_width, window_height, &fn) ;
|
|
return 0 ;
|
|
}
|
|
|
|
int DrawStuff::shutdown() {
|
|
dsStop() ;
|
|
// wait a second to allow time for the loop to exit. Yeah, it's unscientific.
|
|
sleep(1) ;
|
|
return 0 ;
|
|
}
|
|
|
|
void DrawStuff::add_object( DrawStuffObject * dso ) {
|
|
objects.push_back(dso) ;
|
|
}
|