aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--draw.c8
2 files changed, 7 insertions, 2 deletions
diff --git a/README.md b/README.md
index 9c6c99f..0425b11 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ Available potions are the following:
2. **v** *x* *y* *z* - add vertex.
3. **f** *v1* *v2* *v3* - add triangle face with following vertices.
4. **F** *v1* *v2* *v3* *color* - add triangle face with color and following vertices.
+5. **C** *color* - triangles added afterwards will have this color.
Lines that start with any other character will be ignored.
diff --git a/draw.c b/draw.c
index 9b703be..936ff41 100644
--- a/draw.c
+++ b/draw.c
@@ -41,7 +41,8 @@ add_obj(const char *path, Point off)
int pc = 0;
int a, b, c;
float mult = 1;
- unsigned int col;
+ unsigned int col, defcol;
+ defcol = 0x808080ff;
if ((f = fopen(path, "r")) == NULL) {
printf("%s:%d add_obj(...): Error opening file %s\n", __FILE__, __LINE__, path);
@@ -62,7 +63,7 @@ add_obj(const char *path, Point off)
break;
case 'f':
sscanf(s, "%*c %d%d%d", &a, &b, &c);
- add_triangle(v[a-1], v[b-1], v[c-1], 0x808080ff);
+ add_triangle(v[a-1], v[b-1], v[c-1], defcol);
t[0] = v[a-1]; t[0].y = 0;
t[1] = v[b-1]; t[1].y = 0;
t[2] = v[c-1]; t[2].y = 0;
@@ -70,6 +71,9 @@ add_obj(const char *path, Point off)
add_triangle(t[0], t[1], t[2], shadowcol);
#endif
break;
+ case 'C':
+ sscanf(s, "%*c %x", &defcol);
+ break;
case 'F':
sscanf(s, "%*c %d%d%d%x", &a, &b, &c, &col);
add_triangle(v[a-1], v[b-1], v[c-1], col);