⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scene.hpp

📁 The goal of this project is to explore the idea of point-based radiosity, which is a shooting radio
💻 HPP
字号:
#if !defined(BRL_SCENE_HPP)
#define BRL_SCENE_HPP
/*+-------------------------------------------------------------------
  Ben Landon
  CSCI E235
  Final Project

  Scene.hpp

*/

#include "Array_of.hpp"
#include "Point.hpp"
#include "Texture.hpp"
#include "Color.hpp"
#include "Vector.hpp"
#include "gl_common.h"
#include "Splat.hpp"

class SceneException
{
public:
    SceneException (void) {} 
    ~SceneException () {}
};

class Scene;
class SceneTriangle
{
private:
    Point m_pt0;
    Point m_pt1;
    Point m_pt2;

    Vector m_normal;

    // This is a horrible hack.  I need information
    // about the up vector, the bounding box 
    // center, and the ortho width and height 
    // for reconstruction purposes.  All of this
    // can be computed based on the triangles
    // vertices and its normal vector, but I don't
    // have time to write the code to do this right now.
    Vector m_up;
    Point m_bbox_center;
    float m_ortho_width;
    float m_ortho_height;

    Color m_diffuse_color;

    SceneTexture* m_emissive_texture;
    SceneTexture* m_accumulation_texture;
    
    unsigned int m_element_index;
    
    // Texture coordinates for this triangle.
    // The texture coordinates for the first 
    // vertex are elements 0, 1, the tex coordinates
    // for the second are 2, 3, etc.
    float m_tex_coords[6];
    
    static int m_next_index;
    
    Array_of<Splat> m_splats;
    
    int m_scene_tex_width;
    int m_scene_tex_height;

    void accumulate_splats_by_hand (void);
    void accumulate_splats_by_gl_points (void);

    // Debugging int so I can associate an identifier
    // with each element in the scene. 
    int m_debug_id;

public:
    SceneTriangle (Color& diffuse_color, Vector& normal, 
		  const Point* pts, int num_points);
    ~SceneTriangle ();

    const Vector& normal (void) const { return m_normal; }

    void draw (void) const;
    void draw_flat (void) const;
    void draw_diffuse_shaded (void) const;
    void draw_with_accumulation_texture (void) const;
    void draw_wireframe (void) const;

    float area (void) const;
    unsigned int  id (void) const { return m_element_index; }

    const Color& diffuse_color (void) const 
    { return m_diffuse_color; }

    void init_light_source_in_patch (const Color& light_color, 
				    float x, float y, 
				    float width, float height);

    void get_brightest_texel (Point& pt, Color& texel, int& u, int& v) const;

    float get_emissive_texture_energy_density (void) const;

    void clear_splats (void);
    void add_splat (Splat& splat);
    void accumulate_splats (bool use_gl_points);
    void subtract_emissive_texel (const Color& light_color, int u, int v);

    // Given an RGB value from the item buffer, compute the
    // id for that SceneTriangle. 
    static unsigned int item_rgb_to_id (GLubyte r, GLubyte g, GLubyte b);

    void debug_draw_splats (void) const;
    int debug_num_splats (void) const { return m_splats.num_elements(); }
    friend class Scene;
};


/*+-------------------------------------------------------------------
  Scene class


  This class aggregates a number of scene triangles.
  
*/
class Scene 
{
private:
    Array_of<SceneTriangle*> m_scene_triangles;
    
public:
    
    Scene (void);
    ~Scene (void);

    void draw (void) const;

    void draw_diffuse_shaded (void) const;

    void draw_flat (void) const;
    
    void draw_with_accumulation_textures (void);

    void draw_wireframe (void) const;

    void debug_draw_splats (void) const;

    static Scene* load_simple_scene (void);
    
    SceneTriangle* get_brightest_texel (Point& pt, Color& texel, 
                                        int &u, int &v) const;

    int num_triangles (void) const { return m_scene_triangles.num_elements(); }
    
    SceneTriangle* item_rgb_to_triangle (unsigned char r, 
					 unsigned char g, 
					 unsigned char b);

    void clear_all_splats (void);
    void accumulate_all_splats (bool use_gl_points = false);
    
    void examine_all_triangles (void);
    void reset_gl_textures (void);

    int debug_num_splats (void) const; 
};


#endif







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -