- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/LinearMath/btIDebugDraw.h
r2907 r2908 30 30 31 31 #include "btVector3.h" 32 #include "btTransform.h"33 32 34 33 … … 54 53 DBG_DisableBulletLCP = 512, 55 54 DBG_EnableCCD = 1024, 56 DBG_DrawConstraints = (1 << 11),57 DBG_DrawConstraintLimits = (1 << 12),58 55 DBG_MAX_DEBUG_DRAW_MODE 59 56 }; 60 57 61 58 virtual ~btIDebugDraw() {}; 62 63 virtual void drawLine(const btVector3& from,const btVector3& to, const btVector3& fromColor, const btVector3& toColor)64 {65 drawLine (from, to, fromColor);66 }67 68 virtual void drawBox (const btVector3& boxMin, const btVector3& boxMax, const btVector3& color, btScalar alpha)69 {70 }71 72 virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color)73 {74 }75 59 76 60 virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0; … … 126 110 } 127 111 } 128 void drawTransform(const btTransform& transform, btScalar orthoLen)129 {130 btVector3 start = transform.getOrigin();131 drawLine(start, start+transform.getBasis() * btVector3(orthoLen, 0, 0), btVector3(0.7f,0,0));132 drawLine(start, start+transform.getBasis() * btVector3(0, orthoLen, 0), btVector3(0,0.7f,0));133 drawLine(start, start+transform.getBasis() * btVector3(0, 0, orthoLen), btVector3(0,0,0.7f));134 }135 136 void drawArc(const btVector3& center, const btVector3& normal, const btVector3& axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, btScalar maxAngle,137 const btVector3& color, bool drawSect, btScalar stepDegrees = btScalar(10.f))138 {139 const btVector3& vx = axis;140 btVector3 vy = normal.cross(axis);141 btScalar step = stepDegrees * SIMD_RADS_PER_DEG;142 int nSteps = (int)((maxAngle - minAngle) / step);143 if(!nSteps) nSteps = 1;144 btVector3 prev = center + radiusA * vx * btCos(minAngle) + radiusB * vy * btSin(minAngle);145 if(drawSect)146 {147 drawLine(center, prev, color);148 }149 for(int i = 1; i <= nSteps; i++)150 {151 btScalar angle = minAngle + (maxAngle - minAngle) * btScalar(i) / btScalar(nSteps);152 btVector3 next = center + radiusA * vx * btCos(angle) + radiusB * vy * btSin(angle);153 drawLine(prev, next, color);154 prev = next;155 }156 if(drawSect)157 {158 drawLine(center, prev, color);159 }160 }161 void drawSpherePatch(const btVector3& center, const btVector3& up, const btVector3& axis, btScalar radius,162 btScalar minTh, btScalar maxTh, btScalar minPs, btScalar maxPs, const btVector3& color, btScalar stepDegrees = btScalar(10.f))163 {164 btVector3 vA[74];165 btVector3 vB[74];166 btVector3 *pvA = vA, *pvB = vB, *pT;167 btVector3 npole = center + up * radius;168 btVector3 spole = center - up * radius;169 btVector3 arcStart;170 btScalar step = stepDegrees * SIMD_RADS_PER_DEG;171 const btVector3& kv = up;172 const btVector3& iv = axis;173 btVector3 jv = kv.cross(iv);174 bool drawN = false;175 bool drawS = false;176 if(minTh <= -SIMD_HALF_PI)177 {178 minTh = -SIMD_HALF_PI + step;179 drawN = true;180 }181 if(maxTh >= SIMD_HALF_PI)182 {183 maxTh = SIMD_HALF_PI - step;184 drawS = true;185 }186 if(minTh > maxTh)187 {188 minTh = -SIMD_HALF_PI + step;189 maxTh = SIMD_HALF_PI - step;190 drawN = drawS = true;191 }192 int n_hor = (int)((maxTh - minTh) / step) + 1;193 if(n_hor < 2) n_hor = 2;194 btScalar step_h = (maxTh - minTh) / btScalar(n_hor - 1);195 bool isClosed = false;196 if(minPs > maxPs)197 {198 minPs = -SIMD_PI + step;199 maxPs = SIMD_PI;200 isClosed = true;201 }202 else if((maxPs - minPs) >= SIMD_PI * btScalar(2.f))203 {204 isClosed = true;205 }206 else207 {208 isClosed = false;209 }210 int n_vert = (int)((maxPs - minPs) / step) + 1;211 if(n_vert < 2) n_vert = 2;212 btScalar step_v = (maxPs - minPs) / btScalar(n_vert - 1);213 for(int i = 0; i < n_hor; i++)214 {215 btScalar th = minTh + btScalar(i) * step_h;216 btScalar sth = radius * btSin(th);217 btScalar cth = radius * btCos(th);218 for(int j = 0; j < n_vert; j++)219 {220 btScalar psi = minPs + btScalar(j) * step_v;221 btScalar sps = btSin(psi);222 btScalar cps = btCos(psi);223 pvB[j] = center + cth * cps * iv + cth * sps * jv + sth * kv;224 if(i)225 {226 drawLine(pvA[j], pvB[j], color);227 }228 else if(drawS)229 {230 drawLine(spole, pvB[j], color);231 }232 if(j)233 {234 drawLine(pvB[j-1], pvB[j], color);235 }236 else237 {238 arcStart = pvB[j];239 }240 if((i == (n_hor - 1)) && drawN)241 {242 drawLine(npole, pvB[j], color);243 }244 if(isClosed)245 {246 if(j == (n_vert-1))247 {248 drawLine(arcStart, pvB[j], color);249 }250 }251 else252 {253 if(((!i) || (i == (n_hor-1))) && ((!j) || (j == (n_vert-1))))254 {255 drawLine(center, pvB[j], color);256 }257 }258 }259 pT = pvA; pvA = pvB; pvB = pT;260 }261 }262 263 void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color)264 {265 drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMin[1], bbMin[2]), color);266 drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMax[1], bbMin[2]), color);267 drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMax[1], bbMin[2]), color);268 drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMin[1], bbMin[2]), color);269 drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3(bbMin[0], bbMin[1], bbMax[2]), color);270 drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3(bbMax[0], bbMin[1], bbMax[2]), color);271 drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3(bbMax[0], bbMax[1], bbMax[2]), color);272 drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3(bbMin[0], bbMax[1], bbMax[2]), color);273 drawLine(btVector3(bbMin[0], bbMin[1], bbMax[2]), btVector3(bbMax[0], bbMin[1], bbMax[2]), color);274 drawLine(btVector3(bbMax[0], bbMin[1], bbMax[2]), btVector3(bbMax[0], bbMax[1], bbMax[2]), color);275 drawLine(btVector3(bbMax[0], bbMax[1], bbMax[2]), btVector3(bbMin[0], bbMax[1], bbMax[2]), color);276 drawLine(btVector3(bbMin[0], bbMax[1], bbMax[2]), btVector3(bbMin[0], bbMin[1], bbMax[2]), color);277 }278 void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color)279 {280 drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), color);281 drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), color);282 drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), color);283 drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), color);284 drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color);285 drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color);286 drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color);287 drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color);288 drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color);289 drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color);290 drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color);291 drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color);292 }293 112 }; 294 113
Note: See TracChangeset
for help on using the changeset viewer.