07 Apr 11, 01:35AM
There's no need to copy any part of the water.cpp code.
When polygons are rendered they are generated via various methods. One such method is by using triangles. You make a call to glBegin(GL_TRIANGLES). This is followed by glColor3x(r, g, b) in the case of opaque polygons. Then vertices are generated by making three calls to glVertex3x(), one for each vertex. The three vertices form one opaque triangle.
Making a transparent polygon is very simple. There are different methods for doing so but the following is the method I use most commonly[And the method AC uses IIRC]:
^ Those two lines are used to "enable" transparency. Then when I want to render a transparent triangle, instead of calling glColor3x(r, g, b), I call glColor4x(r, g, b, alpha).
AC's engine has support for calls to glColor4x(). In fact, calls are made glColor4f() in the source for such things as HUD features.
The difficulty behind transparent cubes is it is not as simple as changing glColor3x() to glColor4x() whenever you want to. You have to think about the order in which the geometry is rendered. Think about this: water is reflective in AC. If you render the water before the cubes it is supposed to reflect, the water will not reflect anything. You must render the cubes before the water. A similar nuance arises when rendering transparency with the above method; you must render the polygons behind the transparent surface first because the transparent polygons use source alpha to calculate the proper color for each pixel.
The reason I mentioned transparent clips are the most likely solution is because clip entities are rendered after the cubes AFAIK. If the clip is transparent it shouldn't cause any problems; the cubes in the map were rendered earlier.
When polygons are rendered they are generated via various methods. One such method is by using triangles. You make a call to glBegin(GL_TRIANGLES). This is followed by glColor3x(r, g, b) in the case of opaque polygons. Then vertices are generated by making three calls to glVertex3x(), one for each vertex. The three vertices form one opaque triangle.
Making a transparent polygon is very simple. There are different methods for doing so but the following is the method I use most commonly[And the method AC uses IIRC]:
[SELECT ALL] Code:
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
^ Those two lines are used to "enable" transparency. Then when I want to render a transparent triangle, instead of calling glColor3x(r, g, b), I call glColor4x(r, g, b, alpha).
AC's engine has support for calls to glColor4x(). In fact, calls are made glColor4f() in the source for such things as HUD features.
The difficulty behind transparent cubes is it is not as simple as changing glColor3x() to glColor4x() whenever you want to. You have to think about the order in which the geometry is rendered. Think about this: water is reflective in AC. If you render the water before the cubes it is supposed to reflect, the water will not reflect anything. You must render the cubes before the water. A similar nuance arises when rendering transparency with the above method; you must render the polygons behind the transparent surface first because the transparent polygons use source alpha to calculate the proper color for each pixel.
The reason I mentioned transparent clips are the most likely solution is because clip entities are rendered after the cubes AFAIK. If the clip is transparent it shouldn't cause any problems; the cubes in the map were rendered earlier.