I am going to use OpenGL to create a diamond and create the refraction of light through the diamond.
Starting with Lab 6, I first constructed a cube similarly to the glass sphere, pictured below. I had to think about it in axises since every part of the square should be perfectly parallel to an axis.
----SAMPLE CODE------
// --- X ---
Flt t1 = (g.cubeMin[0] - ray->o[0]) * invdir[0];
Flt t2 = (g.cubeMax[0] - ray->o[0]) * invdir[0];
Flt txmin = t1 Flt txmax = t1>t2 ? t1 : t2; if (txmin > tmin) tmin = txmin; if (txmax < tmax) tmax = txmax; if (tmin > tmax) return 0;
After this, I worked with what was given of the glass sphere to create a diamond effect. I based it on a diamond's transparency and refraction index. Literally such a small change, but made all the difference.
--------SAMPLE CODE---------
o->sf_iorInside = 2.417;
Using triangles, I tried to construct the diamond shape, though it is not wonderfully done, it does somewhat resemble a diamond which is good enough for me since I am still a student. Also this was just super complicated.
-----------SAMPLE CODE----------------
Flt tableY = crownHeight;// top flat surface
Flt starY = crownHeight * 0.7;// star facet level
Flt upperGirdleY = crownHeight * 0.3;// top girdle facets
Flt girdleY = 0.0;// girdle (widest point)
Flt lowerGirdleY = -pavilionDepth * 0.2;// bottom girdle facets
Flt pavilionY = -pavilionDepth * 0.6;// main pavilion facets
Flt culetY = -pavilionDepth;// bottom point