예제 #1
0
void EG_Object::calcShadowPlane(const EG_Polygon *surface,
                                EG_Object *shadowObject)
{
    Point3D onePoint;//a single point from the surface
    Matrix3x3 surfaceRotate;//rotates surface points to the surface's orientation

    surfaceRotate.fromEuler(shadowObject->getRotation());

    for (unsigned int i = 0; i < 3; i++)
    {
        //### Rotate the point ###
        onePoint.copyFrom(surface->getVertex(i));
        onePoint = surfaceRotate.rotatePoint(onePoint);

        //### Translate to the surface's position ###
        onePoint.x += shadowObject->getPosition().x;
        onePoint.y += shadowObject->getPosition().y;
        onePoint.z += shadowObject->getPosition().z;

        shadowPlane.at(i)->copyFrom(onePoint);
    }//for i

	EG_Polygon testPolygon;
	vector<GLdouble> testVertices;

	for (unsigned int i = 0; i < shadowPlane.size(); i++)
	{
		testVertices.push_back(shadowPlane.at(i)->x);
		testVertices.push_back(shadowPlane.at(i)->y);
		testVertices.push_back(shadowPlane.at(i)->z);
	}//for i
	testPolygon.setVertices(testVertices);

	testPolygon.addIndex(0);
	testPolygon.addIndex(1);
	testPolygon.addIndex(2);

	testPolygon.draw(GL_POLYGON);
}//calcShadowSurface