| 1 | /* |
| 2 | * |
| 3 | * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Lesser General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2.1 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library 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 GNU |
| 13 | * Lesser General Public License for more details. |
| 14 | * |
| 15 | * Further, this software is distributed without any warranty that it is |
| 16 | * free of the rightful claim of any third person regarding infringement |
| 17 | * or the like. Any license provided herein, whether implied or |
| 18 | * otherwise, applies only to this software file. Patent licenses, if |
| 19 | * any, provided herein do not apply to combinations of this program with |
| 20 | * other software, or any other product whatsoever. |
| 21 | * |
| 22 | * You should have received a copy of the GNU Lesser General Public |
| 23 | * License along with this library; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 | * |
| 26 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 | * Mountain View, CA 94043, or: |
| 28 | * |
| 29 | * http://www.sgi.com |
| 30 | * |
| 31 | * For further information regarding this notice, see: |
| 32 | * |
| 33 | * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | /* |
| 38 | _______________________________________________________________________ |
| 39 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 40 | | |
| 41 | | $Revision: 1.1.1.1 $ |
| 42 | | |
| 43 | | Classes : TsField::buildBlock |
| 44 | | |
| 45 | | Author : Dave Immel |
| 46 | | |
| 47 | ______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 48 | _______________________________________________________________________ |
| 49 | */ |
| 50 | |
| 51 | //--------------------------- Include ---------------------------------- |
| 52 | #include <X11/Intrinsic.h> |
| 53 | #include <Xm/Xm.h> |
| 54 | |
| 55 | #include <Inventor/nodes/SoSeparator.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSeparator.h`/ |
| 56 | #include <Inventor/nodes/SoCoordinate3.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoCoordinate3.h`/ |
| 57 | #include <Inventor/nodes/SoIndexedFaceSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedFaceSet.h`/ |
| 58 | #include <Inventor/nodes/SoNormal.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormal.h`/ |
| 59 | #include "TsField.h"cxx . . $ `<file>/apps/demos/drop/TsField.h`/ |
| 60 | |
| 61 | |
| 62 | //////////////////////////////////////////////////////////////////////// |
| 63 | // |
| 64 | // Description: |
| 65 | // Initialize the Inventor data representing the block. The block |
| 66 | // is the basic unit from which all of the pieces are built. It |
| 67 | // is instanced for all pieces and the field. The block is centered at |
| 68 | // (1, 1, -1) and as length of 2. |
| 69 | // |
| 70 | // Use: private |
| 71 | |
| 72 | void |
| 73 | TsFieldcxx . . $ TsField#::buildBlockcxx . . $ TsField#buildBlock(49f6e7a06ebc5aa8).() |
| 74 | |
| 75 | // |
| 76 | //////////////////////////////////////////////////////////////////////// |
| 77 | { |
| 78 | SoCoordinate3cxx . . $ SoCoordinate3# *coords; |
| 79 | SoIndexedFaceSetcxx . . $ SoIndexedFaceSet# *faces; |
| 80 | SoNormalcxx . . $ SoNormal# *normals; |
| 81 | SbVec3fcxx . . $ SbVec3f# *verts, tcoordcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).; |
| 82 | int32_t *indices, *ind; |
| 83 | int i; |
| 84 | |
| 85 | blockcxx . . $ TsField#block. = new SoSeparatorcxx . . $ SoSeparator#SoSeparator(49f6e7a06ebc5aa8).(); |
| 86 | blockcxx . . $ TsField#block.->renderCachingcxx . . $ SoSeparator#renderCaching. =cxx . . $ SoSFEnum#`operator=`(7864480464b09eea). SoSeparatorcxx . . $ SoSeparator#::ONcxx . . $ SoSeparator#ON.; |
| 87 | blockcxx . . $ TsField#block.->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 88 | |
| 89 | verts = new SbVec3fcxx . . $ SbVec3f#SbVec3f(49f6e7a06ebc5aa8).[24]; |
| 90 | // Front |
| 91 | verts[0].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 0.1, 0.0); |
| 92 | verts[1].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 0.1, 0.0); |
| 93 | verts[2].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 1.9, 0.0); |
| 94 | verts[3].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 1.9, 0.0); |
| 95 | // Right |
| 96 | verts[4].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 2.0, 0.1, -0.1); |
| 97 | verts[5].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 2.0, 0.1, -1.9); |
| 98 | verts[6].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 2.0, 1.9, -1.9); |
| 99 | verts[7].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 2.0, 1.9, -0.1); |
| 100 | // Back |
| 101 | verts[8].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 0.1, -2.0); |
| 102 | verts[9].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 0.1, -2.0); |
| 103 | verts[10].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 1.9, -2.0); |
| 104 | verts[11].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 1.9, -2.0); |
| 105 | // Left |
| 106 | verts[12].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.0, 0.1, -1.9); |
| 107 | verts[13].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.0, 0.1, -0.1); |
| 108 | verts[14].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.0, 1.9, -0.1); |
| 109 | verts[15].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.0, 1.9, -1.9); |
| 110 | // Bottom |
| 111 | verts[16].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 0.0, -1.9); |
| 112 | verts[17].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 0.0, -1.9); |
| 113 | verts[18].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 0.0, -0.1); |
| 114 | verts[19].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 0.0, -0.1); |
| 115 | // Top |
| 116 | verts[20].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 2.0, -0.1); |
| 117 | verts[21].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 2.0, -0.1); |
| 118 | verts[22].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 1.9, 2.0, -1.9); |
| 119 | verts[23].setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). ( 0.1, 2.0, -1.9); |
| 120 | coords = new SoCoordinate3cxx . . $ SoCoordinate3#(); |
| 121 | coords->pointcxx . . $ SoCoordinate3#point..setValuescxx . . $ SoMFVec3f#setValues(5f546bd7717b455b). (0, 24, verts); |
| 122 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (0.0, 0.0, 1.0); |
| 123 | verts[0] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 124 | verts[1] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 125 | verts[2] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 126 | verts[3] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 127 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (1.0, 0.0, 0.0); |
| 128 | verts[4] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 129 | verts[5] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 130 | verts[6] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 131 | verts[7] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 132 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (0.0, 0.0, -1.0); |
| 133 | verts[8] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 134 | verts[9] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 135 | verts[10] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 136 | verts[11] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 137 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (-1.0, 0.0, 0.0); |
| 138 | verts[12] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 139 | verts[13] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 140 | verts[14] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 141 | verts[15] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 142 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (0.0, -1.0, 0.0); |
| 143 | verts[16] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 144 | verts[17] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 145 | verts[18] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 146 | verts[19] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 147 | tcoord.setValuecxx . . $ SbVec3f#setValue(4e87f9d875f2d08d). (0.0, 1.0, 0.0); |
| 148 | verts[20] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 149 | verts[21] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 150 | verts[22] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 151 | verts[23] =cxx . . $ SbVec3f#`operator=`(c7808628d070cfbe). tcoord; |
| 152 | normals = new SoNormalcxx . . $ SoNormal#(); |
| 153 | normals->vectorcxx . . $ SoNormal#vector..setValuescxx . . $ SoMFVec3f#setValues(5f546bd7717b455b). (0, 24, verts); |
| 154 | delete[] verts; |
| 155 | |
| 156 | indices = new int32_t[30+60+32]; |
| 157 | ind = indices; |
| 158 | for (i=0; i<6; i++) |
| 159 | { |
| 160 | *ind++ = i*4; |
| 161 | *ind++ = i*4+1; |
| 162 | *ind++ = i*4+2; |
| 163 | *ind++ = i*4+3; |
| 164 | *ind++ = -1; |
| 165 | } |
| 166 | *ind++ = 13; *ind++ = 12; *ind++ = 16; *ind++ = 19; *ind++ = -1; |
| 167 | *ind++ = 18; *ind++ = 17; *ind++ = 5; *ind++ = 4; *ind++ = -1; |
| 168 | *ind++ = 7; *ind++ = 6; *ind++ = 22; *ind++ = 21; *ind++ = -1; |
| 169 | *ind++ = 15; *ind++ = 14; *ind++ = 20; *ind++ = 23; *ind++ = -1; |
| 170 | *ind++ = 19; *ind++ = 18; *ind++ = 1; *ind++ = 0; *ind++ = -1; |
| 171 | *ind++ = 4; *ind++ = 7; *ind++ = 2; *ind++ = 1; *ind++ = -1; |
| 172 | *ind++ = 3; *ind++ = 2; *ind++ = 21; *ind++ = 20; *ind++ = -1; |
| 173 | *ind++ = 0; *ind++ = 3; *ind++ = 14; *ind++ = 13; *ind++ = -1; |
| 174 | *ind++ = 17; *ind++ = 16; *ind++ = 9; *ind++ = 8; *ind++ = -1; |
| 175 | *ind++ = 6; *ind++ = 5; *ind++ = 8; *ind++ = 11; *ind++ = -1; |
| 176 | *ind++ = 11; *ind++ = 10; *ind++ = 23; *ind++ = 22; *ind++ = -1; |
| 177 | *ind++ = 10; *ind++ = 9; *ind++ = 12; *ind++ = 15; *ind++ = -1; |
| 178 | |
| 179 | *ind++ = 0; *ind++ = 13; *ind++ = 19; *ind++ = -1; |
| 180 | *ind++ = 1; *ind++ = 18; *ind++ = 4; *ind++ = -1; |
| 181 | *ind++ = 2; *ind++ = 7; *ind++ = 21; *ind++ = -1; |
| 182 | *ind++ = 3; *ind++ = 20; *ind++ = 14; *ind++ = -1; |
| 183 | *ind++ = 9; *ind++ = 16; *ind++ = 12; *ind++ = -1; |
| 184 | *ind++ = 8; *ind++ = 5; *ind++ = 17; *ind++ = -1; |
| 185 | *ind++ = 11; *ind++ = 22; *ind++ = 6; *ind++ = -1; |
| 186 | *ind++ = 10; *ind++ = 15; *ind++ = 23; *ind++ = -1; |
| 187 | |
| 188 | faces = new SoIndexedFaceSetcxx . . $ SoIndexedFaceSet#(); |
| 189 | faces->coordIndexcxx . . $ SoIndexedShape#coordIndex..setValuescxx . . $ SoMFInt32#setValues(4ba7fc99d2e6f458). (0, 30+60+32, indices); |
| 190 | delete[] indices; |
| 191 | |
| 192 | blockcxx . . $ TsField#block.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd). (coords); |
| 193 | blockcxx . . $ TsField#block.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd). (normals); |
| 194 | blockcxx . . $ TsField#block.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd). (faces); |
| 195 | } |
| 196 | |
| 197 | |
| 198 | |
| 199 |