diff --git a/A1.xml.real b/A1.xml.real
index c6f5d91..8dcfed7 100644
--- a/A1.xml.real
+++ b/A1.xml.real
@@ -9,15 +9,15 @@
-
+
-
+
-
+
-
+
@@ -25,10 +25,10 @@
-
+
-
+
diff --git a/A4.xml.real b/A4.xml.real
new file mode 100644
index 0000000..e320c2a
--- /dev/null
+++ b/A4.xml.real
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Makefile b/Makefile
index b1e0d76..5e037a7 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/echo_gfx.cpp b/echo_gfx.cpp
index 79a1728..4f43f83 100644
--- a/echo_gfx.cpp
+++ b/echo_gfx.cpp
@@ -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);
diff --git a/echo_loader.cpp b/echo_loader.cpp
index 6dcc7d6..bbe3244 100644
--- a/echo_loader.cpp
+++ b/echo_loader.cpp
@@ -34,11 +34,12 @@
#include
#include
-#include
+#include
#include
#include
#include
#include
+#include
#ifdef ARM9
#include
@@ -520,14 +521,14 @@ 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);
@@ -535,11 +536,11 @@ static grid* parse_grid(TiXmlElement* txe, stage* st, DEPENDENCY_MAP* map, escgr
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
diff --git a/echo_math.cpp b/echo_math.cpp
index 7224451..444a3ee 100644
--- a/echo_math.cpp
+++ b/echo_math.cpp
@@ -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
@@ -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);
+}
+
diff --git a/echo_math.h b/echo_math.h
index 0245392..bdd2f0d 100644
--- a/echo_math.h
+++ b/echo_math.h
@@ -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();
@@ -73,6 +74,8 @@ typedef struct
vector3f p2;
}
line3f;
+
+int has_line(line3f* ptr, line3f line);
#endif
#ifndef __ECHO_ANGLE_RANGE__
diff --git a/freeform_grid.cpp b/freeform_grid.cpp
new file mode 100644
index 0000000..114cf13
--- /dev/null
+++ b/freeform_grid.cpp
@@ -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 .
+*/
+
+#include
+
+#include
+#include
+#include
+#include
+
+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);
+}
+
+
diff --git a/freeform_grid.h b/freeform_grid.h
new file mode 100644
index 0000000..73fcbc1
--- /dev/null
+++ b/freeform_grid.h
@@ -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 .
+*/
+
+#include
+#include
+
+#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
diff --git a/grid.cpp b/grid.cpp
index 8b45d9d..ed88818 100644
--- a/grid.cpp
+++ b/grid.cpp
@@ -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]);
@@ -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);
}
diff --git a/stair.cpp b/stair.cpp
index 023d042..8fd6e31 100644
--- a/stair.cpp
+++ b/stair.cpp
@@ -17,49 +17,92 @@
along with L-Echo. If not, see .
*/
-#include
-
#include
-#include
#include
+#include
+
#include
+#include
-stair::stair()
+stair::stair() : grid()
{
- init(NULL, NULL, NULL, new vector3f(0.5f, 0.5f, 0), new vector3f(0, 0, 0.5f));
+ init(NULL, NULL, NULL, 0);
}
-stair::stair(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width)
+stair::stair(grid_info_t* my_info, grid* my_prev, grid* my_next, float my_angle) : grid()
{
- dir = my_dir;
- width = my_width;
- init(my_info, my_prev, my_next, my_dir, my_width);
+ init(my_info, my_prev, my_next, my_angle);
}
-void stair::init(grid_info_t* my_info, grid* my_prev, grid* my_next, vector3f* my_dir, vector3f* my_width)
+void stair::init(grid_info_t* my_info, grid* my_prev, grid* my_next, float my_angle)
{
- dir = my_dir;
- width = my_width;
- grid::init(my_info, my_prev, my_next);
+ grid::init(my_info, my_prev, my_next);
+ angle = my_angle;
+}
+
+void stair::init_to_null()
+{
+ grid::init_to_null();
+ angle = 0;
}
line3f* stair::generate_lines(grid_info_t my_info)
{
- line3f* ret = new line3f[4];
+ line3f* ret = new line3f[2];
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;
+#ifdef STRICT_MEM
+ vector3f* p1 = new vector3f(0.5, 0.5, 0.5);
+ CHKPTR(p1);
+ p1->self_rotate_about_y(angle);
+ vector3f* p2 = new vector3f(-0.5, 0.5, 0.5);
+ CHKPTR(p2);
+ p2->self_rotate_about_y(angle);
+
+ vector3f* p3 = new vector3f(0.5, -0.5, -0.5);
+ CHKPTR(p3);
+ p3->self_rotate_about_y(angle);
+ vector3f* p4 = new vector3f(-0.5, -0.5, -0.5);
+ CHKPTR(p4);
+ p4->self_rotate_about_y(angle);
+
+ ret[0].p1 = *p1; ret[0].p2 = *p2;
+ ret[1].p1 = *p3; ret[1].p2 = *p4;
+#else
+ vector3f p1(0.5, 0.5, 0.5);
+ p1.self_rotate_about_y(angle);
+ vector3f p2(-0.5, 0.5, 0.5);
+ p2.self_rotate_about_y(angle);
+
+ vector3f p3(0.5, -0.5, -0.5);
+ p3.self_rotate_about_y(angle);
+ vector3f p4(-0.5, -0.5, -0.5);
+ p4.self_rotate_about_y(angle);
+
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;
-
+ ret[1].p1 = p3; ret[1].p2 = p4;
+#endif
+
return(ret);
}
+void stair::draw(vector3f angle)
+{
+ draw_goal(angle);
+
+ line3f* my_lines = get_lines(angle);
+ //draw_rect(my_lines[0].p1, my_lines[1].p1, my_lines[2].p1, my_lines[3].p1);
+ grid* my_next = get_real_next();
+ line3f* next_lines = my_next != NULL ? my_next->get_lines(angle) : NULL;
+ grid* my_prev = get_real_prev();
+ line3f* prev_lines = my_prev != NULL ? my_prev->get_lines(angle) : NULL;
+ int each = 0;
+ while(each < 2)
+ {
+ if( ( next_lines == NULL || !has_line(next_lines, my_lines[each]) )
+ && ( prev_lines == NULL || !has_line(prev_lines, my_lines[each]) ) )
+ draw_line(my_lines[each]);
+ each++;
+ }
+}
diff --git a/stair.h b/stair.h
index 166f500..ce8d5f6 100644
--- a/stair.h
+++ b/stair.h
@@ -24,15 +24,16 @@
#define __ECHO_CLASS_STAIR__
class stair : public grid
{
- protected:
- vector3f* dir;
- vector3f* width;
- public:
- stair();
- stair(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);
+ protected:
+ float angle;
+ public:
+ stair();
+ stair(grid_info_t* my_info, grid* my_prev, grid* my_next, float my_angle);
+ void init(grid_info_t* my_info, grid* my_prev, grid* my_next, float my_angle);
+
+ virtual void init_to_null();
+ virtual line3f* generate_lines(grid_info_t my_info);
+ virtual void draw(vector3f angle);
};
#endif
+