]> git.jsancho.org Git - c-irrlicht.git/commitdiff
Vertices, boxes, matrices, transformations and more
authorJavier Sancho <jsf@jsancho.org>
Tue, 3 Dec 2019 09:06:48 +0000 (10:06 +0100)
committerJavier Sancho <jsf@jsancho.org>
Tue, 3 Dec 2019 09:06:48 +0000 (10:06 +0100)
14 files changed:
Makefile.am
include/ICustomSceneNode.h [deleted file]
include/ISceneManager.h
include/ISceneNode.h
include/IVideoDriver.h
include/S3DVertex.h [new file with mode: 0644]
include/aabbox3d.h
include/cirrlicht.h
include/matrix4.h [new file with mode: 0644]
include/vector2d.h [new file with mode: 0644]
src/ISceneManager.cpp
src/ISceneNode.cpp
src/IVideoDriver.cpp
src/aabbox3d.cpp [new file with mode: 0644]

index b8dce54613e80dde49137ad3cc8f72cd5f171f68..9af851c5b42e625e50a8aef2194a414888e78f3b 100644 (file)
@@ -1,6 +1,7 @@
 ACLOCAL_AMFLAGS = -I m4
 lib_LTLIBRARIES = libCIrrlicht.la
 libCIrrlicht_la_SOURCES = \
+  src/aabbox3d.cpp \
   src/CIrrlicht.cpp \
   src/IAnimatedMeshSceneNode.cpp \
   src/ICursorControl.cpp \
@@ -23,7 +24,6 @@ pkginclude_HEADERS = \
   include/IAnimatedMeshSceneNode.h \
   include/ICameraSceneNode.h \
   include/ICursorControl.h \
-  include/ICustomSceneNode.h \
   include/IFileArchive.h \
   include/IFileSystem.h \
   include/IGUIElement.h \
@@ -36,9 +36,12 @@ pkginclude_HEADERS = \
   include/ISceneNode.h \
   include/ITexture.h \
   include/IVideoDriver.h \
+  include/matrix4.h \
   include/rect.h \
+  include/S3DVertex.h \
   include/SColor.h \
   include/SExposedVideoData.h \
   include/SKeyMap.h \
   include/SMaterial.h \
+  include/vector2d.h \
   include/vector3d.h
diff --git a/include/ICustomSceneNode.h b/include/ICustomSceneNode.h
deleted file mode 100644 (file)
index 17dbeac..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/* c-irrlicht --- C bindings for Irrlicht Engine
-
-   Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
-
-   This file is part of c-irrlicht.
-
-   c-irrlicht is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 3 of the
-   License, or (at your option) any later version.
-
-   c-irrlicht 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 Lesser General Public
-   License along with guile-irrlicht.  If not, see
-   <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __C_I_CUSTOM_SCENE_NODE_H_INCLUDED__
-#define __C_I_CUSTOM_SCENE_NODE_H_INCLUDED__
-
-typedef void irr_scene_ICustomSceneNode;
-
-#endif
index ff1ed12a4da237213e358a724bfd27fe18a8de79..fdcd419c256c745b0c0f3667cac5ad6ff2d76721 100644 (file)
@@ -26,7 +26,6 @@
 #include "IAnimatedMesh.h"
 #include "IAnimatedMeshSceneNode.h"
 #include "ICameraSceneNode.h"
-#include "ICustomSceneNode.h"
 #include "IMeshSceneNode.h"
 #include "ISceneNode.h"
 #include "SKeyMap.h"
@@ -70,7 +69,7 @@ extern "C" {
                                   int invertMouse,
                                   int makeActive);
 
-  irr_scene_ICustomSceneNode*
+  irr_scene_ISceneNode*
   irr_scene_addCustomSceneNode(irr_scene_ISceneManager* smgr,
                                irr_scene_ISceneNode* parent,
                                int id,
index 5f902f6530582e1747b761ffa9c56d9458057bc0..16731a4060c786ab3556d27e52bee432e6f792bf 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "EMaterialFlags.h"
 #include "ITexture.h"
+#include "matrix4.h"
 #include "vector3d.h"
 
 typedef void irr_scene_ISceneNode;
@@ -32,6 +33,9 @@ typedef void irr_scene_ISceneNode;
 extern "C" {
 #endif
 
+  irr_core_matrix4*
+  irr_scene_getAbsoluteTransformation(irr_scene_ISceneNode* node);
+
   void
   irr_scene_setMaterialFlag(irr_scene_ISceneNode* node,
                             irr_video_E_MATERIAL_FLAG flag,
index 5da2d39f0ca5f6d045ca0dff03370e6d523d8281..5c89181d13b89390dc957e8f00cb83e7f075360f 100644 (file)
 #define __C_I_VIDEO_DRIVER_H_INCLUDED__
 
 #include "ITexture.h"
+#include "matrix4.h"
 #include "SColor.h"
 #include "SExposedVideoData.h"
+#include "SMaterial.h"
 #include "rect.h"
 
+//! enumeration for geometry transformation states
+typedef enum
+  {
+   //! View transformation
+   irr_video_ETS_VIEW = 0,
+   //! World transformation
+   irr_video_ETS_WORLD,
+   //! Projection transformation
+   irr_video_ETS_PROJECTION,
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_0,
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_1,
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_2,
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_3,
+#if _C_IRR_MATERIAL_MAX_TEXTURES_>4
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_4,
+#if _C_IRR_MATERIAL_MAX_TEXTURES_>5
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_5,
+#if _C_IRR_MATERIAL_MAX_TEXTURES_>6
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_6,
+#if _C_IRR_MATERIAL_MAX_TEXTURES_>7
+   //! Texture transformation
+   irr_video_ETS_TEXTURE_7,
+#endif
+#endif
+#endif
+#endif
+   //! Not used
+   irr_video_ETS_COUNT
+  } irr_video_E_TRANSFORMATION_STATE;
+
+// types
 typedef void irr_video_IVideoDriver;
 
 #ifdef __cplusplus
@@ -54,6 +94,15 @@ extern "C" {
   irr_video_getTexture(irr_video_IVideoDriver* driver,
                        const char* filename);
 
+  void
+  irr_video_setMaterial(irr_video_IVideoDriver* driver,
+                        const irr_video_SMaterial material);
+
+  void
+  irr_video_setTransform(irr_video_IVideoDriver* driver,
+                         irr_video_E_TRANSFORMATION_STATE state,
+                         irr_core_matrix4* mat);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/S3DVertex.h b/include/S3DVertex.h
new file mode 100644 (file)
index 0000000..7d28d83
--- /dev/null
@@ -0,0 +1,37 @@
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+   Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of c-irrlicht.
+
+   c-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   c-irrlicht 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 Lesser General Public
+   License along with guile-irrlicht.  If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __C_IRR_S_3D_VERTEX_H_INCLUDED__
+#define __C_IRR_S_3D_VERTEX_H_INCLUDED__
+
+#include "SColor.h"
+#include "vector2d.h"
+#include "vector3d.h"
+
+typedef struct
+{
+  irr_core_vector3df pos;
+  irr_core_vector3df normal;
+  irr_video_SColor color;
+  irr_core_vector2df tCoords;
+} irr_video_S3DVertex;
+
+#endif
index f31fadbd6b5232d7ada63b2797fac75f56b66633..1940c20aad0fe0fcb993ab0a42b05017e47aa93a 100644 (file)
 #ifndef __C_IRR_AABBOX_3D_H_INCLUDED__
 #define __C_IRR_AABBOX_3D_H_INCLUDED__
 
-typedef struct{
+#include "vector3d.h"
+
+typedef struct {
+  irr_core_vector3df minEdge;
+  irr_core_vector3df maxEdge;
 } irr_core_aabbox3d_f32;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  void
+  irr_core_aabbox3d_addInternalPoint(irr_core_aabbox3d_f32 box,
+                                     irr_core_vector3df p);
+
+  void
+  irr_core_aabbox3d_reset(irr_core_aabbox3d_f32 box,
+                          irr_core_vector3df initValue);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif
index f00e28c28aa1ec96762e53eb7e229d5808a58acd..2c30a04e60ff34c61427cddd1a152eb14228bfd6 100644 (file)
@@ -30,7 +30,6 @@
 #include "IAnimatedMeshSceneNode.h"
 #include "ICameraSceneNode.h"
 #include "ICursorControl.h"
-#include "ICustomSceneNode.h"
 #include "IFileArchive.h"
 #include "IFileSystem.h"
 #include "IGUIEnvironment.h"
 #include "ISceneNode.h"
 #include "ITexture.h"
 #include "IVideoDriver.h"
+#include "matrix4.h"
 #include "rect.h"
+#include "S3DVertex.h"
 #include "SColor.h"
 #include "SExposedVideoData.h"
 #include "SKeyMap.h"
 #include "SMaterial.h"
+#include "vector2d.h"
 #include "vector3d.h"
 
 #ifdef __cplusplus
diff --git a/include/matrix4.h b/include/matrix4.h
new file mode 100644 (file)
index 0000000..1a02062
--- /dev/null
@@ -0,0 +1,27 @@
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+   Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of c-irrlicht.
+
+   c-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   c-irrlicht 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 Lesser General Public
+   License along with guile-irrlicht.  If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __C_IRR_MATRIX_H_INCLUDED__
+#define __C_IRR_MATRIX_H_INCLUDED__
+
+typedef void irr_core_matrix4;
+
+#endif
diff --git a/include/vector2d.h b/include/vector2d.h
new file mode 100644 (file)
index 0000000..b3ae149
--- /dev/null
@@ -0,0 +1,31 @@
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+   Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of c-irrlicht.
+
+   c-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   c-irrlicht 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 Lesser General Public
+   License along with guile-irrlicht.  If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __C_IRR_VECTOR_2D_H_INCLUDED__
+#define __C_IRR_VECTOR_2D_H_INCLUDED__
+
+typedef struct
+{
+  float x;
+  float y;
+} irr_core_vector2df;
+
+#endif
index 905ad4996ef8b8f2cb688e534b0fd635176b698c..7edf4cf6e432fc8414a7080d8c0fd67d66130fb9 100644 (file)
@@ -174,7 +174,7 @@ extern "C" {
                               makeActive);
   }
 
-  irr_scene_ICustomSceneNode*
+  irr_scene_ISceneNode*
   irr_scene_addCustomSceneNode(irr_scene_ISceneManager* smgr,
                                irr_scene_ISceneNode* parent,
                                int id,
@@ -217,10 +217,10 @@ extern "C" {
                           getBoundingBox,
                           getMaterialCount,
                           getMaterial);
-    node->drop();
-    node = 0;
-    return NULL;
-    //return node;
+    //node->drop();
+    //node = 0;
+    //return NULL;
+    return node;
   }
 
   irr_scene_IMeshSceneNode*
index 8236eeb4d1aafacdb12ad8b42935c440810d7463..9b030034dc597c7f2053bc4fe91d43f8b9527b64 100644 (file)
 #include "ISceneNode.h"
 
 extern "C" {
+  irr_core_matrix4*
+  irr_scene_getAbsoluteTransformation(irr_scene_ISceneNode* node)
+  {
+    return (irr_core_matrix4*)
+      &((irr::scene::ISceneNode*)node)->getAbsoluteTransformation();
+  }
+
   void
   irr_scene_setMaterialFlag(irr_scene_ISceneNode* node,
                             irr_video_E_MATERIAL_FLAG flag,
index 3b77b9106a6b0f70bd9d945e79264765421b1da2..50ee3454283db4ec73ea0d2d7c634c489f0ae4ab 100644 (file)
@@ -89,4 +89,24 @@ extern "C" {
       ((irr::video::IVideoDriver*)driver)->getTexture(filename);
   }
 
+  void
+  irr_video_setMaterial(irr_video_IVideoDriver* driver,
+                        const irr_video_SMaterial material)
+  {
+    irr::video::SMaterial irrMaterial = irr::video::SMaterial();
+    irrMaterial.Lighting = material.lighting;
+    irrMaterial.Wireframe = material.wireframe;
+
+    ((irr::video::IVideoDriver*)driver)->setMaterial(irrMaterial);
+  }
+
+  void
+  irr_video_setTransform(irr_video_IVideoDriver* driver,
+                         irr_video_E_TRANSFORMATION_STATE state,
+                         irr_core_matrix4* mat)
+  {
+    ((irr::video::IVideoDriver*)driver)
+      ->setTransform((irr::video::E_TRANSFORMATION_STATE)state,
+                     *(irr::core::matrix4*)mat);
+  }
 }
diff --git a/src/aabbox3d.cpp b/src/aabbox3d.cpp
new file mode 100644 (file)
index 0000000..4209425
--- /dev/null
@@ -0,0 +1,45 @@
+/* c-irrlicht --- C bindings for Irrlicht Engine
+
+   Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
+
+   This file is part of c-irrlicht.
+
+   c-irrlicht is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 3 of the
+   License, or (at your option) any later version.
+
+   c-irrlicht 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 Lesser General Public
+   License along with guile-irrlicht.  If not, see
+   <http://www.gnu.org/licenses/>.
+*/
+
+#include "aabbox3d.h"
+
+extern "C" {
+  void
+  irr_core_aabbox3d_addInternalPoint(irr_core_aabbox3d_f32 box,
+                                     irr_core_vector3df p)
+  {
+    if (p.x > box.maxEdge.x) box.maxEdge.x = p.x;
+    if (p.y > box.maxEdge.y) box.maxEdge.y = p.y;
+    if (p.z > box.maxEdge.z) box.maxEdge.z = p.z;
+
+    if (p.x < box.minEdge.x) box.minEdge.x = p.x;
+    if (p.y < box.minEdge.y) box.minEdge.y = p.y;
+    if (p.z < box.minEdge.z) box.minEdge.z = p.z;
+  }
+
+  void
+  irr_core_aabbox3d_reset(irr_core_aabbox3d_f32 box,
+                          irr_core_vector3df initValue)
+  {
+    box.minEdge = initValue;
+    box.maxEdge = initValue;
+  }
+}