Ejemplo n.º 1
0
// <Material
// DEF=""                     ID
// USE=""                     IDREF
// ambientIntensity="0.2"     SFFloat [inputOutput]
// diffuseColor="0.8 0.8 0.8" SFColor [inputOutput]
// emissiveColor="0 0 0"      SFColor [inputOutput]
// shininess="0.2"            SFFloat [inputOutput]
// specularColor="0 0 0"      SFColor [inputOutput]
// transparency="0"           SFFloat [inputOutput]
// />
void X3DImporter::ParseNode_Shape_Material()
{
    std::string use, def;
    float ambientIntensity = 0.2f;
    float shininess = 0.2f;
    float transparency = 0;
    aiColor3D diffuseColor(0.8f, 0.8f, 0.8f);
    aiColor3D emissiveColor(0, 0, 0);
    aiColor3D specularColor(0, 0, 0);
    CX3DImporter_NodeElement* ne( nullptr );

	MACRO_ATTRREAD_LOOPBEG;
		MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
		MACRO_ATTRREAD_CHECK_RET("ambientIntensity", ambientIntensity, XML_ReadNode_GetAttrVal_AsFloat);
		MACRO_ATTRREAD_CHECK_RET("shininess", shininess, XML_ReadNode_GetAttrVal_AsFloat);
		MACRO_ATTRREAD_CHECK_RET("transparency", transparency, XML_ReadNode_GetAttrVal_AsFloat);
		MACRO_ATTRREAD_CHECK_REF("diffuseColor", diffuseColor, XML_ReadNode_GetAttrVal_AsCol3f);
		MACRO_ATTRREAD_CHECK_REF("emissiveColor", emissiveColor, XML_ReadNode_GetAttrVal_AsCol3f);
		MACRO_ATTRREAD_CHECK_REF("specularColor", specularColor, XML_ReadNode_GetAttrVal_AsCol3f);
	MACRO_ATTRREAD_LOOPEND;

	// if "USE" defined then find already defined element.
	if(!use.empty())
	{
		MACRO_USE_CHECKANDAPPLY(def, use, ENET_Material, ne);
	}
	else
	{
		// create and if needed - define new geometry object.
		ne = new CX3DImporter_NodeElement_Material(NodeElement_Cur);
		if(!def.empty()) ne->ID = def;

		((CX3DImporter_NodeElement_Material*)ne)->AmbientIntensity = ambientIntensity;
		((CX3DImporter_NodeElement_Material*)ne)->Shininess = shininess;
		((CX3DImporter_NodeElement_Material*)ne)->Transparency = transparency;
		((CX3DImporter_NodeElement_Material*)ne)->DiffuseColor = diffuseColor;
		((CX3DImporter_NodeElement_Material*)ne)->EmissiveColor = emissiveColor;
		((CX3DImporter_NodeElement_Material*)ne)->SpecularColor = specularColor;
        // check for child nodes
		if(!mReader->isEmptyElement())
			ParseNode_Metadata(ne, "Material");
		else
			NodeElement_Cur->Child.push_back(ne);// add made object as child to current element

		NodeElement_List.push_back(ne);// add element to node element list because its a new object in graph
	}// if(!use.empty()) else
}
Ejemplo n.º 2
0
// <MetadataString
// DEF=""       ID
// USE=""       IDREF
// name=""      SFString [inputOutput]
// reference="" SFString [inputOutput]
// value=""     MFString [inputOutput]
// />
void X3DImporter::ParseNode_MetadataString()
{
    std::string def, use;
    std::string name, reference;
    std::list<std::string> value;
    CX3DImporter_NodeElement* ne( nullptr );

	MACRO_ATTRREAD_LOOPBEG;
		MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
		MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
		MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
		MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsListS);
	MACRO_ATTRREAD_LOOPEND;

	MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaString, "MetadataString", ENET_MetaString);
}
Ejemplo n.º 3
0
// <MetadataInteger
// DEF=""       ID
// USE=""       IDREF
// name=""      SFString  [inputOutput]
// reference="" SFString  [inputOutput]
// value=""     MFInteger [inputOutput]
// />
void X3DImporter::ParseNode_MetadataInteger()
{
    std::string def, use;
    std::string name, reference;
    std::vector<int32_t> value;
    CX3DImporter_NodeElement* ne( nullptr );

	MACRO_ATTRREAD_LOOPBEG;
		MACRO_ATTRREAD_CHECKUSEDEF_RET(def, use);
		MACRO_ATTRREAD_CHECK_RET("name", name, mReader->getAttributeValue);
		MACRO_ATTRREAD_CHECK_RET("reference", reference, mReader->getAttributeValue);
		MACRO_ATTRREAD_CHECK_REF("value", value, XML_ReadNode_GetAttrVal_AsArrI32);
	MACRO_ATTRREAD_LOOPEND;

	MACRO_METADATA_FINDCREATE(def, use, reference, value, ne, CX3DImporter_NodeElement_MetaInteger, "MetadataInteger", ENET_MetaInteger);
}