Created
May 28, 2017 21:39
-
-
Save Romain-P/aa6584d5cff03d12ab68376aa0656dcc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static t_object *create_object(t_key *key) | |
| { | |
| t_object *object; | |
| if (!(object = malloc(sizeof(t_object)))) | |
| return (NULL); | |
| object->type = keyget_integer(key, "type"); | |
| object->position = my_create_sfvector3f(keyget_integer(key, "position.x"), | |
| keyget_integer(key, "position.y"), | |
| keyget_integer(key, "position.z")); | |
| object->rotation = my_create_sfvector3f(keyget_integer(key, "rotation.x"), | |
| keyget_integer(key, "rotation.y"), | |
| keyget_integer(key, "rotation.z")); | |
| object->info = keyget_integer(key, "info"); | |
| object->color.r = keyget_integer(key, "color.r"); | |
| object->color.g = keyget_integer(key, "color.g"); | |
| object->color.b = keyget_integer(key, "color.b"); | |
| object->color.a = keyget_integer(key, "color.a"); | |
| object->brillance = keyget_integer(key, "brillance"); | |
| object->reflection = keyget_integer(key, "reflection"); | |
| object->transparency = keyget_integer(key, "transparency"); | |
| object->refraction_i = keyget_integer(key, "refraction_i"); | |
| return (object); | |
| } | |
| t_array *my_create_objects(t_config *config) | |
| { | |
| t_key *objects; | |
| t_array *keys; | |
| t_array *array; | |
| int i; | |
| if (!(array = array_create())) | |
| return (NULL); | |
| objects = get_key(config, "objects"); | |
| keys = (t_array *) objects->value; | |
| i = -1; | |
| while (((t_key **) keys->values)[++i]) | |
| array_add(array, create_object((t_key *) keys->values[i])); | |
| return (array); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment