Creates a volumetric cone of light that casts from the center of the current face
| 798 | |
| 799 | // Creates a volumetric cone of light that casts from the center of the current face |
| 800 | void CLightingDialog::OnCreateVolumeCone() { |
| 801 | int i, t; |
| 802 | |
| 803 | ASSERT(Curface < Curroomp->num_faces); |
| 804 | int resolution = m_resolution; |
| 805 | int first_vert_index, first_face_index, center_index; |
| 806 | |
| 807 | vector faceverts[MAX_VERTS_PER_FACE]; |
| 808 | vector center; |
| 809 | matrix face_matrix; |
| 810 | |
| 811 | vector fvec = Curroomp->faces[Curface].normal; |
| 812 | |
| 813 | float pitch_increment = 65536 / resolution; |
| 814 | float heading_increment = 65536 / resolution; |
| 815 | float desired_angle = m_angle; |
| 816 | float pitch, heading; |
| 817 | |
| 818 | // Fixup angle for our system |
| 819 | desired_angle = (desired_angle / 360.0) * 65536; |
| 820 | |
| 821 | // Get face matrix |
| 822 | vm_VectorToMatrix(&face_matrix, &fvec, NULL, NULL); |
| 823 | vm_TransposeMatrix(&face_matrix); |
| 824 | |
| 825 | // Get polygon center |
| 826 | face *fp = &Curroomp->faces[Curface]; |
| 827 | for (i = 0; i < fp->num_verts; i++) |
| 828 | faceverts[i] = Curroomp->verts[fp->face_verts[i]]; |
| 829 | vm_GetCentroid(¢er, faceverts, fp->num_verts); |
| 830 | |
| 831 | // Add vertices to room |
| 832 | center_index = Curroomp->num_verts; |
| 833 | RoomAddVertices(Curroomp, resolution + 1); |
| 834 | Curroomp->verts[center_index] = center; |
| 835 | first_vert_index = center_index + 1; |
| 836 | |
| 837 | for (i = 0; i < resolution; i++) { |
| 838 | vector dest_vec; |
| 839 | vector hit_vec; |
| 840 | |
| 841 | matrix tempm; |
| 842 | |
| 843 | // Get our direction |
| 844 | heading = FixCos(heading_increment * i); |
| 845 | pitch = FixSin(pitch_increment * i); |
| 846 | |
| 847 | vm_AnglesToMatrix(&tempm, pitch * desired_angle, heading * desired_angle, 0); |
| 848 | vm_MatrixMulVector(&dest_vec, &tempm.fvec, &face_matrix); |
| 849 | |
| 850 | dest_vec *= m_falloff; |
| 851 | dest_vec += center; |
| 852 | |
| 853 | // Now shoot a ray out |
| 854 | ShootRayForLighting(&hit_vec, ¢er, &dest_vec, Curroomp - Rooms); |
| 855 | |
| 856 | Curroomp->verts[first_vert_index + i] = hit_vec; |
| 857 | } |
nothing calls this directly
no test coverage detected