void plParallelIsect::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "Planes") { fPlanes.resize(tag->countChildren()); const pfPrcTag* planeChild = tag->getFirstChild(); for (size_t i=0; i<fPlanes.size(); i++) { if (planeChild->getName() != "ParallelPlane") throw pfPrcTagException(__FILE__, __LINE__, planeChild->getName()); fPlanes[i].fMin = planeChild->getParam("Min", "0").toFloat(); fPlanes[i].fMax = planeChild->getParam("Max", "0").toFloat(); const pfPrcTag* child = planeChild->getFirstChild(); while (child != NULL) { if (child->getName() == "Normal") { if (child->hasChildren()) fPlanes[i].fNorm.prcParse(child->getFirstChild()); } else if (child->getName() == "Positions") { if (child->countChildren() != 2) throw pfPrcParseException(__FILE__, __LINE__, "ParallelPlane expects exactly 2 posiitons"); fPlanes[i].fPosOne.prcParse(child->getFirstChild()); fPlanes[i].fPosTwo.prcParse(child->getFirstChild()->getNextSibling()); } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } planeChild = planeChild->getNextSibling(); } } else { plCreatable::IPrcParse(tag, mgr); } }
void plSplineEaseCurve::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "SplineCoefficients") { hsTList<plString> coefList = tag->getContents(); if (coefList.getSize() != 4) throw pfPrcParseException(__FILE__, __LINE__, "plSplineEaseCurve expects exactly 4 coefficients"); for (size_t i=0; i<4; i++) fCoef[i] = coefList.pop().toFloat(); } else { plATCEaseCurve::IPrcParse(tag, mgr); } }
void plSplineEaseCurve::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "SplineCoefficients") { std::list<plString> coefList = tag->getContents(); if (coefList.size() != 4) throw pfPrcParseException(__FILE__, __LINE__, "plSplineEaseCurve expects exactly 4 coefficients"); size_t i = 0; for (auto coef = coefList.begin(); coef != coefList.end(); ++coef) fCoef[i++] = coef->toFloat(); } else { plATCEaseCurve::IPrcParse(tag, mgr); } }
void plCubicRenderTarget::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "Faces") { if (tag->countChildren() != 6) throw pfPrcParseException(__FILE__, __LINE__, "CubicRenderTarget expects exactly 6 faces"); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<6; i++) { fFaces[i].prcParse(child, mgr); child = child->getNextSibling(); } } else { plRenderTarget::IPrcParse(tag, mgr); } }
void plGrassShaderMod::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "Material") { if (tag->hasChildren()) fMaterial = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "Waves") { if (tag->countChildren() != kNumWaves) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect number of waves"); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<kNumWaves; i++) { fWaves[i].prcParse(child); child = child->getNextSibling(); } } else { plModifier::IPrcParse(tag, mgr); } }
void plIcicle::IPrcParse(const pfPrcTag* tag) { if (tag->getName() == "Icicle") { fIBufferIdx = tag->getParam("BufferIdx", "0").toUint(); fIStartIdx = tag->getParam("StartIdx", "0").toUint(); fILength = tag->getParam("Length", "0").toUint(); } else if (tag->getName() == "SortData") { if (tag->countChildren() != (fILength / 3)) throw pfPrcParseException(__FILE__, __LINE__, "SortData should have exactly Length/3 triangles"); delete[] fSortData; fSortData = new plGBufferTriangle[fILength / 3]; const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<(fILength / 3); i++) { fSortData[i].prcParse(child); child = child->getNextSibling(); } } else { plVertexSpan::IPrcParse(tag); } }
void plAGAnim::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "AGAnimParams") { fName = tag->getParam("Name", ""); fStart = tag->getParam("Start", "0").toFloat(); fEnd = tag->getParam("End", "0").toFloat(); fEoaFlag = tag->getParam("EoaFlag", "0").toUint(); } else if (tag->getName() == "Applicators") { clearApplicators(); fApps.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fApps.size(); i++) { if (child->getName() != "AppSet") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); const pfPrcTag* subChild = child->getFirstChild(); plAGApplicator* agApp = NULL; plAGChannel* agChan = NULL; while (subChild != NULL) { if (subChild->getName() == "Applicator") { if (subChild->hasChildren()) agApp = plAGApplicator::Convert(mgr->prcParseCreatable(subChild->getFirstChild())); } else if (subChild->getName() == "Channel") { if (subChild->hasChildren()) agChan = plAGChannel::Convert(mgr->prcParseCreatable(subChild->getFirstChild())); } else { throw pfPrcTagException(__FILE__, __LINE__, subChild->getName()); } subChild = subChild->getNextSibling(); } if (agApp == NULL) throw pfPrcParseException(__FILE__, __LINE__, "Missing Applicator"); agApp->setChannel(agChan); fApps[i] = agApp; child = child->getNextSibling(); } } else { plSynchedObject::IPrcParse(tag, mgr); } }
void plPythonParameter::prcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() != "plPythonParameter") throw pfPrcTagException(__FILE__, __LINE__, tag->getName()); fID = tag->getParam("ID", "0").toUint(); plString valTypeName = tag->getParam("Type", "(Invalid)"); fValueType = 0; for (size_t i=0; i<=kNone; i++) { if (valTypeName == ValueTypeNames[i]) fValueType = i; } if (fValueType == 0) throw pfPrcParseException(__FILE__, __LINE__, "Invalid parameter type"); switch (fValueType) { case kInt: fIntValue = tag->getParam("Value", "0").toInt(); return; case kBoolean: fBoolValue = tag->getParam("Value", "false").toBool(); return; case kFloat: fFloatValue = tag->getParam("Value", "0").toFloat(); return; case kString: case kAnimationName: case kGlobalSDLVar: case kSubtitle: fStrValue = tag->getParam("Value", ""); return; case kNone: return; default: if (tag->hasChildren()) fObjKey = mgr->prcParseKey(tag->getFirstChild()); return; } }
void plSpanTemplate::prcParse(const pfPrcTag* tag) { if (tag->getName() != "plSpanTemplate") throw pfPrcTagException(__FILE__, __LINE__, tag->getName()); fFormat = tag->getParam("Format", "0").toUint(); const pfPrcTag* child = tag->getFirstChild(); while (child != NULL) { if (child->getName() == "Vertices") { fNumVerts = child->countChildren(); std::vector<Vertex> verts(fNumVerts); const pfPrcTag* vertChild = child->getFirstChild(); for (size_t i=0; i<fNumVerts; i++) { if (vertChild->getName() != "Vertex") throw pfPrcTagException(__FILE__, __LINE__, vertChild->getName()); verts[i].fColor1 = tag->getParam("Color1", "0").toUint(); verts[i].fColor2 = tag->getParam("Color2", "0").toUint(); verts[i].fWeightIdx = tag->getParam("WeightIdx", "0").toInt(); const pfPrcTag* subChild = vertChild->getFirstChild(); while (subChild != NULL) { if (subChild->getName() == "Position") { if (subChild->hasChildren()) verts[i].fPosition.prcParse(subChild->getFirstChild()); } else if (subChild->getName() == "Normal") { if (subChild->hasChildren()) verts[i].fNormal.prcParse(subChild->getFirstChild()); } else if (subChild->getName() == "UVWs") { if ((fFormat & kUVWMask) / 0x10 != subChild->countChildren()) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect Number of UVW maps"); const pfPrcTag* uvwChild = subChild->getFirstChild(); for (size_t j=0; j<(size_t)((fFormat & kUVWMask) / 0x10); j++) { verts[i].fUVWs[j].prcParse(uvwChild); uvwChild = uvwChild->getNextSibling(); } } else if (subChild->getName() == "Weights") { std::list<plString> wgtList = subChild->getContents(); if (wgtList.size() != (fFormat & kWeightMask) / 0x100) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect Number of Weights"); auto wgt = wgtList.begin(); for (size_t j=0; j<(size_t)((fFormat & kWeightMask) / 0x100); j++) verts[i].fWeights[j] = (*wgt++).toFloat(); } else { throw pfPrcTagException(__FILE__, __LINE__, subChild->getName()); } subChild = subChild->getNextSibling(); } vertChild = vertChild->getNextSibling(); } setVertices(verts); } else if (child->getName() == "Indices") { fNumTris = child->countChildren(); fIndices = new unsigned short[fNumTris * 3]; const pfPrcTag* idxChild = child->getFirstChild(); for (size_t i=0; i<(size_t)(fNumTris * 3); i += 3) { std::list<plString> idxList = idxChild->getContents(); if (idxList.size() != 3) throw pfPrcParseException(__FILE__, __LINE__, "Triangles should have exactly 3 indices"); auto idx_iter = idxList.begin(); fIndices[i] = (*idx_iter++).toUint(); fIndices[i+1] = (*idx_iter++).toUint(); fIndices[i+2] = (*idx_iter++).toUint(); idxChild = idxChild->getNextSibling(); } } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } }
void plDrawableSpans::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "Properties") { fProps = tag->getParam("Flags", "0").toUint(); fCriteria = tag->getParam("Criteria", "0").toUint(); fRenderLevel = tag->getParam("RenderLevel", "0").toUint(); } else if (tag->getName() == "Materials") { fMaterials.setSize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fMaterials.getSize(); i++) { fMaterials[i] = mgr->prcParseKey(child); child = child->getNextSibling(); } } else if (tag->getName() == "Icicles") { for (size_t i=0; i<fIcicles.getSize(); i++) delete fIcicles[i]; fIcicles.setSize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fIcicles.getSize(); i++) { fIcicles[i] = new plIcicle(); fIcicles[i]->prcParse(child); child = child->getNextSibling(); } } else if (tag->getName() == "ParticleSpans") { for (size_t i=0; i<fParticleSpans.getSize(); i++) delete fParticleSpans[i]; fParticleSpans.setSize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fParticleSpans.getSize(); i++) { fParticleSpans[i] = new plParticleSpan(); fParticleSpans[i]->prcParse(child); child = child->getNextSibling(); } } else if (tag->getName() == "SpanSourceIndices") { fSpans.setSizeNull(tag->countChildren()); fSpanSourceIndices.setSizeNull(fSpans.getSize()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fSpanSourceIndices.getSize(); i++) { if (child->getName() != "SourceIndex") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); fSpanSourceIndices[i] = child->getParam("value", "0").toUint() | child->getParam("type", "0").toUint(); if ((fSpanSourceIndices[i] & kSpanTypeMask) == kSpanTypeIcicle) fSpans[i] = fIcicles[fSpanSourceIndices[i] & kSpanIDMask]; else if ((fSpanSourceIndices[i] & kSpanTypeMask) == kSpanTypeParticleSpan) fSpans[i] = fParticleSpans[fSpanSourceIndices[i] & kSpanIDMask]; child = child->getNextSibling(); } } else if (tag->getName() == "FogEnvironments") { size_t nChildren = tag->countChildren(); if (nChildren != fSpans.getSize()) throw pfPrcParseException(__FILE__, __LINE__, "Span count mismatch"); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<nChildren; i++) { fSpans[i]->setFogEnvironment(mgr->prcParseKey(child)); child = child->getNextSibling(); } } else if (tag->getName() == "LocalBounds") { if (tag->hasChildren()) fLocalBounds.prcParse(tag->getFirstChild()); } else if (tag->getName() == "WorldBounds") { if (tag->hasChildren()) fWorldBounds.prcParse(tag->getFirstChild()); } else if (tag->getName() == "MaxWorldBounds") { if (tag->hasChildren()) fMaxWorldBounds.prcParse(tag->getFirstChild()); } else if (tag->getName() == "PermaLightInfo") { size_t nChildren = tag->countChildren(); if (nChildren != fSpans.getSize()) throw pfPrcParseException(__FILE__, __LINE__, "Span count mismatch"); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<nChildren; i++) { if (child->getName() != "Span") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); const pfPrcTag* subChild = child->getFirstChild(); while (subChild != NULL) { if (subChild->getName() == "PermaLights") { size_t nLights = subChild->countChildren(); const pfPrcTag* light = subChild->getFirstChild(); for (size_t j=0; j<nLights; j++) { fSpans[i]->addPermaLight(mgr->prcParseKey(light)); light = light->getNextSibling(); } } else if (subChild->getName() == "PermaProjs") { size_t nLights = subChild->countChildren(); const pfPrcTag* light = subChild->getFirstChild(); for (size_t j=0; j<nLights; j++) { fSpans[i]->addPermaProj(mgr->prcParseKey(light)); light = light->getNextSibling(); } } else { throw pfPrcTagException(__FILE__, __LINE__, subChild->getName()); } subChild = subChild->getNextSibling(); } child = child->getNextSibling(); } } else if (tag->getName() == "SourceSpans") { fSourceSpans.setSizeNull(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fSourceSpans.getSize(); i++) { fSourceSpans[i].reset(new plGeometrySpan()); fSourceSpans[i]->prcParse(tag); if (fSpans[i]->getMaterialIdx() == 0xFFFFFFFF) fSourceSpans[i]->setMaterial(NULL); else fSourceSpans[i]->setMaterial(fMaterials[fSpans[i]->getMaterialIdx()]); fSourceSpans[i]->setFogEnvironment(fSpans[i]->getFogEnvironment()); child = child->getNextSibling(); } } else if (tag->getName() == "Transforms") { fLocalToWorlds.setSize(tag->countChildren()); fWorldToLocals.setSize(fLocalToWorlds.getSize()); fLocalToBones.setSize(fLocalToWorlds.getSize()); fBoneToLocals.setSize(fLocalToWorlds.getSize()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fLocalToWorlds.getSize(); i++) { if (child->getName() != "TransformSet") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); const pfPrcTag* subChild = child->getFirstChild(); while (subChild != NULL) { if (subChild->getName() == "LocalToWorld") { if (subChild->hasChildren()) fLocalToWorlds[i].prcParse(subChild->getFirstChild()); } else if (subChild->getName() == "WorldToLocal") { if (subChild->hasChildren()) fWorldToLocals[i].prcParse(subChild->getFirstChild()); } else if (subChild->getName() == "LocalToBone") { if (subChild->hasChildren()) fLocalToBones[i].prcParse(subChild->getFirstChild()); } else if (subChild->getName() == "BoneToLocal") { if (subChild->hasChildren()) fBoneToLocals[i].prcParse(subChild->getFirstChild()); } else { throw pfPrcTagException(__FILE__, __LINE__, subChild->getName()); } subChild = subChild->getNextSibling(); } child = child->getNextSibling(); } } else if (tag->getName() == "DIIndices") { fDIIndices.setSize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fDIIndices.getSize(); i++) { if (child->getName() != "plDISpanIndex") throw pfPrcTagException(__FILE__, __LINE__, child->getName()); fDIIndices[i].fFlags = child->getParam("Flags", "0").toUint(); fDIIndices[i].fIndices.setSize(child->countChildren()); const pfPrcTag* subChild = child->getFirstChild(); for (size_t j=0; j<(fDIIndices[i].fIndices.getSize()); j++) { if (subChild->getName() != "Index") throw pfPrcTagException(__FILE__, __LINE__, subChild->getName()); fDIIndices[i].fIndices[j] = subChild->getParam("value", "0").toUint(); subChild = subChild->getNextSibling(); } child = child->getNextSibling(); } } else if (tag->getName() == "BufferGroups") { for (size_t i=0; i<fGroups.getSize(); i++) delete fGroups[i]; fGroups.setSizeNull(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fGroups.getSize(); i++) { fGroups[i] = new plGBufferGroup(0); fGroups[i]->prcParse(child); child = child->getNextSibling(); } } else if (tag->getName() == "SpaceTree") { if (tag->hasChildren()) setSpaceTree(plSpaceTree::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "SceneNode") { if (tag->hasChildren()) fSceneNode = mgr->prcParseKey(tag->getFirstChild()); } else { hsKeyedObject::IPrcParse(tag, mgr); } }
void plParticleSystem::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "Material") { if (tag->hasChildren()) fMaterial = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "AmbientCtl") { if (tag->hasChildren() && !tag->getParam("NULL", "false").to_bool()) setAmbientCtl(plController::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "DiffuseCtl") { if (tag->hasChildren() && !tag->getParam("NULL", "false").to_bool()) setDiffuseCtl(plController::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "OpacityCtl") { if (tag->hasChildren() && !tag->getParam("NULL", "false").to_bool()) setOpacityCtl(plController::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "WidthCtl") { if (tag->hasChildren() && !tag->getParam("NULL", "false").to_bool()) setWidthCtl(plController::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "HeightCtl") { if (tag->hasChildren() && !tag->getParam("NULL", "false").to_bool()) setHeightCtl(plController::Convert(mgr->prcParseCreatable(tag->getFirstChild()))); } else if (tag->getName() == "ParticleParams") { fXTiles = tag->getParam("XTiles", "0").to_uint(); fYTiles = tag->getParam("YTiles", "0").to_uint(); fMaxTotalParticles = tag->getParam("MaxTotalParticles", "0").to_uint(); fMaxEmitters = tag->getParam("MaxEmitters", "0").to_uint(); fPreSim = tag->getParam("PreSim", "0").to_float(); fDrag = tag->getParam("Drag", "0").to_float(); fWindMult = tag->getParam("WindMult", "0").to_float(); } else if (tag->getName() == "Accel") { if (tag->hasChildren()) fAccel.prcParse(tag->getFirstChild()); } else if (tag->getName() == "Emitters") { for (auto emi = fEmitters.begin(); emi != fEmitters.end(); ++emi) delete *emi; fEmitters.resize(fMaxEmitters); fNumValidEmitters = tag->countChildren(); if (fNumValidEmitters > fMaxEmitters) throw pfPrcParseException(__FILE__, __LINE__, "Too many particle emitters"); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fNumValidEmitters; i++) { fEmitters[i] = plParticleEmitter::Convert(mgr->prcParseCreatable(child)); child = child->getNextSibling(); } } else if (tag->getName() == "Forces") { fForces.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fForces.size(); i++) { fForces[i] = mgr->prcParseKey(child); child = child->getNextSibling(); } } else if (tag->getName() == "Effects") { fEffects.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fEffects.size(); i++) { fEffects[i] = mgr->prcParseKey(child); child = child->getNextSibling(); } } else if (tag->getName() == "Constraints") { fConstraints.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fConstraints.size(); i++) { fConstraints[i] = mgr->prcParseKey(child); child = child->getNextSibling(); } } else if (tag->getName() == "PermaLights") { fPermaLights.resize(tag->countChildren()); const pfPrcTag* child = tag->getFirstChild(); for (size_t i=0; i<fPermaLights.size(); i++) { fPermaLights[i] = mgr->prcParseKey(child); child = child->getNextSibling(); } } else { plSynchedObject::IPrcParse(tag, mgr); } }
void plGenericPhysical::IPrcParse(const pfPrcTag* tag, plResManager* mgr) { if (tag->getName() == "PhysicalParams") { fMass = tag->getParam("Mass", "0").toFloat(); fFriction = tag->getParam("Friction", "0").toFloat(); fRestitution = tag->getParam("Restitution", "0").toFloat(); fLOSDBs = tag->getParam("LOSDBs", "0").toUint(); fCollideGroup = tag->getParam("CollideGroup", "0").toUint(); plString group = tag->getParam("MemberGroup", "kGroupStatic"); plString reports = tag->getParam("ReportGroup", ""); plString collides = tag->getParam("CollideGroup", ""); fMemberGroup = fReportGroup = fCollideGroup = 0; fDisableReport = (reports.find("kDisable") != -1); fDisableCollide = (collides.find("kDisable") != -1); for (size_t i=0; i<plSimDefs::kGroupMax; i++) { if (group.find(plSimDefs::GroupNames[i]) != -1) { fMemberGroup |= i; } if (reports.find(plSimDefs::GroupNames[i]) != -1) { fReportGroup |= (1 << i); } if (collides.find(plSimDefs::GroupNames[i]) != -1) { fCollideGroup |= (1 << i); } } } else if (tag->getName() == "Object") { if (tag->hasChildren()) fObjectKey = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "SceneNode") { if (tag->hasChildren()) fSceneNode = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "SubWorld") { if (tag->hasChildren()) fSubWorld = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "SoundGroup") { if (tag->hasChildren()) fSoundGroup = mgr->prcParseKey(tag->getFirstChild()); } else if (tag->getName() == "Transform") { const pfPrcTag* child = tag->getFirstChild(); while (child != NULL) { if (child->getName() == "hsVector3") { fPos.prcParse(child); } else if (child->getName() == "hsQuat") { fRot.prcParse(child); } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } } else if (tag->getName() == "Props") { if (tag->hasChildren()) fProps.prcParse(tag->getFirstChild()); } else if (tag->getName() == "Bounds" ) { plString bounds = tag->getParam("Type", "kBoxBounds"); for (size_t i=0; i<plSimDefs::kNumBounds; i++) if (bounds == plSimDefs::BoundsNames[i]) fBounds = (plSimDefs::Bounds)i; const pfPrcTag* child = tag->getFirstChild(); while (child != NULL) { if (child->getName() == "SphereBounds") { fRadius = child->getParam("Radius", "0").toFloat(); if (child->hasChildren()) fOffset.prcParse(child->getFirstChild()); } else if (child->getName() == "BoxBounds") { const pfPrcTag* subchild = child->getFirstChild(); while (subchild != NULL) { if (subchild->getName() == "Dimensions") { if (subchild->hasChildren()) fDimensions.prcParse(subchild->getFirstChild()); } else if (subchild->getName() == "Offset") { if (subchild->hasChildren()) fOffset.prcParse(subchild->getFirstChild()); } else { throw pfPrcTagException(__FILE__, __LINE__, subchild->getName()); } subchild = subchild->getNextSibling(); } } else if (child->getName() == "CylinderBounds") { fRadius = child->getParam("Radius", "0").toFloat(); fLength = child->getParam("Length", "0").toFloat(); } else if (child->getName() == "Verts") { fVerts.resize(child->countChildren()); const pfPrcTag* vert = child->getFirstChild(); for (size_t i=0; i<fVerts.size(); i++) { fVerts[i].prcParse(vert); vert = vert->getNextSibling(); } } else if (child->getName() == "Faces") { fIndices.resize(child->countChildren() * 3); const pfPrcTag* tri = child->getFirstChild(); for (size_t i=0; i<fIndices.size(); i += 3) { if (tri->getName() != "Triangle") throw pfPrcTagException(__FILE__, __LINE__, tri->getName()); std::list<plString> idxList = tri->getContents(); if (idxList.size() != 3) throw pfPrcParseException(__FILE__, __LINE__, "Triangles should have exactly 3 indices"); auto idx_iter = idxList.begin(); fIndices[i+0] = (*idx_iter++).toUint(); fIndices[i+1] = (*idx_iter++).toUint(); fIndices[i+2] = (*idx_iter++).toUint(); tri = tri->getNextSibling(); } } else if (child->getName() == "TriMeshDataBuffer") { fTMDSize = child->countChildren(); fTMDBuffer = new unsigned char[fTMDSize]; const pfPrcTag* face = child->getFirstChild(); for (size_t i=0; i<fTMDSize; i++) { if (face->getName() != "Face") throw pfPrcTagException(__FILE__, __LINE__, face->getName()); fTMDBuffer[i] = face->getParam("data", "0").toUint(); face = face->getNextSibling(); } } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } } else { plPhysical::IPrcParse(tag, mgr); } }
void plSpanInstance::prcParse(const pfPrcTag* tag, const plSpanEncoding& encoding, unsigned int numVerts) { if (tag->getName() != "plSpanInstance") throw pfPrcTagException(__FILE__, __LINE__, tag->getName()); fEncoding = encoding; fNumVerts = numVerts; const pfPrcTag* child = tag->getFirstChild(); while (child != NULL) { if (child->getName() == "Local2World") { std::list<ST::string> contents = child->getContents(); auto iter = contents.begin(); if (*iter++ != "[") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][3] = (*iter++).to_float(); if (*iter++ != ";") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][3] = (*iter++).to_float(); if (*iter++ != ";") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][3] = (*iter++).to_float(); if (*iter++ != "]") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); } else if (child->getName() == "PosDeltas") { if (child->countChildren() != fNumVerts) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect vertex count"); const pfPrcTag* posChild = child->getFirstChild(); std::vector<hsVector3> verts(fNumVerts); for (size_t i=0; i<fNumVerts; i++) { verts[i].prcParse(posChild); posChild = posChild->getNextSibling(); } setPosDeltas(verts); } else if (child->getName() == "Colors") { if (child->countChildren() != fNumVerts) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect vertex count"); const pfPrcTag* colorChild = child->getFirstChild(); std::vector<unsigned int> colors(fNumVerts); for (size_t i=0; i<fNumVerts; i++) { if (colorChild->getName() != "Color") throw pfPrcTagException(__FILE__, __LINE__, colorChild->getName()); colors[i] = colorChild->getParam("value", "0").to_uint(); colorChild = colorChild->getNextSibling(); } setColors(colors); } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } }