]> git.jsancho.org Git - c-irrlicht.git/blob - src/ISceneManager.cpp
getFPS
[c-irrlicht.git] / src / ISceneManager.cpp
1 /* c-irrlicht --- C bindings for Irrlicht Engine
2
3    Copyright (C) 2019 Javier Sancho <jsf@jsancho.org>
4
5    This file is part of c-irrlicht.
6
7    c-irrlicht is free software; you can redistribute it and/or modify
8    it under the terms of the GNU Lesser General Public License as
9    published by the Free Software Foundation; either version 3 of the
10    License, or (at your option) any later version.
11
12    c-irrlicht is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with guile-irrlicht.  If not, see
19    <http://www.gnu.org/licenses/>.
20 */
21
22 #include <irrlicht/irrlicht.h>
23 #include "ISceneManager.h"
24
25 extern "C" {
26   irr_scene_IAnimatedMeshSceneNode*
27   irr_scene_addAnimatedMeshSceneNode(irr_scene_ISceneManager* smgr,
28                                      irr_scene_IAnimatedMesh* mesh,
29                                      irr_scene_ISceneNode* parent,
30                                      int id,
31                                      irr_core_vector3df* position,
32                                      irr_core_vector3df* rotation,
33                                      irr_core_vector3df* scale,
34                                      int alsoAddIfMeshPointerZero)
35   {
36     const irr::core::vector3df iPosition =
37       position ?
38       irr::core::vector3df(position->x, position->y, position->z) :
39       irr::core::vector3df(0, 0, 0);
40
41     const irr::core::vector3df iRotation =
42       rotation ?
43       irr::core::vector3df(rotation->x, rotation->y, rotation->z) :
44       irr::core::vector3df(0, 0, 0);
45
46     const irr::core::vector3df& iScale =
47       scale ?
48       irr::core::vector3df(scale->x, scale->y, scale->z) :
49       irr::core::vector3df(1, 1, 1);
50
51     return (irr_scene_IAnimatedMeshSceneNode*)
52       ((irr::scene::ISceneManager*)smgr)
53       ->addAnimatedMeshSceneNode((irr::scene::IAnimatedMesh*)mesh,
54                                  (irr::scene::ISceneNode*)parent,
55                                  id,
56                                  iPosition,
57                                  iRotation,
58                                  iScale,
59                                  alsoAddIfMeshPointerZero);
60   }
61
62   irr_scene_ICameraSceneNode*
63   irr_scene_addCameraSceneNode(irr_scene_ISceneManager* smgr,
64                                irr_scene_ISceneNode* parent,
65                                irr_core_vector3df* position,
66                                irr_core_vector3df* lookat,
67                                int id,
68                                int makeActive)
69   {
70     const irr::core::vector3df& iPosition =
71       position ?
72       irr::core::vector3df(position->x, position->y, position->z) :
73       irr::core::vector3df(0, 0, 0);
74
75     const irr::core::vector3df& iLookat =
76       lookat ?
77       irr::core::vector3df(lookat->x, lookat->y, lookat->z) :
78       irr::core::vector3df(0, 0, 100);
79
80     return (irr_scene_ICameraSceneNode*)
81       ((irr::scene::ISceneManager*)smgr)
82       ->addCameraSceneNode((irr::scene::ISceneNode*)parent,
83                            iPosition,
84                            iLookat,
85                            id,
86                            makeActive);
87   }
88
89   irr_scene_ICameraSceneNode*
90   irr_scene_addCameraSceneNodeFPS(irr_scene_ISceneManager* smgr,
91                                   irr_scene_ISceneNode* parent,
92                                   float rotateSpeed,
93                                   float moveSpeed,
94                                   int id,
95                                   irr_SkeyMap* keyMapArray,
96                                   int keyMapSize,
97                                   int noVerticalMovement,
98                                   float jumpSpeed,
99                                   int invertMouse,
100                                   int makeActive)
101   {
102     return ((irr::scene::ISceneManager*)smgr)
103       ->addCameraSceneNodeFPS((irr::scene::ISceneNode*)parent,
104                               rotateSpeed,
105                               moveSpeed,
106                               id,
107                               (irr::SKeyMap*)keyMapArray,
108                               keyMapSize,
109                               noVerticalMovement,
110                               jumpSpeed,
111                               invertMouse,
112                               makeActive);
113   }
114
115   irr_scene_IMeshSceneNode*
116   irr_scene_addOctreeSceneNodeAM(irr_scene_ISceneManager* smgr,
117                                  irr_scene_IAnimatedMesh* mesh,
118                                  irr_scene_ISceneNode* parent,
119                                  int id,
120                                  int minimalPolysPerNode,
121                                  int alsoAddIfMeshPointerZero)
122   {
123     return ((irr::scene::ISceneManager*)smgr)
124       ->addOctreeSceneNode((irr::scene::IAnimatedMesh*)mesh,
125                            (irr::scene::ISceneNode*)parent,
126                            id,
127                            minimalPolysPerNode,
128                            alsoAddIfMeshPointerZero);
129   }
130
131   void
132   irr_scene_drawAll(irr_scene_ISceneManager* smgr)
133   {
134     ((irr::scene::ISceneManager*)smgr)->drawAll();
135   }
136
137
138   irr_scene_IAnimatedMesh*
139   irr_scene_getMesh(irr_scene_ISceneManager* smgr,
140                     const char* filename)
141   {
142     return (irr_scene_IAnimatedMesh*)
143       ((irr::scene::ISceneManager*)smgr)->getMesh(filename);
144   }
145 }