Introducing scene graph

This commit is contained in:
brunoherbelin
2020-03-31 17:01:33 +02:00
parent cf5a3b3fc9
commit 2fc01e8435
17 changed files with 837 additions and 184 deletions

60
Primitives.h Normal file
View File

@@ -0,0 +1,60 @@
#ifndef PRIMITIVES_H
#define PRIMITIVES_H
#include <string>
#include "Scene.h"
// Draw a Rectangle (triangle strip) with a texture
class TexturedRectangle : public Primitive {
std::string texturepath_;
unsigned int textureindex_;
public:
TexturedRectangle(const std::string& resourcepath);
void draw(glm::mat4 modelview, glm::mat4 projection);
void accept(Visitor& v) override { v.visit(*this); }
std::string getResourcePath() { return texturepath_; }
};
// Draw a Rectangle (triangle strip) with a media as animated texture
class MediaPlayer;
class MediaRectangle : public Primitive {
MediaPlayer *mediaplayer_;
std::string mediapath_;
unsigned int textureindex_;
public:
MediaRectangle(const std::string& mediapath);
~MediaRectangle();
void update ( float dt );
void draw(glm::mat4 modelview, glm::mat4 projection);
void accept(Visitor& v) override { v.visit(*this); }
std::string getMediaPath() { return mediapath_; }
MediaPlayer *getMediaPlayer() { return mediaplayer_; }
};
// Draw a line strip
class LineStrip : public Primitive {
public:
LineStrip(std::vector<glm::vec3> points, glm::vec3 color);
void accept(Visitor& v) override { v.visit(*this); }
std::vector<glm::vec3> getPoints() { return points_; }
glm::vec3 getColor() { return colors_[0]; }
};
#endif // PRIMITIVES_H