Example #1
0
extern void draw_shadow_volume_extruded_edges(/*lint -e{818}*/Occluder* pOcc, const float light_position[4], unsigned int prim)
{
	if (pOcc->show)
	{
		float olight[4];
		mult_matrix_vec((ConstMatrix)pOcc->invMat, light_position, olight);

		glNewList(pOcc->shadow_list, GL_COMPILE);
			glPushMatrix();
			moveToOcc(pOcc);
			glBegin(prim);
			GenerateShadowVolume(pOcc, olight);
			glEnd();
			glPopMatrix();
		glEndList();
	}
}
void ShadowVolume::ProcessModel(const PolygonalModel& model, const MatrixHomogeneous& mTotal, const std::vector<Normals::PolygonNormalData>& normals, bool clip, const ClippingPlane& cp, const PolygonAdjacencyGraph& polygonAdj)
{
	std::pair<PolygonalObject, std::vector<Normals::PolygonNormalData>> shadowObj = GenerateShadowVolume(model, normals, polygonAdj);
	shadowObj.first = mTotal * shadowObj.first;
	for (auto i = shadowObj.second.begin(); i != shadowObj.second.end(); ++i)
		*i = mTotal * *i;

	_shadowSurfaces.push_back(shadowObj.first.polygons);
	_shadowSurfaceNormals.push_back(shadowObj.second);

	for (auto p = shadowObj.first.polygons.begin(); p != shadowObj.first.polygons.end(); ++p)
	{
		p->color = _currPolyId;
		p->colorValid = true;
		++_currPolyId;
	}

	ModelAttr attr2;
	attr2.removeBackFace = BACKFACE_REMOVE_BACK;
	attr2.Shading = SHADING_NONE;
	attr2.forceColor = true;
	attr2.color = _currModelId++;
	DrawingObject img;
	img.shadowVolume = this;
	img.active = DrawingObject::DRAWING_OBJECT_SV;

	_currShadowMode = ShadowExit;
	DrawObject(img, shadowObj.first, mTotal, attr2, shadowObj.second, 0, true, clip, cp);
	_currShadowMode = ShadowEnter;
	size_t normalsOffset = 0;
	for (auto obj = model.begin(); obj != model.end(); ++obj)
	{
		DrawObject(img, *obj, mTotal, attr2, normals, normalsOffset, true, clip, cp);
		normalsOffset += obj->polygons.size();
	}

	attr2.removeBackFace = BACKFACE_REMOVE_FRONT;
	_currShadowMode = ShadowEnter;
	DrawObject(img, shadowObj.first, mTotal, attr2, shadowObj.second, 0, true, clip, cp);
}