Divide-Framework
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
Divide-Framework / trunk / Source Code / Geometry / Shapes / Headers / Predefined / Box3D.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
/* Copyright (c) 2013 DIVIDE-Studio Copyright (c) 2009 Ionut Cava This file is part of DIVIDE Framework. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef _BOX_3D_H_ #define _BOX_3D_H_ #include "Geometry/Shapes/Headers/Object3D.h" #include "Hardware/Video/Buffers/VertexBufferObject/Headers/VertexBufferObject.h" class Box3D : public Object3D { public: Box3D(F32 size) : Object3D(BOX_3D,TRIANGLE_STRIP), _size(size){ vec3<F32> vertices[] = {vec3<F32>(-1.0, -1.0, 1.0), vec3<F32>( 1.0, -1.0, 1.0), vec3<F32>(-1.0, 1.0, 1.0), vec3<F32>( 1.0, 1.0, 1.0), vec3<F32>(-1.0, -1.0, -1.0), vec3<F32>( 1.0, -1.0, -1.0), vec3<F32>(-1.0, 1.0, -1.0), vec3<F32>( 1.0, 1.0, -1.0)}; vec3<F32> normals[] = {vec3<F32>(-1, -1, 1), vec3<F32>( 1, -1, 1), vec3<F32>(-1, 1, 1), vec3<F32>( 1, 1, 1), vec3<F32>(-1, -1, -1), vec3<F32>( 1, -1, -1), vec3<F32>(-1, 1, -1), vec3<F32>( 1, 1, -1)}; U16 indices[] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1}; _geometry->reservePositionCount(8); _geometry->reserveNormalCount(8); _geometry->setIndiceLimits(vec2<U32>(0,7)); F32 halfExtent = size*0.5f; for(U8 i = 0; i < 8; i++){ _geometry->addPosition(vertices[i] * halfExtent); _geometry->addNormal(normals[i]); } for(U8 i = 0; i < 14; i++){ _geometry->addIndex(indices[i]); } _geometry->queueRefresh(); } inline F32 getSize() {return _size;} inline void setSize(F32 size) { ///Since the initial box is half of the full extent already (in the constructor) ///Each vertex is already multiplied by 0.5 so, just multiply by the new size ///IMPORTANT!! -be aware of this - Ionut F32 halfExtent = size; for(U8 i = 0; i < 8; i++){ _geometry->modifyPositionValue(i,_geometry->getPosition()[i] * halfExtent); } _geometry->queueRefresh(); _size = size; } virtual bool computeBoundingBox(SceneGraphNode* const sgn){ if(sgn->getBoundingBox().isComputed()) return true; sgn->getBoundingBox().set(vec3<F32>(-_size),vec3<F32>(_size)); sgn->getBoundingBox().Multiply(0.5f); return SceneNode::computeBoundingBox(sgn); } private: F32 _size; }; #endif |
Commits for Divide-Framework/trunk/Source Code/Geometry/Shapes/Headers/Predefined/Box3D.h
Revision | Author | Commited | Message |
---|---|---|---|
168 Diff | k1ngp1n | Sat 26 Oct, 2013 19:03:21 +0000 | - Reworked the Camera class[[BR]] |
160 Diff | k1ngp1n | Wed 10 Jul, 2013 17:07:04 +0000 | [Ionut] [[BR]] |
152 Diff | k1ngp1n | Thu 20 Jun, 2013 14:23:31 +0000 | [Ionut] [[BR]] |
151 Diff | k1ngp1n | Tue 07 May, 2013 00:00:52 +0000 | [Ionut] [[BR]] |
146 Diff | k1ngp1n | Wed 10 Apr, 2013 13:20:15 +0000 | [Ionut] [[BR]] |
141 Diff | k1ngp1n | Wed 30 Jan, 2013 19:35:31 +0000 | [Ionut] [[BR]] |
116 Diff | k1ngp1n | Mon 04 Jun, 2012 22:27:07 +0000 | [Ionut] [[BR]] |
113 Diff | k1ngp1n | Fri 01 Jun, 2012 16:51:23 +0000 | [Ionut] [[BR]] |
111 Diff | k1ngp1n | Tue 08 May, 2012 21:49:31 +0000 | [Ionut] [[BR]] |
106 | k1ngp1n | Wed 28 Mar, 2012 21:50:23 +0000 | [Ionut] [[BR]] |