line3d.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***************************************************************************
  21. * *
  22. * Project Name : G *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/line3d.h $*
  25. * *
  26. * $Author:: Hector_y $*
  27. * *
  28. * $Modtime:: 2/16/01 3:52p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *-------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef LINE3D_H
  39. #define LINE3D_H
  40. #include "always.h"
  41. #include "rendobj.h"
  42. #include "vector3.h"
  43. #include "vector4.h"
  44. #include "shader.h"
  45. class VertexMaterialClass;
  46. class RenderInfoClass;
  47. /*
  48. ** Line3DClass -- Render3DObject for rendering 3D line segments.
  49. ** These are conceptually cylinders with a given width - some approximation
  50. ** of this will be rendered. (The current approximation assumes that
  51. ** Line3DCLass objects are unlit, therefore only the sihouette needs to be
  52. ** approximated).
  53. */
  54. class Line3DClass : public RenderObjClass
  55. {
  56. public:
  57. Line3DClass (const Vector3 & start, const Vector3 & end, float width,
  58. float r, float g, float b, float opacity = 1.0f);
  59. Line3DClass(const Line3DClass & src);
  60. Line3DClass & operator = (const Line3DClass & that);
  61. virtual ~Line3DClass(void);
  62. virtual RenderObjClass * Clone(void) const;
  63. // class id of this render object
  64. virtual int Class_ID(void) const { return CLASSID_LINE3D; }
  65. virtual void Render(RenderInfoClass & rfinfo);
  66. // scale the 3D line symmetrically about its center.
  67. virtual void Scale(float scale);
  68. virtual void Scale(float scalex, float scaley, float scalez);
  69. // returns the number of polygons in the render object
  70. virtual int Get_Num_Polys(void) const;
  71. // Get the object space bounding volumes
  72. virtual void Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const;
  73. virtual void Get_Obj_Space_Bounding_Box(AABoxClass & box) const;
  74. // The following functions are unique to Line3DClass:
  75. // Reset the line start and end points
  76. void Reset(const Vector3 & new_start, const Vector3 & new_end);
  77. // Reset line start and end points, and the line width
  78. void Reset(const Vector3 & new_start, const Vector3 & new_end, float new_width);
  79. // Reset the line color
  80. void Re_Color(float r, float g, float b);
  81. // Reset the line opacity
  82. void Set_Opacity(float opacity);
  83. protected:
  84. // This is kept to facilitate changing the line endpoints.
  85. float Length;
  86. // This is kept to facilitate changing the line width.
  87. float Width;
  88. // shader
  89. ShaderClass Shader;
  90. // vertices
  91. Vector3 vert[8];
  92. // color
  93. Vector4 Color;
  94. };
  95. #endif