Polygon3D ConvertPolygon(IPPolygonStruct* p)
	{
		std::vector<HomogeneousPoint> vertices;
		std::vector<Vector3D> tmpNormals;
		vertices.reserve(3);
		tmpNormals.reserve(3);
		bool badNormal = false;
		IPVertexStruct* v = p->PVertex;
		while (v != NULL)
		{
			// assume 3D. no indication in structure...
			IPAttributeStruct* vertexAttrRGB = AttrFindAttribute(v->Attr, "rgb");
			if (vertexAttrRGB != NULL)
			{
				int vr, vg, vb;
				sscanf_s(vertexAttrRGB->U.Str, "%d,%d,%d", &vr, &vg, &vb);
				vertices.push_back(HomogeneousPoint(v->Coord[0], v->Coord[1], v->Coord[2], 1.0, RGB(vr, vg, vb)));
			}
			else
			{
				vertices.push_back(HomogeneousPoint(v->Coord[0], v->Coord[1], v->Coord[2]));
			}
			if (v->Normal[0] == 0 && v->Normal[1] == 0 && v->Normal[2] == 0)
			{
				badNormal = true;
			}
			tmpNormals.push_back(Vector3D(v->Normal[0], v->Normal[1], v->Normal[2]));
			
			v = v->Pnext;
		}
		if (badNormal)
		{
			tmpNormals.clear();
		}

		IPAttributeStruct* polyAttrRGB = AttrFindAttribute(p->Attr, "rgb");
		if (polyAttrRGB != NULL)
		{
			int pr, pg, pb;
			sscanf_s(polyAttrRGB->U.Str, "%d,%d,%d", &pr, &pg, &pb);
			return Polygon3D(vertices, tmpNormals, RGB(pr,pg,pb));
		}
		else
		{
			return Polygon3D(vertices, tmpNormals);
		}
	}
Exemple #2
0
	void Spot::setPosition(const ofVec3f& pos) 
	{ 
		active = true;
		position = pos; 
		
		vector<ofVec3f> vertexs;
		vertexs.push_back(ofVec3f(-size * 0.5f, 0, -size * 0.5f));
		vertexs.push_back(ofVec3f(size * 0.5f, 0, -size * 0.5f));
		vertexs.push_back(ofVec3f(size * 0.5f, 0, size * 0.5f));
		vertexs.push_back(ofVec3f(-size * 0.5f, 0, size * 0.5f));
		area = Polygon3D(vertexs);
	}