From: Michel Pollet <buserror@gmail.com>
Date: Fri, 15 Jun 2012 08:16:12 +0000 (+0100)
Subject: c3light: New bit
X-Git-Tag: v1.0~80
X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=ede3c505b3cb75db4e7314e58849bd3a8c74992b;p=sx%2Fsimavr.git

c3light: New bit

Records lights position/type and can be carried around
in the geometry, transformed etc.

Signed-off-by: Michel Pollet <buserror@gmail.com>
---

diff --git a/examples/shared/libc3/src/c3light.c b/examples/shared/libc3/src/c3light.c
new file mode 100644
index 0000000..368a74e
--- /dev/null
+++ b/examples/shared/libc3/src/c3light.c
@@ -0,0 +1,46 @@
+/*
+	c3light.c
+
+	Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
+
+ 	This file is part of libc3.
+
+	simavr 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.
+
+	simavr 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 simavr.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <stdio.h>
+#include <string.h>
+#include "c3light.h"
+
+c3light_p
+c3light_new(
+		struct c3object_t * o /* = NULL */)
+{
+	c3light_p res = malloc(sizeof(*res));
+	return c3light_init(res, o);
+}
+
+c3light_p
+c3light_init(
+		c3light_p l,
+		struct c3object_t * o /* = NULL */)
+{
+	memset(l, 0, sizeof(*l));
+	c3geometry_init(&l->geometry,
+			c3geometry_type(C3_LIGHT_TYPE, 0),
+			o);
+
+	return l;
+}
diff --git a/examples/shared/libc3/src/c3light.h b/examples/shared/libc3/src/c3light.h
new file mode 100644
index 0000000..1ae153d
--- /dev/null
+++ b/examples/shared/libc3/src/c3light.h
@@ -0,0 +1,54 @@
+/*
+	c3light.h
+
+	Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
+
+ 	This file is part of libc3.
+
+	simavr 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.
+
+	simavr 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 simavr.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __C3LIGHT_H___
+#define __C3LIGHT_H___
+
+#include "c3geometry.h"
+
+enum {
+	C3_LIGHT_TYPE = C3_TYPE('l','i','g','h'),
+};
+
+typedef struct c3light_t {
+	c3geometry_t	geometry;
+	c3apiobject_t	light_id;
+	int				context_view_index;
+	c3vec4			position;
+	c3vec3			direction;
+	c3f				fov;
+	struct {
+		c3colorf_t	ambiant;
+		c3colorf_t	specular;
+	} color;
+} c3light_t, *c3light_p;
+
+c3light_p
+c3light_new(
+		struct c3object_t * o /* = NULL */);
+
+c3light_p
+c3light_init(
+		c3light_p l,
+		struct c3object_t * o /* = NULL */);
+
+#endif /* __C3LIGHT_H___ */