diff --git a/Makefile b/Makefile index 88a55c1..c7fc09e 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ CXXFLAGS = -I./ -DSTRICT_MEM -DDEBUG -DTIXML_USE_STL -g3 -Wall #endif TINYXML_USE_STL := YES +DEVELOPER_SDK_DIR := /opt/mac/SDKs + +CFLAGS := -isysroot /opt/mac/SDKs/MacOSX10.5.sdk CPPFILES := $(wildcard *.cpp) $(wildcard tinyxml/*.cpp) $(wildcard ext/*.cpp) OFILES := $(CPPFILES:.cpp=.o) @@ -34,8 +37,9 @@ lab: $(OFILES) w32: $(OBJFILES) i586-mingw32msvc-g++ *.OBJ tinyxml/*.OBJ glut32.lib -lGL -lGLU -g3 -Wall -o l-echo.exe +%.DO: CXXFLAGS += -isysroot /opt/mac/SDKs/MacOSX10.5.sdk -I/opt/mac/SDKs/MacOSX10.5.sdk/usr/include %.DO: %.cpp - powerpc-apple-darwin8-g++ -arch i386 -arch ppc $(CXXFLAGS) -c -o $@ $< + powerpc-apple-darwin8-g++ -arch i386 -arch ppc $(CXXFLAGS) -c -o $@ $< mac: $(DOFILES) powerpc-apple-darwin8-g++ -arch i386 -arch ppc *.DO tinyxml/*.DO -framework OpenGL -framework GLUT -g3 -Wall -o l-echo-mac diff --git a/echo_char_joints.cpp b/echo_char_joints.cpp new file mode 100644 index 0000000..ae75d47 --- /dev/null +++ b/echo_char_joints.cpp @@ -0,0 +1,32 @@ +// echo_char_joints.cpp + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include +#include + +int reset_joints(echo_char_joints* joints) +{ + if(!joints) + return(FAIL); + for(int each = 0; each < NUM_VALUES; each++) + joints->value[each] = 0; + //joints->waist_turn = 60; + return(WIN); +} diff --git a/echo_char_joints.h b/echo_char_joints.h new file mode 100644 index 0000000..582aa09 --- /dev/null +++ b/echo_char_joints.h @@ -0,0 +1,114 @@ +// echo_char_joints.h + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include + +#ifndef __ECHO_CHAR_JOINTS__ +#define __ECHO_CHAR_JOINTS__ +#define NUM_VALUES 27 //just count them +/** This union represents the joints and possible ways of bending them (at least, based on my body) + * This is setup so that there are two ways to access a value: + * 1) joints->[joint/body part]_[axis of rotation] (front is negative z, up is positive y, right is negative x) + * (positive is clockwise) + * 2) joints->[joint/body part (may be different)]_[action] + * For example: lhand_x is the same as lwrist + **/ +typedef union +{ + float value[27]; + struct + { + float head_x; //nodding + float head_y; //turning head + float head_z; //tilting head + float waist_y; //turning waist + float waist_z; //bowing + + float lthigh_x; //lifting leg + float lthigh_y; //twisting leg (roll) + float lthigh_z; //opening legs + + float lleg_x; //bending leg + float lfoot_x; //flexing foot + + float rthigh_x; //lifting leg + float rthigh_y; //twisting leg (roll) + float rthigh_z; //opening legs + + float rleg_x; //bending leg + float rfoot_x; //flexing foot + + float lshoulder_z; //flapping arms + float lshoulder_y; //pushing out + float lshoulder_x; //swinging arms + + float larm_x; //bending elbow + float larm_y; //twisting arm + float lhand_x; //wrist + + float rshoulder_z; //flapping arms + float rshoulder_y; //pushing out + float rshoulder_x; //swinging arms + + float rarm_x; //bending elbow + float rarm_y; //twisting arm + float rhand_x; //wrist + }; + struct + { + float head_nod; //nodding + float head_turn; //turning head + float head_tilt; //tilting head + float waist_turn; //turning waist + float waist_bow; //bowing + + float lthigh_lift; //lifting leg + float lthigh_twist; //twisting leg (roll) + float lthigh_open; //opening legs + + float lleg_bend; //bending leg + float lfoot_bend; //flexing foot + + float rthigh_lift; //lifting leg + float rthigh_twist; //twisting leg (roll) + float rthigh_open; //opening legs + + float rleg_bend; //bending leg + float rfoot_bend; //flexing foot + + float lshoulder_flap; //flapping arms + float lshoulder_push; //pushing out + float lshoulder_swing; //swinging arms + + float larm_bend; //bending elbow + float larm_twist; //twisting arm + float lwrist; //wrist + + float rshoulder_flap; //flapping arms + float rshoulder_push; //pushing out + float rshoulder_swing; //swinging arms + + float rarm_bend; //bending elbow + float rarm_twist; //twisting arm + float rwrist; //wrist + }; +} echo_char_joints; + +int reset_joints(echo_char_joints* joints); +#endif diff --git a/echo_character.cpp b/echo_character.cpp index 167df93..48c4361 100644 --- a/echo_character.cpp +++ b/echo_character.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include #include +#include #include #include @@ -55,7 +57,7 @@ #define SPEED_FALL_FROM_SKY 0.15f #else //various character speeds - #define SPEED_STEP 0.08f + #define SPEED_STEP 0.12f #define SPEED_RUN 0.25f #define SPEED_FALL 0.50f #define SPEED_LAUNCH 0.30f @@ -145,6 +147,9 @@ void echo_char::init(grid * g1) start = grid1 = g1; grid2 = g1 ? grid1->get_next(echo_ns::angle, grid1) : NULL; + dist_traveled = 0; + dist_traveled_cyclic = 0; + paused = 0; grid1per = 1; grid2per = 0; @@ -157,6 +162,7 @@ void echo_char::init(grid * g1) #ifdef HAS_ACCEL is_accel = NO_FALL; #endif + reset_joints(&joints); change_speed(); } @@ -247,9 +253,25 @@ void echo_char::step() vector3f pos2 = i2->pos; if(!paused) { + dist_traveled += speed; + dist_traveled_cyclic += speed * 180; + if(dist_traveled_cyclic > 720) + { + dist_traveled -= 4; + dist_traveled_cyclic -= 720; + } dist = pos1.dist(pos2); - grid1per -= speed / dist; //step thru it - grid2per += speed / dist; + if((dist_traveled > 0.5f && dist_traveled <= 1) + || (dist_traveled > 2.5f && dist_traveled <= 3)) + { + grid1per -= (1 + 0.75f * echo_cos(360 * dist_traveled)) * speed / dist; //step thru it + grid2per += (1 + 0.75f * echo_cos(360 * dist_traveled)) * speed / dist; + } + else + { + grid1per -= speed / dist; //step thru it + grid2per += speed / dist; + } #ifdef HAS_ACCEL if(is_accel == FALL_FROM_HOLE) speed += ACCEL; @@ -269,10 +291,6 @@ void echo_char::step() if(i2) { vector3f pos2 = i2->pos; - draw(pos1.x * grid1per + pos2.x * grid2per, - pos1.y * grid1per + pos2.y * grid2per, - pos1.z * grid1per + pos2.z * grid2per); - return; } } } @@ -309,6 +327,43 @@ void echo_char::draw(float x, float y, float z) //* gfx_push_matrix(); gfx_translatef(x, y, z); + float main_per = 0; + grid* main_grid = NULL; + if(grid1 && grid1per >= 0.5f) + { + main_per = grid1per; + main_grid = grid1; + } + else if(grid2 && grid2per >= 0.5f) + { + main_per = grid2per; + main_grid = grid2; + } + if(main_grid) + { + gfx_translatef(0, grid2->vert_shift(main_per), 0); + joints.rshoulder_swing = -20 * echo_cos(dist_traveled_cyclic / 2); + joints.lshoulder_swing = 20 * echo_cos(dist_traveled_cyclic / 2); + joints.rarm_bend = -10 * echo_cos(dist_traveled_cyclic / 2) - 20; + joints.larm_bend = 10 * echo_cos(dist_traveled_cyclic / 2) - 20; + joints.rthigh_lift = -45 * echo_cos(dist_traveled_cyclic / 2); + joints.lthigh_lift = 45 * echo_cos(dist_traveled_cyclic / 2); + + #define LEG_BEND_MAX 30 + + if(dist_traveled > 1 && dist_traveled <= 1.5f) + joints.rleg_bend = LEG_BEND_MAX * echo_cos(dist_traveled * 180 + 180); + else if(dist_traveled > 3.0f || dist_traveled <= 1) + joints.rleg_bend = LEG_BEND_MAX * echo_sin(dist_traveled * 45); + else + joints.rleg_bend = 0; + if(dist_traveled > 3 && dist_traveled <= 3.5f) + joints.lleg_bend = LEG_BEND_MAX * echo_cos(dist_traveled * 180 + 180); + else if(dist_traveled > 1.0f && dist_traveled <= 3) + joints.lleg_bend = LEG_BEND_MAX * echo_sin(dist_traveled * 45 - 90); + else + joints.lleg_bend = 0; + } if(grid1 && grid2) { grid_info_t* i1 = grid1->get_info(echo_ns::angle); @@ -322,13 +377,14 @@ void echo_char::draw(float x, float y, float z) #ifndef ECHO_NDS //gfx_colorf gfx_outline_start(); - draw_character(); + draw_character(&joints); gfx_outline_mid(); - draw_character(); + draw_character(&joints); gfx_outline_end(); + //ECHO_PRINT("joints->rthigh_lift: %f\n", joints.rthigh_lift); #else gfx_set_polyID(1); - draw_character(); + draw_character(&joints); #endif gfx_pop_matrix(); // */ diff --git a/echo_character.h b/echo_character.h index c11294d..2b740e4 100644 --- a/echo_character.h +++ b/echo_character.h @@ -20,6 +20,7 @@ #include #include #include +#include #ifndef __ECHO_CHARACTER__ #define __ECHO_CHARACTER__ @@ -52,8 +53,12 @@ class echo_char dist is the distance between the two grids. weight +=/-= (speed / dist) each step; + + dist_traveled is used to remember the amount of distance traveled so that I can do animations accordingly */ - float grid1per, grid2per, startper, speed, dist, act_speed; + float grid1per, grid2per, startper, speed, dist, act_speed, dist_traveled, dist_traveled_cyclic; + //the rotations of the joints + echo_char_joints joints; public: //default constructor diff --git a/echo_debug.h b/echo_debug.h index 846a791..6dc447c 100644 --- a/echo_debug.h +++ b/echo_debug.h @@ -26,6 +26,7 @@ #else #include + //#warning "lol" #define ECHO_PRINT printf #endif diff --git a/echo_error.h b/echo_error.h index 1dcc285..536156e 100644 --- a/echo_error.h +++ b/echo_error.h @@ -20,6 +20,9 @@ #include #include +#define WIN 0 +#define FAIL -1 + void lderr(const char* msg); void ldmemerr(); void lderr(const char* msg1, const char* msg2); diff --git a/echo_gfx.cpp b/echo_gfx.cpp index 72b288b..543168c 100644 --- a/echo_gfx.cpp +++ b/echo_gfx.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -172,13 +173,24 @@ void draw_goal_gfx(vector3f pos) glPushMatrix(); glColor3f(0, 0, 0); glTranslatef(pos.x, pos.y, pos.z); - draw_character(); + draw_character(NULL); POP_MATRIX; } } -void draw_character() +void draw_character(echo_char_joints* joints) { + if(joints == NULL) + { + static echo_char_joints* null_joints = NULL; + if(null_joints == NULL) + { + null_joints = new(echo_char_joints); + CHKPTR(null_joints); + reset_joints(null_joints); + } + joints = null_joints; + } #ifdef LAB glPushMatrix(); glTranslatef(0, 1.875f, 0); @@ -191,74 +203,99 @@ void draw_character() glPushMatrix(); //neck, head glTranslatef(0, 0.3f, 0); draw_sphere_pointzero75(); + gfx_rotatef(joints->head_x, 1, 0, 0); + gfx_rotatef(joints->head_y, 0, 1, 0); + gfx_rotatef(joints->head_z, 0, 0, 1); glTranslatef(0, 0.3f, 0); draw_head(); POP_MATRIX; glPushMatrix(); //left hand glTranslatef(0.2f, 0.2f, 0); draw_sphere_pointzero75(); - gfx_rotatef(12, 0, 0, 1); + gfx_rotatef(joints->lshoulder_x, 1, 0, 0); + gfx_rotatef(joints->lshoulder_y, 0, 1, 0); + gfx_rotatef(12 + joints->lshoulder_z, 0, 0, 1); glTranslatef(0, -0.05f, 0); draw_limb(); glTranslatef(0, -0.45f, 0); draw_sphere_pointzero75(); + gfx_rotatef(joints->larm_x, 1, 0, 0); + gfx_rotatef(joints->larm_y, 0, 1, 0); gfx_rotatef(-12, 0, 0, 1); glTranslatef(0, -0.05f, 0); draw_limb(); glTranslatef(0, -0.45f, 0); draw_sphere_pointzero75(); + gfx_rotatef(joints->lhand_x, 1, 0, 0); glTranslatef(-0.03f, -0.06f, 0); draw_left_hand(); POP_MATRIX; glPushMatrix(); //right hand glTranslatef(-0.2f, 0.2f, 0); draw_sphere_pointzero75(); - gfx_rotatef(-12, 0, 0, 1); + gfx_rotatef(joints->rshoulder_x, 1, 0, 0); + gfx_rotatef(joints->rshoulder_y, 0, 1, 0); + gfx_rotatef(-12 + joints->rshoulder_z, 0, 0, 1); glTranslatef(0, -0.05f, 0); draw_limb(); glTranslatef(0, -0.45f, 0); draw_sphere_pointzero75(); + gfx_rotatef(joints->rarm_x, 1, 0, 0); + gfx_rotatef(joints->rarm_y, 0, 1, 0); gfx_rotatef(12, 0, 0, 1); glTranslatef(0, -0.05f, 0); draw_limb(); glTranslatef(0, -0.45f, 0); draw_sphere_pointzero75(); + gfx_rotatef(joints->rhand_x, 1, 0, 0); glTranslatef(0.03f, -0.06f, 0); draw_right_hand(); POP_MATRIX; - glPushMatrix(); //left leg - glTranslatef(0.1f, -0.7f, 0); - draw_sphere_pointzero75(); - glTranslatef(0, -0.05f, 0); - draw_limb(); - glTranslatef(0, -0.45f, 0); - draw_sphere_pointzero75(); - glTranslatef(0, -0.05f, 0); - draw_limb(); - glTranslatef(0, -0.45f, 0); - draw_sphere_pointzero75(); - glTranslatef(0.01f, -0.15f, -0.075f); - draw_foot(); - POP_MATRIX; - glPushMatrix(); //right leg - glTranslatef(-0.1f, -0.7f, 0); - draw_sphere_pointzero75(); - glTranslatef(0, -0.05f, 0); - draw_limb(); - glTranslatef(0, -0.45f, 0); - draw_sphere_pointzero75(); - glTranslatef(0, -0.05f, 0); - draw_limb(); - glTranslatef(0, -0.45f, 0); - draw_sphere_pointzero75(); - glTranslatef(-0.01f, -0.15f, -0.075f); - draw_foot(); - POP_MATRIX; glPushMatrix(); //waist, lower body glTranslatef(0, -0.32f, 0); draw_sphere_point1(); + gfx_rotatef(joints->waist_y, 0, 1, 0); + gfx_rotatef(joints->waist_z, 0, 0, 1); glTranslatef(0, -0.32f, 0); draw_lower_body(); + glPushMatrix(); //left leg + glTranslatef(0.1f, -0.06f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->lthigh_x, 1, 0, 0); + gfx_rotatef(joints->lthigh_y, 0, 1, 0); + gfx_rotatef(joints->lthigh_z, 0, 0, 1); + glTranslatef(0, -0.05f, 0); + draw_limb(); + glTranslatef(0, -0.45f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->lleg_x, 1, 0, 0); + glTranslatef(0, -0.05f, 0); + draw_limb(); + glTranslatef(0, -0.45f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->lfoot_x, 1, 0, 0); + glTranslatef(0.01f, -0.15f, -0.075f); + draw_foot(); + POP_MATRIX; + glPushMatrix(); //right leg + glTranslatef(-0.1f, -0.06f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->rthigh_x, 1, 0, 0); + gfx_rotatef(joints->rthigh_y, 0, 1, 0); + gfx_rotatef(joints->rthigh_z, 0, 0, 1); + glTranslatef(0, -0.05f, 0); + draw_limb(); + glTranslatef(0, -0.45f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->rleg_x, 1, 0, 0); + glTranslatef(0, -0.05f, 0); + draw_limb(); + glTranslatef(0, -0.45f, 0); + draw_sphere_pointzero75(); + gfx_rotatef(joints->rfoot_x, 1, 0, 0); + glTranslatef(-0.01f, -0.15f, -0.075f); + draw_foot(); + POP_MATRIX; POP_MATRIX; POP_MATRIX; #endif diff --git a/echo_gfx.h b/echo_gfx.h index 102a78e..628a227 100644 --- a/echo_gfx.h +++ b/echo_gfx.h @@ -18,6 +18,7 @@ */ #include +#include #include void draw_line(float x1, float y1, float z1, float x2, float y2, float z2); @@ -41,7 +42,7 @@ void draw_limb(); void draw_hole(vector3f pos); void draw_launcher(vector3f pos); void draw_goal_gfx(vector3f pos); -void draw_character(); +void draw_character(echo_char_joints* joints); void draw_stairs(); void draw_left_hand(); void draw_right_hand(); diff --git a/echo_loader.cpp b/echo_loader.cpp index 8c18d40..203137e 100644 --- a/echo_loader.cpp +++ b/echo_loader.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ #include #include -#ifdef ARM9 +#ifdef ECHO_NDS #include #else #include @@ -144,7 +145,7 @@ class trigger_functor : public functor typedef std::vector FUNCTOR_VEC; typedef std::map DEPENDENCY_MAP; -#ifdef ARM9 +#ifdef ECHO_NDS static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgrid* escroot , LEVEL_MAP* nonffgrids, LEVEL_MAP* ffgrids); #else @@ -161,7 +162,7 @@ stage* load_stage(const char* file_name) LD_CHKPTR(map); stage* ret = new stage(); LD_CHKPTR(ret); -#ifdef ARM9 +#ifdef ECHO_NDS LEVEL_MAP* nonffgrids = new LEVEL_MAP(); LD_CHKPTR(nonffgrids); LEVEL_MAP* ffgrids = new LEVEL_MAP(); @@ -174,7 +175,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -185,7 +186,7 @@ stage* load_stage(const char* file_name) { if(child->Type() == TiXmlNode::ELEMENT) { -#ifdef ARM9 +#ifdef ECHO_NDS if(!parse_grid(child->ToElement(), ret, map, NULL, nonffgrids, ffgrids)) #else if(!parse_grid(child->ToElement(), ret, map, NULL)) @@ -198,7 +199,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -212,7 +213,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -227,7 +228,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -241,7 +242,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -255,7 +256,7 @@ stage* load_stage(const char* file_name) delete doc; delete map; delete ret; -#ifdef ARM9 +#ifdef ECHO_NDS delete nonffgrids; delete ffgrids; #endif @@ -266,7 +267,7 @@ stage* load_stage(const char* file_name) if(!map->empty()) ldwarn("dependencies not satisfied..."); delete map; -#ifdef ARM9 +#ifdef ECHO_NDS #define GRID_POLYID_START 19 unsigned int polyID = GRID_POLYID_START; LEVEL_MAP::iterator it = nonffgrids->begin(), end = nonffgrids->end(); @@ -421,7 +422,7 @@ static int get_angle(TiXmlElement* txe, vector3f* vec) return(get_float(txe, "x", &vec->x) && get_float(txe, "y", &vec->y)); } -#ifdef ARM9 +#ifdef ECHO_NDS static int add_esc(TiXmlElement* child, stage* st, DEPENDENCY_MAP* map, escgrid* escroot, escgrid* egrid , LEVEL_MAP* nonffgrids, LEVEL_MAP* ffgrids) #else @@ -435,7 +436,7 @@ static int add_esc(TiXmlElement* child, stage* st, DEPENDENCY_MAP* map, escgrid* LD_CHKPTR(each_angle); if(!get_angle(child, each_angle)) return(0); -#ifdef ARM9 +#ifdef ECHO_NDS grid* g = parse_grid(child->FirstChild()->ToElement(), st, map, escroot ? escroot : egrid, nonffgrids, ffgrids); #else grid* g = parse_grid(child->FirstChild()->ToElement(), st, map, escroot ? escroot : egrid); @@ -453,7 +454,7 @@ static int add_esc(TiXmlElement* child, stage* st, DEPENDENCY_MAP* map, escgrid* LD_CHKPTR(v2); if(!get_float(child, "x_max", &v2->x) || !get_float(child, "y_max", &v2->y)) return(0); -#ifdef ARM9 +#ifdef ECHO_NDS grid* g = parse_grid(child->FirstChild()->ToElement(), st, map, escroot ? escroot : egrid, nonffgrids, ffgrids); #else grid* g = parse_grid(child->FirstChild()->ToElement(), st, map, escroot ? escroot : egrid); @@ -469,7 +470,7 @@ static int add_esc(TiXmlElement* child, stage* st, DEPENDENCY_MAP* map, escgrid* return(1); } -#ifdef ARM9 +#ifdef ECHO_NDS static int add_escs(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgrid* escroot, escgrid* grid , LEVEL_MAP* nonffgrids, LEVEL_MAP* ffgrids) #else @@ -482,7 +483,7 @@ static int add_escs(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgrid* while(child) { if(child->Type() == TiXmlNode::ELEMENT && strcmp(child->Value(), "triggers")) -#ifdef ARM9 +#ifdef ECHO_NDS add_esc(child->ToElement(), st, map, escroot, grid, nonffgrids, ffgrids); #else add_esc(child->ToElement(), st, map, escroot, grid); @@ -672,7 +673,7 @@ static int add_triggers(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, grid* return(1); } -#ifdef ARM9 +#ifdef ECHO_NDS static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgrid* escroot , LEVEL_MAP* nonffgrids, LEVEL_MAP* ffgrids) #else @@ -741,7 +742,7 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr LD_PRINT("%s is a escgrid!\n", name); new_grid = new escgrid(info, prev, next); LD_CHKPTR(new_grid); -#ifdef ARM9 +#ifdef ECHO_NDS if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid, nonffgrids, ffgrids)) #else if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid)) @@ -757,7 +758,7 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr LD_PRINT("%s is an hole!\n", name); new_grid = new hole(info, prev, next); LD_CHKPTR(new_grid); -#ifdef ARM9 +#ifdef ECHO_NDS if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid, nonffgrids, ffgrids)) #else if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid)) @@ -773,7 +774,7 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr LD_PRINT("%s is a launcher!\n", name); new_grid = new launcher(info, prev, next); LD_CHKPTR(new_grid); -#ifdef ARM9 +#ifdef ECHO_NDS if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid, nonffgrids, ffgrids)) #else if(!add_escs(txe, st, map, escroot, (escgrid*)new_grid)) @@ -843,7 +844,7 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr delete info; return(NULL); } -#ifdef ARM9 +#ifdef ECHO_NDS if(!strcmp(type, "freeform_grid")) map_add_pos(ffgrids, info->pos, new_grid); else if(strcmp(type, "stair")) diff --git a/echo_ns.cpp b/echo_ns.cpp index 33fc890..171c21c 100644 --- a/echo_ns.cpp +++ b/echo_ns.cpp @@ -93,11 +93,11 @@ namespace echo_ns gfx_translatef(info->pos.x, info->pos.y, info->pos.z); #ifndef ECHO_NDS gfx_outline_start(); - draw_character(); + draw_character(NULL); gfx_outline_mid(); #endif gfx_color3f(null_char_opacity, null_char_opacity, null_char_opacity); - draw_character(); + draw_character(NULL); #ifndef ECHO_NDS gfx_outline_end(); #endif diff --git a/echo_prefs.cpp b/echo_prefs.cpp new file mode 100644 index 0000000..003c242 --- /dev/null +++ b/echo_prefs.cpp @@ -0,0 +1,87 @@ +// echo_prefs.cpp + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include +#include +#include +#include + +#ifdef ECHO_NDS + #ifndef __ECHO_NDS_PREFS__ + #define __ECHO_NDS_PREFS__ + + #define HAND_ATTR_NAME "handedness" + #define HAND_LEFT_VALUE "left" + #define HAND_RIGHT_VALUE "right" + #define PREFS_FILE "/apps/n-echo/prefs.xml" + #include + int open_prefs(TiXmlDocument** document) + { + *document = new TiXmlDocument(PREFS_FILE); + return((*document)->LoadFile() ? WIN : FAIL); + } + int get_hand(TiXmlDocument* document, enum HAND* handedness) + { + if(document) + { + TiXmlElement* root = document->Root(); + if(root) + { + const char* hand_str = root->Attribute(HAND_ATTR_NAME); + if(hand_str) + { + if(!strcmp(hand_str, HAND_LEFT_VALUE)) + { + *handedness = LEFT_HAND; + return(WIN); + } + else if(!strcmp(hand_str, HAND_RIGHT_VALUE)) + { + *handedness = RIGHT_HAND; + return(WIN); + } + } + } + } + return(FAIL); + } + int set_hand(TiXmlDocument* document, enum HAND handedness) + { + if(document) + { + TiXmlElement* root = document->Root(); + if(root) + { + root->SetAttribute(HAND_ATTR_NAME, handedness == LEFT_HAND ? HAND_LEFT_VALUE : HAND_RIGHT_VALUE); + return(WIN); + } + } + return(FAIL); + } + int close_prefs(TiXmlDocument* doocument) + { + if(document->SaveFile(PREFS_FILE) == FALSE) + return(FAIL); + delete document; + return(WIN); + } + #endif +#endif + + diff --git a/echo_prefs.h b/echo_prefs.h new file mode 100644 index 0000000..eb0427d --- /dev/null +++ b/echo_prefs.h @@ -0,0 +1,30 @@ +// echo_prefs.h + +/* + This file is part of L-Echo. + + L-Echo is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + L-Echo is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with L-Echo. If not, see . +*/ + +#include + +#ifdef ECHO_NDS + enum { LEFT_HAND, RIGHT_HAND } HAND; + + int open_prefs(TiXmlDocument** document); + int get_hand(TiXmlDocument* document, enum HAND* handedness); + int set_hand(TiXmlDocument* document, enum HAND handedness); + int close_prefs(TiXmlDocument* document); +#endif + diff --git a/grid.cpp b/grid.cpp index 9acad1d..1245a26 100644 --- a/grid.cpp +++ b/grid.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -258,7 +259,11 @@ int grid::is_pt_on(vector3f angle, vector3f pt) && ABS(pos.z - pt.z) < HALF_GRID); } -#ifdef ARM9 +float grid::vert_shift(float percent_in) +{ + return(0.1f * echo_cos(60 - 60 * percent_in) - 0.15f); +} +#ifdef ECHO_NDS unsigned int grid::get_polyID(vector3f angle) { return(polyID); diff --git a/grid.h b/grid.h index 6c32a7d..3ec1b9f 100644 --- a/grid.h +++ b/grid.h @@ -21,6 +21,7 @@ #include #include #include +#include #define GRID_SIZE 1 #define HALF_GRID 0.5f @@ -61,7 +62,7 @@ class grid vector3f** points; -#ifdef ARM9 +#ifdef ECHO_NDS unsigned int polyID; #endif public: @@ -102,10 +103,12 @@ class grid virtual void draw(vector3f angle); virtual int is_pt_on(vector3f angle, vector3f pt); + + virtual float vert_shift(float percent_in); void draw_goal(vector3f angle); -#ifdef ARM9 +#ifdef ECHO_NDS virtual unsigned int get_polyID(vector3f angle); void set_polyID(unsigned int my_polyID); #endif diff --git a/large_hole_demo.xml b/large_hole_demo.xml new file mode 100755 index 0000000..e36aa1a --- /dev/null +++ b/large_hole_demo.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/main.cpp b/main.cpp index fc38ab1..fc5d7ba 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -188,6 +190,10 @@ static vector3f real_angle(0, 0, 0); //the current directory static echo_files* files = NULL; +#ifdef ECHO_NDS + static int left, right, up, down; +#endif + //--METHODS #ifdef ECHO_NDS @@ -257,17 +263,42 @@ int main(int argc, char **argv) #ifdef ECHO_NDS //initialize the file system fatInitDefault(); + + TiXmlDocument* doc = NULL; + if(open_pref(&doc) == WIN) + { + HAND* hand = NULL; + if(get_hand(doc, hand) == WIN) + { + if(*hand == RIGHT_HAND) + { + left = KEY_LEFT; + right = KEY_RIGHT; + up = KEY_UP; + down = KEY_DOWN; + } + else + { + left = KEY_Y; + right = KEY_A; + up = KEY_X; + down = KEY_B; + } + } + close_pref(doc); + } + //get the files - files = get_files("/"); + files = get_files("/app/nds"); //initialize the screens init(argc, argv, 255, 191); //load the menu load(NULL); //infinite loop while(1) - { + { //get the key presses and touch screen, and refresh topscreen if in info or loader mode - get_key(); + get_key(); //otherwise the 3D will paint anyways, so don't paint over. if(!menu_mode) { @@ -277,12 +308,27 @@ int main(int argc, char **argv) glFlush(0); } //otherwise we won't sync - swiWaitForVBlank(); - } + swiWaitForVBlank(); + } #elif ECHO_PC + echo_char_joints* joints = new(echo_char_joints); + joints->rwrist = 10; + ECHO_PRINT("joints.rwrist: %f\n", joints->rwrist); + ECHO_PRINT("joints.rhand_x: %f\n", joints->rhand_x); + ECHO_PRINT("joints.lhand_x: %f\n", joints->lhand_x); + joints->lwrist = 20; + ECHO_PRINT("joints.rwrist: %f\n", joints->rwrist); + ECHO_PRINT("joints.rhand_x: %f\n", joints->rhand_x); + ECHO_PRINT("joints.lhand_x: %f\n", joints->lhand_x); + reset_joints(joints); + ECHO_PRINT("joints.rwrist: %f\n", joints->rwrist); + ECHO_PRINT("joints.rhand_x: %f\n", joints->rhand_x); + ECHO_PRINT("joints.lhand_x: %f\n", joints->lhand_x); + delete joints; + //fill lookup tables init_math(); - #ifdef WIN32 //goddammit windows, adhere to POSIX! + #ifdef ECHO_WIN //goddammmit windows, adhere to POSIX! TCHAR buffer[MAX_PATH] = ""; GetCurrentDirectory(MAX_PATH, buffer); files = get_files(buffer); @@ -878,12 +924,14 @@ static void display() { glColor3f(0, 0, 0); draw_message_string(-2, 3, "L-Echo"); - draw_string(-3, 0, "Please load a stage."); - draw_string(-6, -2, "Press L To Toggle Loader."); - draw_string(-6, -2.5, "Press P To Start/Pause/Resume."); - draw_string(-6, -3, "Press Arrow Keys or use Mouse to "); - draw_string(-3, -3.5, "Rotate World."); - draw_string(-6, -4, "Press Esc To Quit."); + draw_string(-3, -0.5, "Please load a stage."); + draw_string(-6, -1.5, "Press L To Toggle Loader."); + draw_string(-6, -2, "Press P To Start/Pause/Resume."); + draw_string(-6, -2.5, "Press W To Walk."); + draw_string(-6, -3, "Press R to Run."); + draw_string(-6, -3.5, "Press Arrow Keys or use Mouse to "); + draw_string(-3, -4, "Rotate World."); + draw_string(-6, -4.5, "Press Esc To Quit."); } //draw the loader @@ -986,11 +1034,12 @@ static void display() } else if(!menu_mode) { - if((key & KEY_L) || (key & KEY_R)) start_or_pause(); - if((key & KEY_RIGHT) || (key & KEY_A)) right(); - if((key & KEY_LEFT) || (key & KEY_Y)) left(); - if((key & KEY_DOWN) || (key & KEY_B)) down(); - if((key & KEY_UP) || (key & KEY_X)) up(); + if((key & KEY_L) || (key & KEY_R)) + start_or_pause(); + if(key & right) right(); + if(key & left) left(); + if(key & down) down(); + if(key & up) up(); } if(key & KEY_START) { diff --git a/walkway.xml b/walkway.xml new file mode 100755 index 0000000..f633efd --- /dev/null +++ b/walkway.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +