MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawFireballObject

Function DrawFireballObject

Descent3/fireball.cpp:720–826  ·  view source on GitHub ↗

Given an object, renders the representation of this fireball

Source from the content-addressed store, hash-verified

718
719// Given an object, renders the representation of this fireball
720void DrawFireballObject(object *obj) {
721 ASSERT(obj->type == OBJ_FIREBALL);
722
723 // First check to see if these are special types
724 if (obj->id == BLAST_RING_INDEX) {
725 DrawBlastRingObject(obj);
726 return;
727 }
728 if (obj->id == GRAVITY_FIELD_INDEX) {
729 // Draw two blast rings
730 matrix tempm;
731 vm_MakeIdentity(&tempm);
732 ObjSetOrient(obj, &tempm);
733 DrawBlastRingObject(obj);
734 return;
735 }
736 if (obj->id == SMOLDERING_INDEX) {
737 DrawSmolderingObject(obj);
738 return;
739 }
740 float norm_time;
741 float time_live = Gametime - obj->creation_time;
742 float size = obj->size;
743
744 int objnum = obj - Objects;
745 int rot_angle;
746 int bm_handle;
747 if (Fireballs[obj->id].type == FT_BILLOW)
748 rot_angle = ((objnum * 5000) + (FrameCount * 160)) % 65536;
749 else
750 rot_angle = ((objnum * 5000) + (FrameCount * 30)) % 65536;
751
752 norm_time = time_live / obj->lifetime;
753 if (norm_time >= 1)
754 norm_time = .99999f; // don't go over!
755 if (obj->id == SMOKE_TRAIL_INDEX) // If its a smoke trail, get image from texture
756 {
757 int texnum = obj->ctype.blast_info.bm_handle;
758 if (GameTextures[texnum].flags & TF_ANIMATED) {
759 PageInVClip(GameTextures[texnum].bm_handle);
760 vclip *vc = &GameVClips[GameTextures[texnum].bm_handle];
761 int int_frame = vc->num_frames * norm_time;
762 bm_handle = vc->frames[int_frame];
763 } else
764 bm_handle = GameTextures[texnum].bm_handle;
765 } else if (obj->id == CUSTOM_EXPLOSION_INDEX) // Do custom
766 {
767 bm_handle = GetTextureBitmap(obj->ctype.blast_info.bm_handle, 0);
768 if (!(GameTextures[obj->ctype.blast_info.bm_handle].flags & TF_ANIMATED)) {
769 // If this is just a single bitmap, scale it based on time
770 if (norm_time < .5) // Ramp up quickly
771 {
772 float temp_norm = norm_time / .2;
773 temp_norm = std::min(1.0f, temp_norm);
774 size *= temp_norm;
775 } else // ramp down slowly
776 {
777 float temp_norm = ((norm_time - .5) / .5);

Callers 1

RenderObjectFunction · 0.85

Calls 15

DrawBlastRingObjectFunction · 0.85
ObjSetOrientFunction · 0.85
DrawSmolderingObjectFunction · 0.85
PageInVClipFunction · 0.85
GetTextureBitmapFunction · 0.85
g3_DrawRotatedBitmapFunction · 0.85
bm_hFunction · 0.85
bm_wFunction · 0.85
vm_MakeIdentityFunction · 0.50
rend_SetAlphaTypeFunction · 0.50
rend_SetAlphaValueFunction · 0.50
rend_SetOverlayTypeFunction · 0.50

Tested by

no test coverage detected