RTRenderer.cpp
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 1k
Category:

Graph program

Development Platform:

Visual C++

  1. #include <stdafx.h>
  2. #include "..//Drawer.h"
  3. #include "RTRenderer.h"
  4. class CDefaultTexture : public sgRayTracingTexture::sgCSolidTexture
  5. {
  6. public:
  7. float  m_red;
  8. float  m_green;
  9. float  m_blue;
  10. float  m_alpha;
  11. virtual  void     GetColor(sgRayTracingTexture::RT_COLOR& col) const
  12. {
  13. col.m_red = m_red;
  14. col.m_green = m_green;
  15. col.m_blue = m_blue;
  16. col.m_alpha = m_alpha;
  17. }
  18. };
  19. class CDefaultMaterial : public sgCMaterial
  20. {
  21. public:
  22. CDefaultTexture  m_def_texture;
  23. virtual   const sgRayTracingTexture::sgCTexture*   GetTexture() const {return &m_def_texture;};
  24. };
  25. static  CDefaultMaterial   default_material;
  26. int   MyRenderer::GetWidth()
  27. {
  28.   return m_draw_sizes.cx;
  29. }
  30. int   MyRenderer::GetHeight()
  31. {
  32.   return m_draw_sizes.cy;
  33. }
  34. sgCMaterial*  MyRenderer::GetMaterial(const sgCObject* ooo)
  35. {
  36.   sgC3DObject* obj3D = (sgC3DObject*)(ooo);
  37.   const float* obj_col = Drawer::GetColorByIndex(ooo->GetAttribute(SG_OA_COLOR));
  38.   default_material.m_def_texture.m_red   = obj_col[0];
  39.   default_material.m_def_texture.m_green = obj_col[1];
  40.   default_material.m_def_texture.m_blue  = obj_col[2];
  41.   default_material.m_def_texture.m_alpha = 0.0f;
  42.   return &default_material;
  43. };