From: Javier Sancho Date: Tue, 3 Dec 2019 09:06:48 +0000 (+0100) Subject: Vertices, boxes, matrices, transformations and more X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=8d84fb35562071d38c50f6d78880aa3cb626c0fc;p=c-irrlicht.git Vertices, boxes, matrices, transformations and more --- diff --git a/Makefile.am b/Makefile.am index b8dce54..9af851c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 17dbeac..0000000 --- a/include/ICustomSceneNode.h +++ /dev/null @@ -1,27 +0,0 @@ -/* c-irrlicht --- C bindings for Irrlicht Engine - - Copyright (C) 2019 Javier Sancho - - 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 - . -*/ - -#ifndef __C_I_CUSTOM_SCENE_NODE_H_INCLUDED__ -#define __C_I_CUSTOM_SCENE_NODE_H_INCLUDED__ - -typedef void irr_scene_ICustomSceneNode; - -#endif diff --git a/include/ISceneManager.h b/include/ISceneManager.h index ff1ed12..fdcd419 100644 --- a/include/ISceneManager.h +++ b/include/ISceneManager.h @@ -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, diff --git a/include/ISceneNode.h b/include/ISceneNode.h index 5f902f6..16731a4 100644 --- a/include/ISceneNode.h +++ b/include/ISceneNode.h @@ -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, diff --git a/include/IVideoDriver.h b/include/IVideoDriver.h index 5da2d39..5c89181 100644 --- a/include/IVideoDriver.h +++ b/include/IVideoDriver.h @@ -23,10 +23,50 @@ #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 index 0000000..7d28d83 --- /dev/null +++ b/include/S3DVertex.h @@ -0,0 +1,37 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#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 diff --git a/include/aabbox3d.h b/include/aabbox3d.h index f31fadb..1940c20 100644 --- a/include/aabbox3d.h +++ b/include/aabbox3d.h @@ -22,7 +22,27 @@ #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 diff --git a/include/cirrlicht.h b/include/cirrlicht.h index f00e28c..2c30a04 100644 --- a/include/cirrlicht.h +++ b/include/cirrlicht.h @@ -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" @@ -43,11 +42,14 @@ #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 index 0000000..1a02062 --- /dev/null +++ b/include/matrix4.h @@ -0,0 +1,27 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#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 index 0000000..b3ae149 --- /dev/null +++ b/include/vector2d.h @@ -0,0 +1,31 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#ifndef __C_IRR_VECTOR_2D_H_INCLUDED__ +#define __C_IRR_VECTOR_2D_H_INCLUDED__ + +typedef struct +{ + float x; + float y; +} irr_core_vector2df; + +#endif diff --git a/src/ISceneManager.cpp b/src/ISceneManager.cpp index 905ad49..7edf4cf 100644 --- a/src/ISceneManager.cpp +++ b/src/ISceneManager.cpp @@ -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* diff --git a/src/ISceneNode.cpp b/src/ISceneNode.cpp index 8236eeb..9b03003 100644 --- a/src/ISceneNode.cpp +++ b/src/ISceneNode.cpp @@ -23,6 +23,13 @@ #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, diff --git a/src/IVideoDriver.cpp b/src/IVideoDriver.cpp index 3b77b91..50ee345 100644 --- a/src/IVideoDriver.cpp +++ b/src/IVideoDriver.cpp @@ -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 index 0000000..4209425 --- /dev/null +++ b/src/aabbox3d.cpp @@ -0,0 +1,45 @@ +/* c-irrlicht --- C bindings for Irrlicht Engine + + Copyright (C) 2019 Javier Sancho + + 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 + . +*/ + +#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; + } +}