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

📄 hemicube.hpp

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

  Final Project
  
  This class contains the interface for the HemiCube class, 
  which is used for doing Nusselt analog/form factor types
  of things.

  The hemicube owns the cosine textures, the item buffers, depth
  buffers and "RC" buffers.  Note that an RC buffer stands for
  "rendering * cosine".  This is the scene drawn with diffuse lighting
  and modulated by the cosine texture.

*/

#include "gl_common.h"
#include "Texture.hpp"
#include "Scene.hpp"

/*+-------------------------------------------------------------------
  HemiCubeException 

  This is an exception class to be thrown when something bad happens
  in the HemiCube class.  An example of something bad happening is if
  the cosine textures could not be created.  

*/
class HemiCubeException 
{
public:
    HemiCubeException (void) {} 
    ~HemiCubeException () {}
};


/*+-------------------------------------------------------------------
  HemiCube class 
  
  This class owns 5 buffers for the item buffers, the 
  cosine textures, and the RC (scene rendering x cosine) 
  textures.

*/
class HemiCube 
{
private:
    // Depth part of the item buffer. 
    // The depth component can come 
    // from either the RC rendering or the item 
    // rendering.
    float* m_center_depth_buffer;
    float* m_left_depth_buffer;
    float* m_bottom_depth_buffer;
    float* m_right_depth_buffer;
    float* m_top_depth_buffer;

    // RGB part of the item buffer
    // This should be some integral type, e.g.
    // unsigned chars so we can identify 
    // items in the item buffer without 
    // worrying about floating point epsilon
    unsigned char* m_center_item_buffer;
    unsigned char* m_left_item_buffer;
    unsigned char* m_bottom_item_buffer;
    unsigned char* m_right_item_buffer;
    unsigned char* m_top_item_buffer;
    
    // RC = "rendering" * "cosine"
    float* m_center_rc_buffer;
    float* m_left_rc_buffer;
    float* m_bottom_rc_buffer;
    float* m_right_rc_buffer;
    float* m_top_rc_buffer;

    // load_cosine_image loads the cosine texture
    // from a PGM file.
    void load_cosine_image (void);

    // Load the grayscale cosine textures
    void init_textures (void);
    
    // render_one_item_buffer
    void render_one_item_buffer (const Scene& scene,
				 const Point& camera_point,
				 const Vector& normal,
				 const Vector& up, 
				 float frustum_bottom,
				 float frustum_top
				 );

    
    void render_one_lighted_scene_buffer (const Scene& scene,
					  const Point& camera_point,
					  const Vector& normal,
					  const Vector& up,
                                          const Color& color,
					  float frustum_bottom,
					  float frustum_top,
					  GLdouble* modelview_matrix,
					  GLdouble* projection_matrix
					  );


    void multiply_rc_buffer_by_cosine_texture (float* rc_buffer, 
					       int pixel_width,
					       int pixel_height,
                                               GrayscaleTexture* gs_tex);

    void reconstruct_one_side (Scene& scene, 
			       float* rc_buffer,
			       float* depth_buffer,
			       unsigned char* item_buffer,
			       int pixel_width, 
			       int pixel_height,
                               float area, 
			       GLdouble* modelview_matrix,
			       GLdouble* projection_matrix
			       );        

    void clear_item_buffers (void);
    void clear_rc_buffers (void);

    // Go through the rc buffers and find the element with the largest
    // float value.  Recall that the rc buffer is the lighted scene
    // multiplied by the cosine texture.
    // find_max_rc_value finds the largest among across all five
    // rc buffers.
    float find_max_rc_value (void) const;

    int m_center_pixel_width;
    int m_center_pixel_height;
    int m_side_pixel_width;
    int m_side_pixel_height;

    int m_components_per_pixel;

    Map_of<float>* m_pCenter_cos_map;
    Map_of<float>* m_pLeft_cos_map;
    Map_of<float>* m_pBottom_cos_map;
    Map_of<float>* m_pTop_cos_map;
    Map_of<float>* m_pRight_cos_map;

    GrayscaleTexture* m_center_cosine_texture;
    GrayscaleTexture* m_bottom_cosine_texture;

    // These fields are always 16 elements 
    // long, independent of the resolution of 
    // the hemicube, obviously.
    GLdouble m_center_modelview[16];
    GLdouble m_left_modelview[16];
    GLdouble m_bottom_modelview[16];
    GLdouble m_right_modelview[16];
    GLdouble m_top_modelview[16];

    GLdouble m_center_projection[16];
    GLdouble m_left_projection[16];
    GLdouble m_bottom_projection[16];
    GLdouble m_right_projection[16];
    GLdouble m_top_projection[16];



public:
    HemiCube (void);
    ~HemiCube ();
 
    // Debugging methods 
    // These methods are not currently in use, but they
    // are helpful for drawing information about the HemiCube.  
    void debug_draw (float x, float y, float width, float height);
    void debug_draw_item_buffer (void);
    void debug_draw_rc_buffer (void);

    // Method for obtaining the RC buffers, the item buffers,
    // and the depth buffers for each of the five sides of
    // the hemicube. 
    void render_buffers (const Scene& scene, 
			 const Point& camera_point,
			 const Vector& normal,
			 const Color& light_color);
    
    // Use the information in the scene to reconstruct
    // the points shot into the scene.  This is a method
    // on HemiCube because it requires projection 
    // information and the information from the various
    // buffers (item, rc, depth). 
    void reconstruct (Scene& scene);
};

#endif




⌨️ 快捷键说明

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