本文整理汇总了C++中JSONValue::GetFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::GetFloat方法的具体用法?C++ JSONValue::GetFloat怎么用?C++ JSONValue::GetFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONValue
的用法示例。
在下文中一共展示了JSONValue::GetFloat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadSettingsInternal
bool ModelImporter::LoadSettingsInternal()
{
if (!AssetImporter::LoadSettingsInternal())
return false;
JSONValue import = jsonRoot_.GetChild("ModelImporter", JSON_OBJECT);
SetDefaults();
if (import.HasMember("scale"))
scale_ = import.GetFloat("scale");
if (import.HasMember("importAnimations"))
importAnimations_ = import.GetBool("importAnimations");
if (import.HasMember("animInfo"))
{
JSONValue animInfo = import.GetChild("animInfo");
for (unsigned i = 0; i < animInfo.GetSize(); i++)
{
JSONValue anim = animInfo.GetChild(i);
SharedPtr<AnimationImportInfo> info(new AnimationImportInfo(context_));
info->name_ = anim.GetString("name");
info->SetStartTime(anim.GetFloat("startTime"));
info->SetEndTime(anim.GetFloat("endTime"));
animationInfo_.Push(info);
}
}
return true;
}
示例2: BeginLoad
bool Animation::BeginLoad(Deserializer& source)
{
unsigned memoryUse = sizeof(Animation);
// Check ID
if (source.ReadFileID() != "UANI")
{
URHO3D_LOGERROR(source.GetName() + " is not a valid animation file");
return false;
}
// Read name and length
animationName_ = source.ReadString();
animationNameHash_ = animationName_;
length_ = source.ReadFloat();
tracks_.Clear();
unsigned tracks = source.ReadUInt();
memoryUse += tracks * sizeof(AnimationTrack);
// Read tracks
for (unsigned i = 0; i < tracks; ++i)
{
AnimationTrack* newTrack = CreateTrack(source.ReadString());
newTrack->channelMask_ = source.ReadUByte();
unsigned keyFrames = source.ReadUInt();
newTrack->keyFrames_.Resize(keyFrames);
memoryUse += keyFrames * sizeof(AnimationKeyFrame);
// Read keyframes of the track
for (unsigned j = 0; j < keyFrames; ++j)
{
AnimationKeyFrame& newKeyFrame = newTrack->keyFrames_[j];
newKeyFrame.time_ = source.ReadFloat();
if (newTrack->channelMask_ & CHANNEL_POSITION)
newKeyFrame.position_ = source.ReadVector3();
if (newTrack->channelMask_ & CHANNEL_ROTATION)
newKeyFrame.rotation_ = source.ReadQuaternion();
if (newTrack->channelMask_ & CHANNEL_SCALE)
newKeyFrame.scale_ = source.ReadVector3();
}
}
// Optionally read triggers from an XML file
ResourceCache* cache = GetSubsystem<ResourceCache>();
String xmlName = ReplaceExtension(GetName(), ".xml");
SharedPtr<XMLFile> file(cache->GetTempResource<XMLFile>(xmlName, false));
if (file)
{
XMLElement rootElem = file->GetRoot();
XMLElement triggerElem = rootElem.GetChild("trigger");
while (triggerElem)
{
if (triggerElem.HasAttribute("normalizedtime"))
AddTrigger(triggerElem.GetFloat("normalizedtime"), true, triggerElem.GetVariant());
else if (triggerElem.HasAttribute("time"))
AddTrigger(triggerElem.GetFloat("time"), false, triggerElem.GetVariant());
triggerElem = triggerElem.GetNext("trigger");
}
memoryUse += triggers_.Size() * sizeof(AnimationTriggerPoint);
SetMemoryUse(memoryUse);
return true;
}
// Optionally read triggers from a JSON file
String jsonName = ReplaceExtension(GetName(), ".json");
SharedPtr<JSONFile> jsonFile(cache->GetTempResource<JSONFile>(jsonName, false));
if (jsonFile)
{
const JSONValue& rootVal = jsonFile->GetRoot();
JSONArray triggerArray = rootVal.Get("triggers").GetArray();
for (unsigned i = 0; i < triggerArray.Size(); i++)
{
const JSONValue& triggerValue = triggerArray.At(i);
JSONValue normalizedTimeValue = triggerValue.Get("normalizedTime");
if (!normalizedTimeValue.IsNull())
AddTrigger(normalizedTimeValue.GetFloat(), true, triggerValue.GetVariant());
else
{
JSONValue timeVal = triggerValue.Get("time");
if (!timeVal.IsNull())
AddTrigger(timeVal.GetFloat(), false, triggerValue.GetVariant());
}
}
memoryUse += triggers_.Size() * sizeof(AnimationTriggerPoint);
SetMemoryUse(memoryUse);
return true;
}
SetMemoryUse(memoryUse);
return true;
}