Sets up the light states for an indoor object to be rendered
| 1104 | } |
| 1105 | // Sets up the light states for an indoor object to be rendered |
| 1106 | bool SetupMineObject(object *objp) { |
| 1107 | if (objp->lighting_render_type == LRT_STATIC || Poly_models[objp->rtype.pobj_info.model_num].new_style == 0) { |
| 1108 | RenderObject_SetStatic(1.0f, 1.0f, 1.0f); |
| 1109 | } else if (objp->lighting_render_type == LRT_GOURAUD || NoLightmaps) { |
| 1110 | float scalar_r = 1.0, scalar_g = 1.0, scalar_b = 1.0; |
| 1111 | |
| 1112 | vector lightdir = {0, -1.0, 0}; // straight down for now |
| 1113 | |
| 1114 | // Get the volume light for this object |
| 1115 | if (objp->effect_info && (objp->effect_info->type_flags & EF_VOLUME_LIT) && |
| 1116 | !(Rooms[objp->roomnum].flags & RF_EXTERNAL)) { |
| 1117 | vector vpos = objp->pos; |
| 1118 | if (Render_mirror_for_room) |
| 1119 | vpos = objp->last_pos; |
| 1120 | if (objp->effect_info->type_flags & EF_VOLUME_CHANGING) { |
| 1121 | float old_r, old_g, old_b; |
| 1122 | float new_r, new_g, new_b; |
| 1123 | GetRoomDynamicScalar(&objp->effect_info->volume_old_pos, &Rooms[objp->effect_info->volume_old_room], &old_r, |
| 1124 | &old_g, &old_b); |
| 1125 | GetRoomDynamicScalar(&vpos, &Rooms[objp->roomnum], &new_r, &new_g, &new_b); |
| 1126 | scalar_r = |
| 1127 | (old_r * objp->effect_info->volume_change_time) + ((1 - objp->effect_info->volume_change_time) * new_r); |
| 1128 | scalar_g = |
| 1129 | (old_g * objp->effect_info->volume_change_time) + ((1 - objp->effect_info->volume_change_time) * new_g); |
| 1130 | scalar_b = |
| 1131 | (old_b * objp->effect_info->volume_change_time) + ((1 - objp->effect_info->volume_change_time) * new_b); |
| 1132 | } else |
| 1133 | GetRoomDynamicScalar(&vpos, &Rooms[objp->roomnum], &scalar_r, &scalar_g, &scalar_b); |
| 1134 | |
| 1135 | scalar_r = std::min<float>(1, scalar_r + (objp->effect_info->dynamic_red)); |
| 1136 | scalar_g = std::min<float>(1, scalar_g + (objp->effect_info->dynamic_green)); |
| 1137 | scalar_b = std::min<float>(1, scalar_b + (objp->effect_info->dynamic_blue)); |
| 1138 | // If this is a robot, make it at least 10% for each RGB component |
| 1139 | if (objp->type == OBJ_ROBOT) { |
| 1140 | scalar_r = std::max<float>(.1, scalar_r); |
| 1141 | scalar_g = std::max<float>(.1, scalar_g); |
| 1142 | scalar_b = std::max<float>(.1, scalar_b); |
| 1143 | } |
| 1144 | |
| 1145 | if (objp->type == OBJ_PLAYER && (Game_mode & GM_MULTI)) { |
| 1146 | if (Netgame.flags & NF_BRIGHT_PLAYERS) { |
| 1147 | scalar_r = 1; |
| 1148 | scalar_g = 1; |
| 1149 | scalar_b = 1; |
| 1150 | } else { |
| 1151 | // Make this ship brighter based on its speed |
| 1152 | float speed_norm; |
| 1153 | speed_norm = std::min<float>(vm_GetMagnitudeFast(&objp->mtype.phys_info.velocity) / 20.0, 1); |
| 1154 | speed_norm *= 1; |
| 1155 | speed_norm += 1; |
| 1156 | scalar_r = std::min<float>(1, scalar_r * speed_norm); |
| 1157 | scalar_g = std::min<float>(1, scalar_g * speed_norm); |
| 1158 | scalar_b = std::min<float>(1, scalar_b * speed_norm); |
| 1159 | } |
| 1160 | } |
| 1161 | if (objp->type == OBJ_PLAYER && (Players[objp->id].flags & PLAYER_FLAGS_HEADLIGHT)) { |
| 1162 | scalar_r = 1; |
| 1163 | scalar_g = 1; |
no test coverage detected