Scene3DMesh* SGMExporter::ConvertMesh(IGameNode* meshNode) { std::string meshNodeName = StringUtils::ToNarrow(meshNode->GetName()); Log::LogT("exporting node '%s'", meshNodeName.c_str()); IGameMesh *gMesh = (IGameMesh*)meshNode ->GetIGameObject(); assert(gMesh); if (!gMesh ->InitializeData()) { Log::LogT("error: couldnt initialize data, skipping node"); return NULL; } if (!gMesh->IsObjectSkinned()) { Log::LogT("Mesh '%s' is not skinned", meshNodeName.c_str()); meshNode->ReleaseIGameObject(); return NULL; } else Log::LogT("Mesh '%s' is skinned", meshNodeName.c_str()); Scene3DMesh *mesh = new Scene3DMesh(); mesh->id = meshNode->GetNodeID(); mesh->name = StringUtils::ToNarrow(meshNode->GetName()); CollectProperties(mesh, gMesh); IGameMaterial *mat = meshNode ->GetNodeMaterial(); if (mat != NULL) mesh->materialName = StringUtils::ToNarrow(mat->GetMaterialName()); IGameSkin* skin = gMesh->GetIGameSkin(); for (int i = 0; i < skin->GetTotalSkinBoneCount(); i++) mesh->bonesIds.push_back(skin->GetIGameBone(i)->GetNodeID()); for (int i = 0; i < gMesh ->GetNumberOfFaces(); i++) ExtractVertices(skin, gMesh ->GetFace(i), gMesh, mesh->vertices); Log::LogT("Min bones = %d, max bones = %d", dbgMinBonesCount, dbgMaxBonesCount); meshNode ->ReleaseIGameObject(); return mesh; }
void USQLiteDatabase::AssignResultsToObjectProperties(const SQLiteResultValue& ResultValue, UObject* ObjectToPopulate) { auto propertyMap = CollectProperties(ObjectToPopulate); for (SQLiteResultField field : ResultValue.Fields) { if (propertyMap.Contains(field.Name)) { UProperty* targetProperty = propertyMap[field.Name]; if (field.Type == SQLiteResultValueTypes::Integer) { UInt64Property* int64prop = NULL; UIntProperty* int32prop = NULL; UInt16Property* int16prop = NULL; UInt8Property* int8prop = NULL; UBoolProperty* boolProp = NULL; if ((int64prop = Cast<UInt64Property>(targetProperty)) != NULL) { int64prop->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } else if ((int32prop = Cast<UIntProperty>(targetProperty)) != NULL) { int32prop->SetPropertyValue_InContainer(ObjectToPopulate, (int32)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } else if ((int16prop = Cast<UInt16Property>(targetProperty)) != NULL) { int16prop->SetPropertyValue_InContainer(ObjectToPopulate, (int16)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } else if ((int8prop = Cast<UInt8Property>(targetProperty)) != NULL) { int8prop->SetPropertyValue_InContainer(ObjectToPopulate, (int8)field.IntValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } else if ((boolProp = Cast<UBoolProperty>(targetProperty)) != NULL) { boolProp->SetPropertyValue_InContainer(ObjectToPopulate, field.IntValue > 0); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%d'"), *field.Name, field.IntValue)); } } else if (field.Type == SQLiteResultValueTypes::Float) { UDoubleProperty* doubleProp = NULL; UFloatProperty* floatProp = NULL; if ((doubleProp = Cast<UDoubleProperty>(targetProperty)) != NULL) { doubleProp->SetPropertyValue_InContainer(ObjectToPopulate, field.DoubleValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue)); } else if ((floatProp = Cast<UFloatProperty>(targetProperty)) != NULL) { floatProp->SetPropertyValue_InContainer(ObjectToPopulate, (float)field.DoubleValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%f'"), *field.Name, field.DoubleValue)); } } else if (field.Type == SQLiteResultValueTypes::Text) { UStrProperty* strProp = NULL; if ((strProp = Cast<UStrProperty>(targetProperty)) != NULL) { strProp->SetPropertyValue_InContainer(ObjectToPopulate, field.StringValue); LOGSQLITE(Verbose, *FString::Printf(TEXT("Property '%s' was set to '%s'"), *field.Name, *field.StringValue.Mid(0, 64))); } } } } }