1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module graphene.Frustum; 26 27 private import glib.ConstructionException; 28 private import glib.MemorySlice; 29 private import gobject.ObjectG; 30 private import graphene.Box; 31 private import graphene.Matrix; 32 private import graphene.Plane; 33 private import graphene.Point3D; 34 private import graphene.Sphere; 35 private import graphene.c.functions; 36 public import graphene.c.types; 37 private import gtkd.Loader; 38 39 40 /** 41 * A 3D volume delimited by 2D clip planes. 42 * 43 * The contents of the `graphene_frustum_t` are private, and should not be 44 * modified directly. 45 * 46 * Since: 1.2 47 */ 48 public class Frustum 49 { 50 /** the main Gtk struct */ 51 protected graphene_frustum_t* graphene_frustum; 52 protected bool ownedRef; 53 54 /** Get the main Gtk struct */ 55 public graphene_frustum_t* getFrustumStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return graphene_frustum; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected void* getStruct() 64 { 65 return cast(void*)graphene_frustum; 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (graphene_frustum_t* graphene_frustum, bool ownedRef = false) 72 { 73 this.graphene_frustum = graphene_frustum; 74 this.ownedRef = ownedRef; 75 } 76 77 ~this () 78 { 79 if ( Linker.isLoaded(LIBRARY_GRAPHENE) && ownedRef ) 80 graphene_frustum_free(graphene_frustum); 81 } 82 83 84 /** */ 85 public static GType getType() 86 { 87 return graphene_frustum_get_type(); 88 } 89 90 /** 91 * Allocates a new #graphene_frustum_t structure. 92 * 93 * The contents of the returned structure are undefined. 94 * 95 * Returns: the newly allocated #graphene_frustum_t 96 * structure. Use graphene_frustum_free() to free the resources 97 * allocated by this function. 98 * 99 * Since: 1.2 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this() 104 { 105 auto __p = graphene_frustum_alloc(); 106 107 if(__p is null) 108 { 109 throw new ConstructionException("null returned by alloc"); 110 } 111 112 this(cast(graphene_frustum_t*) __p); 113 } 114 115 /** 116 * Checks whether a point is inside the volume defined by the given 117 * #graphene_frustum_t. 118 * 119 * Params: 120 * point = a #graphene_point3d_t 121 * 122 * Returns: `true` if the point is inside the frustum 123 * 124 * Since: 1.2 125 */ 126 public bool containsPoint(Point3D point) 127 { 128 return graphene_frustum_contains_point(graphene_frustum, (point is null) ? null : point.getPoint3DStruct()) != 0; 129 } 130 131 /** 132 * Checks whether the two given #graphene_frustum_t are equal. 133 * 134 * Params: 135 * b = a #graphene_frustum_t 136 * 137 * Returns: `true` if the given frustums are equal 138 * 139 * Since: 1.6 140 */ 141 public bool equal(Frustum b) 142 { 143 return graphene_frustum_equal(graphene_frustum, (b is null) ? null : b.getFrustumStruct()) != 0; 144 } 145 146 /** 147 * Frees the resources allocated by graphene_frustum_alloc(). 148 * 149 * Since: 1.2 150 */ 151 public void free() 152 { 153 graphene_frustum_free(graphene_frustum); 154 ownedRef = false; 155 } 156 157 /** 158 * Retrieves the planes that define the given #graphene_frustum_t. 159 * 160 * Params: 161 * planes = return location for an array 162 * of 6 #graphene_plane_t 163 * 164 * Since: 1.2 165 */ 166 public void getPlanes(out Plane[6] planes) 167 { 168 graphene_plane_t* outplanes = cast(graphene_plane_t*)sliceAlloc0(graphene_plane_t.sizeof * 6); 169 170 graphene_frustum_get_planes(graphene_frustum, outplanes); 171 172 for(size_t i = 0; i < 6; i++) 173 { 174 planes[i] = ObjectG.getDObject!(Plane)(cast(graphene_plane_t*) &outplanes[i]); 175 } 176 } 177 178 /** 179 * Initializes the given #graphene_frustum_t using the provided 180 * clipping planes. 181 * 182 * Params: 183 * p0 = a clipping plane 184 * p1 = a clipping plane 185 * p2 = a clipping plane 186 * p3 = a clipping plane 187 * p4 = a clipping plane 188 * p5 = a clipping plane 189 * 190 * Returns: the initialized frustum 191 * 192 * Since: 1.2 193 */ 194 public Frustum init(Plane p0, Plane p1, Plane p2, Plane p3, Plane p4, Plane p5) 195 { 196 auto __p = graphene_frustum_init(graphene_frustum, (p0 is null) ? null : p0.getPlaneStruct(), (p1 is null) ? null : p1.getPlaneStruct(), (p2 is null) ? null : p2.getPlaneStruct(), (p3 is null) ? null : p3.getPlaneStruct(), (p4 is null) ? null : p4.getPlaneStruct(), (p5 is null) ? null : p5.getPlaneStruct()); 197 198 if(__p is null) 199 { 200 return null; 201 } 202 203 return ObjectG.getDObject!(Frustum)(cast(graphene_frustum_t*) __p); 204 } 205 206 /** 207 * Initializes the given #graphene_frustum_t using the clipping 208 * planes of another #graphene_frustum_t. 209 * 210 * Params: 211 * src = a #graphene_frustum_t 212 * 213 * Returns: the initialized frustum 214 * 215 * Since: 1.2 216 */ 217 public Frustum initFromFrustum(Frustum src) 218 { 219 auto __p = graphene_frustum_init_from_frustum(graphene_frustum, (src is null) ? null : src.getFrustumStruct()); 220 221 if(__p is null) 222 { 223 return null; 224 } 225 226 return ObjectG.getDObject!(Frustum)(cast(graphene_frustum_t*) __p); 227 } 228 229 /** 230 * Initializes a #graphene_frustum_t using the given @matrix. 231 * 232 * Params: 233 * matrix = a #graphene_matrix_t 234 * 235 * Returns: the initialized frustum 236 * 237 * Since: 1.2 238 */ 239 public Frustum initFromMatrix(Matrix matrix) 240 { 241 auto __p = graphene_frustum_init_from_matrix(graphene_frustum, (matrix is null) ? null : matrix.getMatrixStruct()); 242 243 if(__p is null) 244 { 245 return null; 246 } 247 248 return ObjectG.getDObject!(Frustum)(cast(graphene_frustum_t*) __p); 249 } 250 251 /** 252 * Checks whether the given @box intersects a plane of 253 * a #graphene_frustum_t. 254 * 255 * Params: 256 * box = a #graphene_box_t 257 * 258 * Returns: `true` if the box intersects the frustum 259 * 260 * Since: 1.2 261 */ 262 public bool intersectsBox(Box box) 263 { 264 return graphene_frustum_intersects_box(graphene_frustum, (box is null) ? null : box.getBoxStruct()) != 0; 265 } 266 267 /** 268 * Checks whether the given @sphere intersects a plane of 269 * a #graphene_frustum_t. 270 * 271 * Params: 272 * sphere = a #graphene_sphere_t 273 * 274 * Returns: `true` if the sphere intersects the frustum 275 * 276 * Since: 1.2 277 */ 278 public bool intersectsSphere(Sphere sphere) 279 { 280 return graphene_frustum_intersects_sphere(graphene_frustum, (sphere is null) ? null : sphere.getSphereStruct()) != 0; 281 } 282 }