RID MeshBufferParser::parse(JSONReader& reader, int childIndex) { MeshBufferDescriptor descriptor; reader.get(childIndex, "size", &descriptor.size); const char* indexBufferName = reader.get_string(childIndex, "index_buffer"); descriptor.indexBuffer = find(indexBufferName, ResourceType::INDEXBUFFER); const char* constantBufferName = reader.get_string(childIndex, "constant_buffer"); descriptor.constantBuffer = find(constantBufferName, ResourceType::CONSTANTBUFFER); const char* vertexBufferName = reader.get_string(childIndex, "vertex_buffer"); descriptor.vertexBuffer = find(vertexBufferName, ResourceType::VERTEXBUFFER); const char* materialName = reader.get_string(childIndex, "material"); descriptor.material = find(materialName, ResourceType::MATERIAL); const char* name = reader.get_string(childIndex, "name"); return createMeshBuffer(name, descriptor); }
RID BlendStateParser::parse(JSONReader& reader, int childIndex) { BlendStateDescriptor descriptor; const char* entry = reader.get_string(childIndex, "src_blend"); descriptor.srcBlend = findBlendStateMapping(entry); entry = reader.get_string(childIndex, "dest_blend"); descriptor.destBlend = findBlendStateMapping(entry); entry = reader.get_string(childIndex, "src_blend_alpha"); descriptor.srcAlphaBlend = findBlendStateMapping(entry); entry = reader.get_string(childIndex, "dest_blend_alpha"); descriptor.destAlphaBlend = findBlendStateMapping(entry); reader.get(childIndex, "alpha_enabled", &descriptor.alphaEnabled); const char* name = reader.get_string(childIndex, "name"); return createBlendState(name, descriptor); }
bool SpriteSheet::loadData(const JSONReader& loader) { int categories[256]; int num = loader.get_categories(categories, 256); for (int i = 0; i < num; ++i) { Rect r; loader.get(categories[i], "rect", &r); const char* sn = loader.get_string(categories[i], "name"); add(sn, r); } return true; }
bool SpriteSheet::reloadData(const JSONReader& loader) { int categories[256]; int num = loader.get_categories(categories, 256); for (int i = 0; i < num; ++i) { Rect r; loader.get(categories[i], "rect", &r); const char* sn = loader.get_string(categories[i], "name"); int idx = findIndex(sn); if (idx == -1) { add(sn, r); } else { SheetEntry& se = _entries[idx]; se.texture = Texture(r); } } return true; }
RID IndexBufferParser::parse(JSONReader& reader, int childIndex) { IndexBufferDescriptor descriptor; reader.get(childIndex, "size", &descriptor.size); const char* name = reader.get_string(childIndex, "name"); return createIndexBuffer(name, descriptor); }
RID ParticleManagerParser::parse(JSONReader& reader, int childIndex) { ParticleSystemsDescriptor descriptor; reader.get(childIndex, "sprite_buffer", &descriptor.spriteBuffer); const char* name = reader.get_string(childIndex, "name"); return createParticleManager(descriptor); }