64 p.colideWithPlayer =
j[
"playerColide"];
70 obj = GameObjectManager->createGameObject(
j[
"mesh"],
j[
"name"]);
73 obj->setPosition(
j[
"position"]);
74 obj->setOrientation(
j[
"orientation"]);
75 obj->setScale(
j[
"scale"]);
84 if(!
j[
"scripts"].is_null())
86 for(
auto& jsonScript :
j[
"scripts"])
87 obj->attachScript(jsonScript);
103 l = GameObjectManager->createLightObject(
j[
"name"]);
109 l->setPower(
j[
"power"]);
111 l->setPosition(
j[
"position"]);
113 l->setDirection(
j[
"direction"]);
126 if(res.
type ==
"Zip")
127 resourceManager->addZipLocation(res.
path, res.
group);
132 if(!
j[
"group"].is_null())
133 p.group =
j[
"group"];
145 preloadResources(preload)
147 jsonFile = std::make_unique<AnnJson>();
166 json = json_t::parse(file);
173 preloadResources(preload)
175 jsonFile = std::make_unique<AnnJson>();
177 json = json_t::parse(jsonCode);
189 for(
auto& jsonGameObject : json[
"content"])
190 levelContent.push_back(jsonGameObject);
192 for(
auto& jsonLight : json[
"lighting"])
193 levelLighting.push_back(jsonLight);
196 player->setPosition(json[
"player"][
"startPosition"]);
197 player->setOrientation(json[
"player"][
"startOrientation"].get<AnnQuaternion>());
198 AnnDebug() <<
"Player position reset";
199 AnnDebug() << player->getPosition();
200 AnnDebug() << player->getOrientation();
215 if(!json[
"resources"].is_null())
216 AnnDebug() <<
"Defined " << json[
"resources"].size() <<
" resources";
217 for(
const resLocParam resource : json[
"resources"])
221 if(
preloadResources && resource.group != resourceManager->getDefaultResourceGroupName())
223 resourceManager->loadGroup(resource.group);
void declareResource(const resLocParam &res)
Directional lights simulate parallel light beams from a distant source, hence have direction but no p...
phyShapeType stringToShape(const std::string &str)
Spotlights simulate a cone of light from a source so require position and direction,...
AnnLightObject::LightTypes lightTypeFromString(const std::string &s)
Namespace containing the totality of Annwvyn components.
void runLogic() override
Run logic, actually empty here.
LightTypes
Defines the type of light.
Exception regarding engine utilisation. See message.
AnnGameObjectManagerPtr AnnGetGameObjectManager()
Get the game-object manager.
virtual ~AnnJsonLevel()
Dtor.
static const char * getDefaultResourceGroupName()
Return the default resource group name.
AnnJsonOpaquePtr jsonFile
Pimpl.
void processJson()
Do initial processing on JSON.
Open an output stream to the engine log.
void from_json(const json_t &j, AnnVect3 &v)
Exception regarding collision shape creation.
Main Annwvyn include file (to be used by client application)
Point light sources give off light equally in all directions, so require only position not direction.
void load() override
Load method. This goes through the loaded JSON and create the object for you.
const bool preloadResources
If set to false, resource group will not be initialized.
AnnResourceManagerPtr AnnGetResourceManager()
Get the resource manager.
AnnJsonLevel(std::string path, bool preload=true)
Construct a JSON level from a file.
Exception regarding an AnnGameObject that was null when it wasnt.
AnnPlayerBodyPtr AnnGetPlayer()
Get the player object.