COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Cosmos::wavefront::material Struct Reference

#include <objlib.h>

Collaboration diagram for Cosmos::wavefront::material:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

string name = ""
 
float density = 0.f
 
Vector ambient
 
Vector diffuse
 
Vector specular
 

Member Function Documentation

json11::Json Cosmos::wavefront::material::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
266  {
267  return json11::Json::object {
268  { "name" , name },
269  { "density" , density },
270  { "ambient" , ambient },
271  { "diffuse" , diffuse },
272  { "specular", specular }
273  };
274  }
string name
Definition: objlib.h:256
std::map< std::string, Json > object
Definition: json11.hpp:88
float density
Definition: objlib.h:257
Vector specular
Definition: objlib.h:260
Vector diffuse
Definition: objlib.h:259
Vector ambient
Definition: objlib.h:258
void Cosmos::wavefront::material::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
282  {
283  string error;
285  if(error.empty()) {
286  if(!p["name"].is_null()) name = p["name"].string_value();
287  if(!p["density"].is_null()) density = p["density"].number_value();
288  if(!p["ambient"].is_null()) ambient.from_json(p["ambient"].dump());
289  if(!p["diffuse"].is_null()) diffuse.from_json(p["diffuse"].dump());
290  if(!p["specular"].is_null()) specular.from_json(p["specular"].dump());
291  } else {
292  cerr<<"ERROR: <"<<error<<">"<<endl;
293  }
294  return;
295  }
string name
Definition: objlib.h:256
Definition: json11.hpp:79
float density
Definition: objlib.h:257
Vector specular
Definition: objlib.h:260
static double * p
Definition: gauss_jackson_test.cpp:42
void dump(std::string &out) const
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:783
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
Vector diffuse
Definition: objlib.h:259
Vector ambient
Definition: objlib.h:258

Member Data Documentation

string Cosmos::wavefront::material::name = ""
float Cosmos::wavefront::material::density = 0.f
Vector Cosmos::wavefront::material::ambient
Vector Cosmos::wavefront::material::diffuse
Vector Cosmos::wavefront::material::specular

The documentation for this struct was generated from the following file: