bool psCharAppearance::ChangeMaterial(const char* part, const char* materialName) { if (!part || !materialName) return false; csString materialNameParsed = ParseStrings(part, materialName); bool failed = false; csRef<iMaterialWrapper> material = psengine->GetLoader()->LoadMaterial(materialNameParsed, &failed); if(!failed) { if(!material.IsValid()) { Attachment attach(false); attach.materialName = materialNameParsed; attach.partName = part; if(delayedAttach.IsEmpty()) { psengine->RegisterDelayedLoader(this); } delayedAttach.PushBack(attach); return true; } ProcessAttach(material, materialName, part); return true; } // The material isn't available to load. csReport(psengine->GetObjectRegistry(), CS_REPORTER_SEVERITY_NOTIFY, "planeshift.character.appearance", "Attempted to change to material %s and failed; material not found.", materialNameParsed.GetData()); return false; }
void psCharAppearance::HairMesh(csString& subMesh) { hairMesh = subMesh; if ( hairMesh.Length() == 0 ) { hairMesh = "Hair"; } csString newPartParsed = ParseStrings("Hair", hairMesh); if(state && stateFactory) { int newMeshAvailable = stateFactory->FindMeshName(newPartParsed); if ( newMeshAvailable == -1 ) { return; } else { for ( int idx=0; idx < stateFactory->GetMeshCount(); idx++) { const char* meshName = stateFactory->GetMeshName(idx); if ( strstr(meshName, "Hair") ) { state->DetachCoreMesh(meshName); } } state->AttachCoreMesh(newPartParsed); hairAttached = true; hairMesh = newPartParsed; } } else if(animeshObject && animeshFactory) { for ( size_t idx=0; idx < animeshFactory->GetSubMeshCount(); idx++) { const char* meshName = animeshFactory->GetSubMesh(idx)->GetName(); if(meshName) { if (strstr(meshName, "Hair")) { animeshObject->GetSubMesh(idx)->SetRendering(false); } if (!strcmp(meshName, newPartParsed)) { animeshObject->GetSubMesh(idx)->SetRendering(true); hairAttached = true; beardMesh = newPartParsed; } } } } if ( hairColorSet ) HairColor(hairShader); }
int main(int argc, char* argv[]) { //Check input if(argc != 7) { Usage(); return -1; } //Get current date time_t t = time(NULL); struct tm date = *localtime(&t); MakeAbsoluteDate(&date); //Parse birthday struct tm birthday; ParseStrings(&birthday, argv + 1); //Print both printf("Now it is "); FormattedPrint(&date); printf("Your birthday is "); FormattedPrint(&birthday); //Find the difference double differenceInSeconds = difftime(mktime(&date), mktime(&birthday)); printf("The difference in seconds is %f\n", differenceInSeconds); struct tm difference; SubtractDates(&difference, &date, &birthday); printf("The difference is "); FormattedPrint(&difference); return 0; }
bool psCharAppearance::ChangeMesh(const char* partPattern, const char* newPart) { csString newPartParsed = ParseStrings(partPattern, newPart); if(stateFactory && state) { // If the new mesh cannot be found then do nothing. int newMeshAvailable = stateFactory->FindMeshName(newPartParsed); if ( newMeshAvailable == -1 ) return false; /* First we detach every mesh that match the partPattern */ for (int idx=0; idx < stateFactory->GetMeshCount(); idx++) { const char * meshName = stateFactory->GetMeshName( idx ); if (strstr(meshName,partPattern)) { state->DetachCoreMesh( meshName ); } } state->AttachCoreMesh( newPartParsed.GetData() ); } else if(animeshFactory && animeshObject) { // If the new mesh cannot be found then do nothing. size_t newMeshAvailable = animeshFactory->FindSubMesh(newPartParsed); if ( newMeshAvailable == (size_t)-1 ) return false; /* First we detach every mesh that match the partPattern */ for ( size_t idx=0; idx < animeshFactory->GetSubMeshCount(); idx++) { const char* meshName = animeshFactory->GetSubMesh(idx)->GetName(); if(meshName) { if (strstr(meshName, partPattern)) { animeshObject->GetSubMesh(idx)->SetRendering(false); } if (!strcmp(meshName, newPartParsed)) { animeshObject->GetSubMesh(idx)->SetRendering(true); } } } } return true; }
void psCharAppearance::Equip( csString& slotname, csString& mesh, csString& part, csString& subMesh, csString& texture ) { //Bracers must be managed separately as we have two slots in cal3d but only one slot here //To resolve the problem we call recursively this same function with the "corrected" slot names //which are rightarm leftarm if (slotname == "bracers") { for(unsigned int position = 0; position < bracersSlotCount; position++) Equip(BracersSlots[position], mesh, part, subMesh, texture); return; } if ( slotname == "helm" ) { ShowHair(false); } // If it's a new mesh attach that mesh. if ( mesh.Length() ) { if( texture.Length() && !subMesh.Length() ) Attach(slotname, mesh, texture); else Attach(slotname, mesh); } // This is a subMesh on the model change so change the mesh for that part. if ( subMesh.Length() ) { // Change the mesh on the part of the model. ChangeMesh(part, subMesh); // If there is also a new material ( texture ) then place that on as well. if ( texture.Length() ) { ChangeMaterial( ParseStrings(part,subMesh), texture); } } else if ( part.Length() ) { ChangeMaterial(part, texture); } }