Vuo  2.3.2
VuoCubemap.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoCubemap.h"
12 
14 #ifdef VUO_COMPILER
16  "title" : "Cubemap",
17  "description" : "A collection of images for the 6 sides of a cube",
18  "keywords" : [
19  "skybox", "environment map", "360", "180", "VR", "360vr",
20  ],
21  "version" : "1.0.0",
22  "dependencies" : [
23  "VuoImage",
24  "VuoText",
25  ],
26 });
27 #endif
29 
33 typedef struct
34 {
35  VuoImage front;
36  VuoImage left;
37  VuoImage right;
38  VuoImage back;
39  VuoImage top;
40  VuoImage bottom;
41 } VuoCubemap_internal;
42 
48 void VuoCubemap_free(void *cubemap)
49 {
50  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
51 
52  VuoRelease(c->front);
53  VuoRelease(c->left);
54  VuoRelease(c->right);
55  VuoRelease(c->back);
56  VuoRelease(c->top);
57  VuoRelease(c->bottom);
58 
59  free(c);
60 }
61 
68 {
69  VuoCubemap_internal *c = (VuoCubemap_internal *)calloc(1, sizeof(VuoCubemap_internal));
70  VuoRegister(c, VuoCubemap_free);
71 
72  VuoRetain(front);
73  c->front = front;
74 
75  VuoRetain(left);
76  c->left = left;
77 
78  VuoRetain(right);
79  c->right = right;
80 
81  VuoRetain(back);
82  c->back = back;
83 
84  VuoRetain(top);
85  c->top = top;
86 
87  VuoRetain(bottom);
88  c->bottom = bottom;
89 
90  return (VuoCubemap)c;
91 }
92 
99 {
100  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
101  return c->front;
102 }
103 
110 {
111  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
112  return c->left;
113 }
114 
121 {
122  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
123  return c->right;
124 }
125 
132 {
133  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
134  return c->back;
135 }
136 
143 {
144  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
145  return c->top;
146 }
147 
154 {
155  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
156  return c->bottom;
157 }
158 
164 {
166  VuoJson_getObjectValue(VuoImage, js, "front", NULL),
167  VuoJson_getObjectValue(VuoImage, js, "left", NULL),
168  VuoJson_getObjectValue(VuoImage, js, "right", NULL),
169  VuoJson_getObjectValue(VuoImage, js, "back", NULL),
170  VuoJson_getObjectValue(VuoImage, js, "top", NULL),
171  VuoJson_getObjectValue(VuoImage, js, "bottom", NULL));
172 }
173 
179 {
180  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
181 
182  json_object *js = json_object_new_object();
183  json_object_object_add(js, "front", VuoImage_getJson(c->front));
184  json_object_object_add(js, "left", VuoImage_getJson(c->left));
185  json_object_object_add(js, "right", VuoImage_getJson(c->right));
186  json_object_object_add(js, "back", VuoImage_getJson(c->back));
187  json_object_object_add(js, "top", VuoImage_getJson(c->top));
188  json_object_object_add(js, "bottom", VuoImage_getJson(c->bottom));
189 
190  return js;
191 }
192 
197 char *VuoCubemap_getSummary(const VuoCubemap cubemap)
198 {
199  VuoCubemap_internal *c = (VuoCubemap_internal *)cubemap;
200 
201  return VuoText_format("<table><tr><th>Front</th><td>%lu×%lu</td></tr><tr><th>Left</th><td>%lu×%lu</td></tr><tr><th>Right</th><td>%lu×%lu</td></tr><tr><th>Back</th><td>%lu×%lu</td></tr><tr><th>Top</th><td>%lu×%lu</td></tr><tr><th>Bottom</th><td>%lu×%lu</td></tr>",
202  c->front ? c->front->pixelsWide : 0, c->front ? c->front->pixelsHigh : 0,
203  c->left ? c->left->pixelsWide : 0, c->left ? c->left->pixelsHigh : 0,
204  c->right ? c->right->pixelsWide : 0, c->right ? c->right->pixelsHigh : 0,
205  c->back ? c->back->pixelsWide : 0, c->back ? c->back->pixelsHigh : 0,
206  c->top ? c->top->pixelsWide : 0, c->top ? c->top->pixelsHigh : 0,
207  c->bottom ? c->bottom->pixelsWide : 0, c->bottom ? c->bottom->pixelsHigh : 0);
208 }