kick
|
00001 // 00002 // mesh_renderer.h 00003 // KickCPP 00004 // 00005 // Created by Morten Nobel-Jørgensen on 12/12/13. 00006 // Copyright (c) 2013 Morten Nobel-Joergensen. All rights reserved. 00007 // 00008 00009 #pragma once 00010 00011 #include "component.h" 00012 #include "kick/material/material.h" 00013 #include "component_renderable.h" 00014 #include <vector> 00015 00016 namespace kick { 00017 class Transform; 00018 class Mesh; 00019 class GameObject; 00020 00021 class MeshRenderer : public ComponentRenderable { 00022 public: 00023 MeshRenderer(GameObject *gameObject); 00024 ~MeshRenderer(); 00025 00026 virtual void render(EngineUniforms *engineUniforms, Material* replacementMaterial = nullptr); 00027 void setMesh(std::shared_ptr<Mesh> mesh); 00028 std::shared_ptr<Mesh> mesh(); 00029 // set the first material 00030 void setMaterial(Material *material); 00031 // get first material (no nullptr if no material added) 00032 Material* material(); 00033 00034 Material* instancedMaterial(); 00035 void setMaterials(const std::vector<Material *> &mats); 00036 const std::vector<Material*> &materials(); 00037 const std::vector<Material*> &instancedMaterials(); 00038 00039 virtual int renderOrder(); 00040 00041 private: 00042 bool isInstanced = false; 00043 std::shared_ptr<Mesh> mMesh; 00044 std::shared_ptr<Transform> mTransform; 00045 std::vector<Material*> mMaterials; 00046 }; 00047 }