initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / scenegraph.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2011 Adam Williams <broadcast at earthling dot net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  * 
19  */
20
21
22
23 #ifndef SCENEGRAPH_H
24 #define SCENEGRAPH_H
25
26
27 #include "affine.inc"
28 #include "arraylist.h"
29 #include "overlayframe.h"
30 #include "vframe.h"
31
32
33 // Main scene graph objects
34 class SceneGraph;
35
36
37
38
39 // Base class for all scene objects
40 class SceneNode
41 {
42 public:
43         SceneNode();
44         SceneNode(const char *title);
45         SceneNode(VFrame *image, int private_image, float x, float y);
46         virtual ~SceneNode();
47
48         void append(SceneNode *node);
49         SceneNode* get_node(int number);
50         void reset();
51 // Copy values & image pointer but not subnodes yet
52         void copy_ref(SceneNode *node);
53 // Not recursive yet
54         int get_memory_usage();
55         virtual void dump(int indent);
56         void render(VFrame *frame, int do_camera);
57 // 2D coordinate transformation
58         void transform_coord(
59                 float *x, 
60                 float *y, 
61                 float *sx, 
62                 float *sy, 
63                 float *ry);
64         int get_flip();
65
66         ArrayList<SceneNode*> nodes;
67
68 // for 2D
69         VFrame *image;
70         int private_image;
71
72 // Move.  Only x & y are used in 2D.
73 // x,y is the top left corner in 2D
74         float x, y, z;
75 // Scale.  Only sx & sy are used in 2D
76         float sx, sy, sz;
77 // Rotate in degrees.  Only ry is used in 2D
78         float rx, ry, rz;
79 // causes x,y to be the top right corner in 2D
80         int flip;
81         int hidden;
82         char title[BCTEXTLEN];
83 // Set in append()
84         SceneNode *parent;
85         SceneGraph *scene;
86 };
87
88
89 class SceneGraph : public VFrameScene
90 {
91 public:
92         SceneGraph();
93         virtual ~SceneGraph();
94
95         SceneNode* get_node(int number);
96         void append(SceneNode *node);
97         void append_camera(SceneNode *node);
98 // Render 2D scene
99         void render(VFrame *frame, int cpus);
100         void dump();
101         void transform_camera(VFrame *frame, 
102                 float *x, 
103                 float *y, 
104                 float *sx, 
105                 float *sy, 
106                 int flip);
107
108         
109         ArrayList<SceneNode*> nodes;
110         ArrayList<SceneNode*> cameras;
111         int current_camera;
112         AffineEngine *affine;
113         OverlayFrame *overlayer;
114         int cpus;
115 };
116
117
118
119 class SceneTransform : public SceneNode
120 {
121 public:
122         SceneTransform();
123         virtual ~SceneTransform();
124
125 };
126
127
128
129 class SceneLight : public SceneNode
130 {
131 public:
132         SceneLight();
133         virtual ~SceneLight();
134
135
136         double r, g, b;
137 };
138
139
140 class SceneCamera : public SceneNode
141 {
142 public:
143         SceneCamera();
144         virtual ~SceneCamera();
145
146         virtual void dump(int indent);
147
148 // Top left of box to look at in 2D
149         double at_x, at_y, at_z;
150         double scale;
151 };
152
153 class SceneMaterial : public SceneNode
154 {
155 public:
156         SceneMaterial();
157         virtual ~SceneMaterial();
158
159         double r, g, b, a;
160         char *texture;
161         double s, t;
162 };
163
164
165
166 // Base class for shapes
167 class SceneShape : public SceneNode
168 {
169 public:
170         SceneShape();
171         ~SceneShape();
172
173 // Pivot for shapes
174         double pivot_x, pivot_y, pivot_z;
175 };
176
177
178
179 class SceneCylinder : public SceneShape
180 {
181 public:
182         SceneCylinder();
183         virtual ~SceneCylinder();
184 };
185
186 class SceneSphere : public SceneShape
187 {
188 public:
189         SceneSphere();
190         virtual ~SceneSphere();
191 };
192
193 class SceneBox : public SceneShape
194 {
195 public:
196         SceneBox();
197         virtual ~SceneBox();
198 };
199
200
201
202
203
204 #endif
205
206
207