static inline void DrawFeatureColVol(const CFeature* f) { const CollisionVolume* v = f->collisionVolume; if (!f->IsInLosForAllyTeam(gu->myAllyTeam) && !gu->spectatingFullView) return; if (!camera->InView(f->pos, f->drawRadius)) return; const bool vCustomType = (v->GetVolumeType() < CollisionVolume::COLVOL_TYPE_SPHERE); const bool vCustomDims = ((v->GetOffsets()).SqLength() >= 1.0f || math::fabs(v->GetBoundingRadius() - f->radius) >= 1.0f); glPushMatrix(); glMultMatrixf(f->GetTransformMatrixRef()); DrawObjectMidAndAimPos(f); if (!v->IgnoreHits()) { DrawCollisionVolume(v); } if (vCustomType || vCustomDims) { // assume this is a custom volume glColor3f(0.5f, 0.5f, 0.5f); glScalef(f->radius, f->radius, f->radius); glWireSphere(&volumeDisplayListIDs[0], 20, 20); } glPopMatrix(); }
static void DrawUnitDebugPieceTree(const LocalModelPiece* p, const LocalModelPiece* lap, int lapf, CMatrix44f mat) { mat.Translate(p->pos.x, p->pos.y, p->pos.z); mat.RotateY(-p->rot[1]); mat.RotateX(-p->rot[0]); mat.RotateZ(-p->rot[2]); glPushMatrix(); glMultMatrixf(mat.m); if (p->visible && !p->GetCollisionVolume()->IsDisabled()) { if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColor3f((1.0f - ((gs->frameNum - lapf) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(p->GetCollisionVolume()); if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColorf3(defaultColVolColor); } } glPopMatrix(); for (unsigned int i = 0; i < p->childs.size(); i++) { DrawUnitDebugPieceTree(p->childs[i], lap, lapf, mat); } }
static void DrawUnitDebugPieceTree(const LocalModelPiece* p, const LocalModelPiece* lap, int lapf, CMatrix44f mat) { const float3& rot = p->GetRotation(); mat.Translate(p->GetPosition()); mat.RotateY(-rot[1]); mat.RotateX(-rot[0]); mat.RotateZ(-rot[2]); glPushMatrix(); glMultMatrixf(mat.m); if (p->scriptSetVisible && !p->GetCollisionVolume()->IgnoreHits()) { if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColor3f((1.0f - ((gs->frameNum - lapf) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(p->GetCollisionVolume()); if ((p == lap) && (lapf > 0 && ((gs->frameNum - lapf) < 150))) { glColorf3(DEFAULT_VOLUME_COLOR); } } glPopMatrix(); for (unsigned int i = 0; i < p->children.size(); i++) { DrawUnitDebugPieceTree(p->children[i], lap, lapf, mat); } }
static inline void DrawFeatureColVol(const CFeature* f) { if (f->collisionVolume && !f->collisionVolume->IsDisabled()) { if (!f->IsInLosForAllyTeam(gu->myAllyTeam) && !gu->spectatingFullView) return; if (!camera->InView(f->pos, f->drawRadius)) return; glPushMatrix(); glMultMatrixf(f->transMatrix.m); glTranslatef3(f->relMidPos * float3(-1.0f, 1.0f, 1.0f)); GLUquadricObj* q = gluNewQuadric(); // draw the centerpos glColor3f(1.0f, 0.0f, 1.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glColorf3(defaultColVolColor); gluQuadricDrawStyle(q, GLU_LINE); DrawCollisionVolume(f->collisionVolume, q); gluDeleteQuadric(q); glPopMatrix(); } }
static void DrawObjectDebugPieces(const CSolidObject* o) { const int hitDeltaTime = (gs->frameNum - o->lastHitPieceFrame); for (unsigned int n = 0; n < o->localModel.pieces.size(); n++) { const LocalModelPiece* lmp = o->localModel.GetPiece(n); const CollisionVolume* lmpVol = lmp->GetCollisionVolume(); const bool b0 = ((o->lastHitPieceFrame > 0) && (hitDeltaTime < 150)); const bool b1 = (lmp == o->lastHitPiece); if (!lmp->scriptSetVisible || lmpVol->IgnoreHits()) continue; if (b0 && b1) { glColor3f((1.0f - (hitDeltaTime / 150.0f)), 0.0f, 0.0f); } glPushMatrix(); glMultMatrixf(lmp->GetModelSpaceMatrix()); // factors in the volume offsets DrawCollisionVolume(lmpVol); glPopMatrix(); if (b0 && b1) { glColorf4(DEFAULT_VOLUME_COLOR); } } }
static inline void DrawUnitColVol(const CUnit* u) { if (!(u->losStatus[gu->myAllyTeam] & LOS_INLOS) && !gu->spectatingFullView) return; if (!camera->InView(u->drawMidPos, u->drawRadius)) return; const CollisionVolume* v = u->collisionVolume; const bool vCustomType = (v->GetVolumeType() < CollisionVolume::COLVOL_TYPE_SPHERE); const bool vCustomDims = ((v->GetOffsets()).SqLength() >= 1.0f || math::fabs(v->GetBoundingRadius() - u->radius) >= 1.0f); glPushMatrix(); glMultMatrixf(u->GetTransformMatrix()); DrawObjectMidAndAimPos(u); if (v->DefaultToPieceTree()) { // draw only the piece volumes for less clutter CMatrix44f mat(u->relMidPos * float3(0.0f, -1.0f, 0.0f)); DrawUnitDebugPieceTree(u->localModel->GetRoot(), u->lastAttackedPiece, u->lastAttackedPieceFrame, mat); } else { if (!v->IgnoreHits()) { // make it fade red under attack if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColor3f((1.0f - ((gs->frameNum - u->lastAttackFrame) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(v); if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColorf3(DEFAULT_VOLUME_COLOR); } } } if (vCustomType || vCustomDims) { // assume this is a custom volume glColor3f(0.5f, 0.5f, 0.5f); glScalef(u->radius, u->radius, u->radius); glWireSphere(&volumeDisplayListIDs[0], 20, 20); } glPopMatrix(); }
static inline void DrawUnitColVol(const CUnit* unit) { if (!(unit->losStatus[gu->myAllyTeam] & LOS_INLOS) && !gu->spectatingFullView) return; if (!camera->InView(unit->drawMidPos, unit->drawRadius)) return; glPushMatrix(); glMultMatrixf(unit->GetTransformMatrix()); glTranslatef3(unit->relMidPos * float3(-1.0f, 1.0f, 1.0f)); GLUquadricObj* q = gluNewQuadric(); // draw the aimpoint glColor3f(1.0f, 0.0f, 1.0f); gluQuadricDrawStyle(q, GLU_FILL); gluSphere(q, 2.0f, 5, 5); glColorf3(defaultColVolColor); gluQuadricDrawStyle(q, GLU_LINE); if (unit->unitDef->usePieceCollisionVolumes) { //! draw only the piece volumes for less clutter CMatrix44f mat(unit->relMidPos * float3(0.0f, -1.0f, 0.0f)); DrawUnitDebugPieceTree(unit->localmodel->GetRoot(), unit->lastAttackedPiece, unit->lastAttackedPieceFrame, mat, q); } else { if (!unit->collisionVolume->IsDisabled()) { //! make it fade red under attack if (unit->lastAttack > 0 && ((gs->frameNum - unit->lastAttack) < 150)) { glColor3f((1.0f - ((gs->frameNum - unit->lastAttack) / 150.0f)), 0.0f, 0.0f); } DrawCollisionVolume(unit->collisionVolume, q); if (unit->lastAttack > 0 && ((gs->frameNum - unit->lastAttack) < 150)) { glColorf3(defaultColVolColor); } } } gluDeleteQuadric(q); glPopMatrix(); }
static inline void DrawFeatureColVol(const CFeature* f) { const CollisionVolume* v = &f->collisionVolume; if (f->IsInVoid()) return; if (!f->IsInLosForAllyTeam(gu->myAllyTeam) && !gu->spectatingFullView) return; if (!camera->InView(f->pos, f->GetDrawRadius())) return; const bool vCustomType = (v->GetVolumeType() < CollisionVolume::COLVOL_TYPE_SPHERE); const bool vCustomDims = ((v->GetOffsets()).SqLength() >= 1.0f || math::fabs(v->GetBoundingRadius() - f->radius) >= 1.0f); glPushMatrix(); glMultMatrixf(f->GetTransformMatrixRef()); DrawObjectMidAndAimPos(f); if (v->DefaultToPieceTree()) { // draw only the piece volumes for less clutter // note: relMidPos transform is on the stack at this // point but all piece-positions are relative to pos // --> undo it glTranslatef3(-f->relMidPos * WORLD_TO_OBJECT_SPACE); DrawObjectDebugPieces(f); glTranslatef3(f->relMidPos * WORLD_TO_OBJECT_SPACE); } else { if (!v->IgnoreHits()) { DrawCollisionVolume(v); } } if (vCustomType || vCustomDims) { // assume this is a custom volume glColor4f(0.5f, 0.5f, 0.5f, 0.35f); glScalef(f->radius, f->radius, f->radius); glWireSphere(&volumeDisplayListIDs[0], 20, 20); } glPopMatrix(); }
static inline void DrawUnitColVol(const CUnit* u) { if (u->IsInVoid()) return; if (!(u->losStatus[gu->myAllyTeam] & LOS_INLOS) && !gu->spectatingFullView) return; if (!camera->InView(u->drawMidPos, u->GetDrawRadius())) return; const CollisionVolume* v = &u->collisionVolume; const bool vCustomType = (v->GetVolumeType() < CollisionVolume::COLVOL_TYPE_SPHERE); const bool vCustomDims = ((v->GetOffsets()).SqLength() >= 1.0f || math::fabs(v->GetBoundingRadius() - u->radius) >= 1.0f); GLUquadricObj* q = gluNewQuadric(); gluQuadricDrawStyle(q, GLU_FILL); glDisable(GL_DEPTH_TEST); for (const CWeapon* w: u->weapons) { glPushMatrix(); glTranslatef3(w->aimFromPos); glColor4f(1.0f, 1.0f, 0.0f, 0.4f); gluSphere(q, 1.0f, 5, 5); glPopMatrix(); glPushMatrix(); glTranslatef3(w->weaponMuzzlePos); if (w->HaveTarget()) { glColor4f(1.0f, 0.8f, 0.0f, 0.4f); } else { glColor4f(1.0f, 0.0f, 0.0f, 0.4f); } gluSphere(q, 1.0f, 5, 5); glPopMatrix(); if (w->HaveTarget()) { glPushMatrix(); glTranslatef3(w->GetCurrentTargetPos()); glColor4f(1.0f, 0.8f, 0.0f, 0.4f); gluSphere(q, 1.0f, 5, 5); glPopMatrix(); } } glColorf4(DEFAULT_VOLUME_COLOR); glEnable(GL_DEPTH_TEST); gluDeleteQuadric(q); glPushMatrix(); glMultMatrixf(u->GetTransformMatrix()); DrawObjectMidAndAimPos(u); if (v->DefaultToPieceTree()) { // draw only the piece volumes for less clutter // note: relMidPos transform is on the stack at this // point but all piece-positions are relative to pos // --> undo it glTranslatef3(-u->relMidPos * WORLD_TO_OBJECT_SPACE); DrawObjectDebugPieces(u); glTranslatef3(u->relMidPos * WORLD_TO_OBJECT_SPACE); } else { if (!v->IgnoreHits()) { // make it fade red under attack if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColor3f((1.0f - ((gs->frameNum - u->lastAttackFrame) / 150.0f)), 0.0f, 0.0f); } // if drawing this, disable the DrawObjectMidAndAimPos call // DrawCollisionVolume((u->localModel).GetBoundingVolume()); DrawCollisionVolume(v); if (u->lastAttackFrame > 0 && ((gs->frameNum - u->lastAttackFrame) < 150)) { glColorf4(DEFAULT_VOLUME_COLOR); } } } if (u->shieldWeapon != nullptr) { const CPlasmaRepulser* shield = static_cast<const CPlasmaRepulser*>(u->shieldWeapon); glColor4f(0.0f, 0.0f, 0.6f, 0.35f); DrawCollisionVolume(&shield->collisionVolume); } if (vCustomType || vCustomDims) { // assume this is a custom volume glColor4f(0.5f, 0.5f, 0.5f, 0.35f); glScalef(u->radius, u->radius, u->radius); glWireSphere(&volumeDisplayListIDs[0], 20, 20); } glPopMatrix(); }