Skip to content

Commit

Permalink
started modification to separate freeform_grids (used for obstacles) …
Browse files Browse the repository at this point in the history
…and stairs (which can only be angled about the y axis, but actually look like stairs)
  • Loading branch information
penguin673 committed Jul 3, 2008
1 parent b3989fc commit ec06b9e
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 63 deletions.
12 changes: 6 additions & 6 deletions A1.xml.real
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@
</trigger>
</triggers>
</grid>
<stair id="s1" x="2" y="-1.5f" z="0" prev="g1" next="g2">
<freeform_grid id="s1" x="2" y="-1.5f" z="0" prev="g1" next="g2">
<angle x="-0.5f" y="0.5f" z="0"/>
<angle x="0" y="0" z="0.5f" />
</stair>
</freeform_grid>
<grid id="g2" x="3" y="-2" z="0" prev="s1" next="s2" />
<stair id="s2" x="3" y="-2.5f" z="1" prev="g2" next="g3">
<freeform_grid id="s2" x="3" y="-2.5f" z="1" prev="g2" next="g3">
<angle x="0" y="-.5f" z=".5f" />
<angle x="0.5f" y="0" z="0" />
</stair>
</freeform_grid>

<escgrid id="g4" x="2" y="-3" z="2" prev="g3" next="g3">
<!-- lol -->
<angle x="-35" y="-25">
<grid id="g4" x="2" y="-3" z="2" prev="g3" next="st1"/>
</angle>
</escgrid>
<stair id="s3" x="3" y="-3.5f" z="3" prev="g3" next="g5">
<freeform_grid id="s3" x="3" y="-3.5f" z="3" prev="g3" next="g5">
<angle x="0" y="-.5f" z=".5f" />
<angle x="0.5f" y="0" z="0" />
</stair>
</freeform_grid>
<t_grid id="g3" x="3" y="-3" z="2" prev="s2" next="g4" next2="s3"/>

<grid id="g5" x="3" y="-4" z="4" prev="s3" next="s3" goal="1">
Expand Down
89 changes: 89 additions & 0 deletions A4.xml.real
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" standalone="no" ?>
<stage name="A4" start="start" goals="3">
<freeform_grid id="p_east" x="0.75f" y="0" z="0" prev="NONE" next="NONE" noland="1">
<angle x="0" y="3" z="0" />
<angle x="0" y="0" z="0.75f" />
</freeform_grid>
<freeform_grid id="p_west" x="-0.75f" y="0" z="0" prev="NONE" next="NONE" noland="1">
<angle x="0" y="3" z="0" />
<angle x="0" y="0" z="0.75f" />
</freeform_grid>
<freeform_grid id="p_south" x="0" y="0" z="0.75f" prev="NONE" next="NONE" noland="1">
<angle x="0" y="3" z="0" />
<angle x="0.75f" y="0" z="0" />
</freeform_grid>
<freeform_grid id="p_north" x="0" y="0" z="-0.75f" prev="NONE" next="NONE" noland="1">
<angle x="0" y="3" z="0" />
<angle x="0.75f" y="0" z="0" />
</freeform_grid>

<grid id="west6" x="-5" y="0" z="-3" prev="west5" next="north1" goal="1">
<triggers>
<trigger id="start">
<not>
<goal id="south8" />
</not>
</trigger>
</triggers>
</grid>

<grid id="start" x="3" y="0" z="-3" prev="north7" next="east1" />
<grid id="east1" x="3" y="0" z="-2" prev="start" next="east2" />
<grid id="east2" x="3" y="0" z="-1" prev="east1" next="east3" />
<grid id="east3" x="3" y="0" z="0" prev="east2" next="east4" />
<grid id="east4" x="3" y="0" z="1" prev="east3" next="east5" />
<grid id="east5" x="3" y="0" z="2" prev="east4" next="east6" />
<grid id="east6" x="3" y="0" z="3" prev="east5" next="south1" />

<grid id="south1" x="2" y="0" z="3" prev="east6" next="south2" />
<hole id="south2" x="1" y="0" z="3" prev="south1" next="south3">
<range x_min="-40" x_max="40" y_min="-150" y_max="-170" z_min="0" z_max="0">
<grid id="south2_esc" x="1" y="0" z="3" prev="south1" next="south3"/>
</range>
</hole>
<grid id="south3" x="0" y="0" z="3" prev="south2" next="south4" />
<grid id="south4" x="-1" y="0" z="3" prev="south3" next="south5" />
<grid id="south5" x="-2" y="0" z="3" prev="south4" next="south6" />
<grid id="south6" x="-3" y="0" z="3" prev="south5" next="south7" />
<grid id="south7" x="-4" y="0" z="3" prev="south6" next="south8" />
<grid id="south8" x="-5" y="0" z="3" prev="south7" next="west1" goal="1">
<triggers>
<trigger id="start">
<not>
<goal id="west6" />
</not>
</trigger>
</triggers>
</grid>

<escgrid id="west1" x="-5" y="0" z="2" prev="south8" next="south8">
<range x_min="-40" x_max="40" y_min="100" y_max="105" z_min="0" z_max="0">
<grid id="west1_esc" x="-5" y="0" z="2" prev="south8" next="west2" />
</range>
</escgrid>
<grid id="west2" x="-5" y="0" z="1" prev="west1" next="west3" nodraw="1"/>
<escgrid id="west3" x="-5" y="0" z="0" prev="west4" next="west4">
<range x_min="-40" x_max="40" y_min="100" y_max="105" z_min="0" z_max="0">
<grid id="west3_esc" x="-5" y="0" z="0" prev="west2" next="west4" />
</range>
</escgrid>
<grid id="west4" x="-5" y="0" z="-1" prev="west3" next="west5" />
<grid id="west5" x="-5" y="0" z="-2" prev="west4" next="west6" />


<grid id="north1" x="-4" y="0" z="-3" prev="west6" next="north2" />
<grid id="north2" x="-3" y="0" z="-3" prev="north1" next="north3" />
<escgrid id="north3" x="-2" y="0" z="-3" prev="north2" next="north2">
<range x_min="-40" x_max="40" y_min="15" y_max="25" z_min="0" z_max="0">
<grid id="north3_esc" x="-2" y="0" z="-3" prev="north2" next="north4" />
</range>
</escgrid>
<grid id="north4" x="-1" y="0" z="-3" prev="north3" next="north5" nodraw="1"/>
<escgrid id="north5" x="0" y="0" z="-3" prev="north6" next="north6">
<range x_min="-40" x_max="40" y_min="15" y_max="25" z_min="0" z_max="0">
<grid id="north5_esc" x="0" y="0" z="-3" prev="north4" next="north6" />
</range>
</escgrid>
<grid id="north6" x="1" y="0" z="-3" prev="north5" next="north7" />
<grid id="north7" x="2" y="0" z="-3" prev="north6" next="start" />
</stage>
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ OBJFILES := $(CPPFILES:.cpp=.OBJ) #$(WINFILES:.cpp=.OBJ)
DOPFILES := $(CPPFILES:.cpp=.DOP)
DOIFILES := $(CPPFILES:.cpp=.DOI)

PKGPREFIX := ../l-echo-0.2.3_r40-
DESC := L-Echo 0.2.3
PKGPREFIX := ../l-echo-0.2.4_r41-
DESC := L-Echo 0.2.4

all: $(OFILES)
gcc tinyxml/*.o *.o -DTIXML_USE_STL -lGL -lGLU /usr/lib/libglut.so.3.8.0 -lpthread -g3 -Wall -o l-echo
Expand Down
5 changes: 0 additions & 5 deletions echo_gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ void draw_line(line3f ln)
draw_line(ln.p1, ln.p2);
}

static int has_line(line3f* ptr, line3f line)
{
return(ptr[0] == line || ptr[1] == line || ptr[2] == line || ptr[3] == line);
}

void draw_hole(vector3f pos)
{
glColor3f(0, 0, 0);
Expand Down
13 changes: 7 additions & 6 deletions echo_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
#include <echo_stage.h>

#include <launcher.h>
#include <stair.h>
#include <freeform_grid.h>
#include <t_grid.h>
#include <escgrid.h>
#include <hole.h>
#include <grid.h>
#include <stair.h>

#ifdef ARM9
#include <tinyxml.h>
Expand Down Expand Up @@ -520,26 +521,26 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr
LD_CHKPTR(new_grid);
add_escs(txe, st, map, escroot, (escgrid*)new_grid);
}
else if(!strcmp(type, "stair"))
else if(!strcmp(type, "freeform_grid"))
{
LD_PRINT("%s is a stair!\n", name);
LD_PRINT("%s is a freeform_grid!\n", name);
TiXmlNode* vec_element = txe->FirstChild();
while(vec_element != NULL && vec_element->Type() != TiXmlNode::ELEMENT)
vec_element = vec_element->NextSiblingElement();
if(!vec_element)
lderr("cannot find direction element of stair: " , name);
lderr("cannot find direction element of freeform_grid: " , name);
vector3f* dir_angle = new vector3f();
LD_CHKPTR(dir_angle);
get_vec(vec_element->ToElement(), dir_angle);
vec_element = vec_element->NextSibling();
while(vec_element != NULL && vec_element->Type() != TiXmlNode::ELEMENT)
vec_element = vec_element->NextSiblingElement();
if(!vec_element)
lderr("cannot find width element of stair: " , name);
lderr("cannot find width element of freeform_grid: " , name);
vector3f* width_angle = new vector3f();
LD_CHKPTR(width_angle);
get_vec(vec_element->ToElement(), width_angle);
new_grid = new stair(info, prev, next, dir_angle, width_angle);
new_grid = new freeform_grid(info, prev, next, dir_angle, width_angle);
LD_CHKPTR(new_grid);
}
else
Expand Down
12 changes: 12 additions & 0 deletions echo_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ vector3f* vector3f::rotate_about_y(float angle)
#endif
}

void vector3f::self_rotate_about_y(float angle)
{
float x_save = x;
x = z * ECHO_SINF(angle) + x * ECHO_COSF(angle);
z = z * ECHO_COSF(angle) - x_save * ECHO_SINF(angle);
}

vector3f* vector3f::angle_to_real()
{
#ifdef STRICT_MEM
Expand All @@ -240,3 +247,8 @@ vector3f* vector3f::angle_to_real()
#endif
}

int has_line(line3f* ptr, line3f line)
{
return(ptr[0] == line || ptr[1] == line || ptr[2] == line || ptr[3] == line);
}

3 changes: 3 additions & 0 deletions echo_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class vector3f
vector3f* rotate_xy(vector3f rot);
vector3f* neg_rotate_yx(vector3f rot);
vector3f* rotate_about_y(float angle);
void self_rotate_about_y(float angle);
vector3f* angle_to_real();

vector3f normalize_angle();
Expand All @@ -73,6 +74,8 @@ typedef struct
vector3f p2;
}
line3f;

int has_line(line3f* ptr, line3f line);
#endif

#ifndef __ECHO_ANGLE_RANGE__
Expand Down
72 changes: 72 additions & 0 deletions freeform_grid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// freeform_grid.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 <http://www.gnu.org/licenses/>.
*/

#include <cstdlib>

#include <echo_error.h>
#include <freeform_grid.h>
#include <echo_math.h>
#include <grid.h>

freeform_grid::freeform_grid() : grid()
{
init(NULL, NULL, NULL, new vector3f(0.5f, 0.5f, 0), new vector3f(0, 0, 0.5f));
}

freeform_grid::freeform_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width) : grid()
{
dir = my_dir;
width = my_width;
init(my_info, my_prev, my_next, my_dir, my_width);
}

void freeform_grid::init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width)
{
dir = my_dir;
width = my_width;
grid::init(my_info, my_prev, my_next);
}

void freeform_grid::init_to_null()
{
grid::init_to_null();
dir = NULL;
width = NULL;
}

line3f* freeform_grid::generate_lines(grid_info_t my_info)
{
line3f* ret = new line3f[4];
CHKPTR(ret);

vector3f pos = my_info.pos;
vector3f p1 = pos + *dir + *width;
vector3f p2 = pos - *dir + *width;
vector3f p3 = pos - *dir - *width;
vector3f p4 = pos + *dir - *width;

ret[0].p1 = p1; ret[0].p2 = p2;
ret[1].p1 = p2; ret[1].p2 = p3;
ret[2].p1 = p3; ret[2].p2 = p4;
ret[3].p1 = p4; ret[3].p2 = p1;

return(ret);
}


38 changes: 38 additions & 0 deletions freeform_grid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// freeform_grid.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 <http://www.gnu.org/licenses/>.
*/

#include <echo_math.h>
#include <grid.h>

#ifndef __ECHO_CLASS_FREEFORM_GRID__
#define __ECHO_CLASS_FREEFORM_GRID__
class freeform_grid : public grid
{
protected:
vector3f* dir;
vector3f* width;
public:
freeform_grid();
freeform_grid(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width);
void init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width);
virtual line3f* generate_lines(grid_info_t my_info);
virtual void init_to_null();
//virtual void draw(vector3f angle);
};
#endif
30 changes: 20 additions & 10 deletions grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ void grid::init(grid_info_t* my_info, grid* my_prev, grid* my_next, int my_num_n
lines = ginfo != NULL ? generate_lines(*ginfo) : NULL;
}

static int has_line(line3f* ptr, line3f line)
{
return(ptr[0] == line || ptr[1] == line || ptr[2] == line || ptr[3] == line);
}

static void dump_lines(line3f* ptr)
{
dump_line3f(ptr[0]);
Expand Down Expand Up @@ -173,17 +168,32 @@ line3f* grid::generate_lines(grid_info_t my_info)
{
line3f* ret = new line3f[4];
CHKPTR(ret);

#ifdef STRICT_MEM
vector3f* p1 = new vector3f(my_info.pos.x - HALF_GRID, my_info.pos.y, my_info.pos.z - HALF_GRID);
CHKPTR(p1);
vector3f* p2 = new vector3f(my_info.pos.x - HALF_GRID, my_info.pos.y, my_info.pos.z + HALF_GRID);
CHKPTR(p2);
vector3f* p3 = new vector3f(my_info.pos.x + HALF_GRID, my_info.pos.y, my_info.pos.z + HALF_GRID);
CHKPTR(p3);
vector3f* p4 = new vector3f(my_info.pos.x + HALF_GRID, my_info.pos.y, my_info.pos.z - HALF_GRID);
CHKPTR(p4);

vector3f pos = my_info.pos;
vector3f p1(pos.x - HALF_GRID, pos.y, pos.z - HALF_GRID);
vector3f p2(pos.x - HALF_GRID, pos.y, pos.z + HALF_GRID);
vector3f p3(pos.x + HALF_GRID, pos.y, pos.z + HALF_GRID);
vector3f p4(pos.x + HALF_GRID, pos.y, pos.z - HALF_GRID);
ret[0].p1 = *p1; ret[0].p2 = *p2;
ret[1].p1 = *p2; ret[1].p2 = *p3;
ret[2].p1 = *p3; ret[2].p2 = *p4;
ret[3].p1 = *p4; ret[3].p2 = *p1;
#else
vector3f p1(my_info.pos.x - HALF_GRID, my_info.pos.y, my_info.pos.z - HALF_GRID);
vector3f p2(my_info.pos.x - HALF_GRID, my_info.pos.y, my_info.pos.z + HALF_GRID);
vector3f p3(my_info.pos.x + HALF_GRID, my_info.pos.y, my_info.pos.z + HALF_GRID);
vector3f p4(my_info.pos.x + HALF_GRID, my_info.pos.y, my_info.pos.z - HALF_GRID);

ret[0].p1 = p1; ret[0].p2 = p2;
ret[1].p1 = p2; ret[1].p2 = p3;
ret[2].p1 = p3; ret[2].p2 = p4;
ret[3].p1 = p4; ret[3].p2 = p1;
#endif

return(ret);
}
Expand Down
Loading

0 comments on commit ec06b9e

Please sign in to comment.