2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
14 * $Source: /cvs/cvsroot/d2x/main/editor/ktmap.c,v $
17 * $Date: 2004-12-19 13:54:27 $
19 * Texture map key bindings.
21 * $Log: not supported by cvs2svn $
22 * Revision 1.1.1.1 1999/06/14 22:03:34 donut
23 * Import of d1x 1.37 source.
25 * Revision 2.0 1995/02/27 11:35:37 john
26 * Version 2.0! No anonymous unions, Watcom 10.0, with no need
29 * Revision 1.26 1994/08/25 21:57:12 mike
32 * Revision 1.25 1994/08/03 10:32:41 mike
33 * Texture map stretching.
35 * Revision 1.24 1994/05/14 17:17:35 matt
36 * Got rid of externs in source (non-header) files
38 * Revision 1.23 1994/04/28 10:48:38 yuan
39 * Fixed undo message for Clear Texture.
41 * Revision 1.22 1994/04/22 17:45:42 john
42 * MAde top 2 bits of paste-ons pick the
43 * orientation of the bitmap.
45 * Revision 1.21 1994/04/01 14:36:08 yuan
46 * Fixed propogate function so you can propogate and move.
48 * Revision 1.20 1994/03/19 17:22:08 yuan
49 * Wall system implemented until specific features need to be added...
50 * (Needs to be hammered on though.)
52 * Revision 1.19 1994/02/14 12:06:12 mike
53 * change segment data structure.
55 * Revision 1.18 1994/01/25 17:58:47 yuan
56 * Added ambient lighting, and also added fixing bogus segments
57 * functions to the editor... (they don't work fully... need to
60 * Revision 1.17 1994/01/24 11:54:52 yuan
61 * Checking everything in
63 * Revision 1.16 1994/01/18 16:05:57 yuan
64 * Added clear texture 2 function (shift 0)
66 * Revision 1.15 1994/01/18 10:15:01 yuan
69 * Revision 1.14 1993/12/06 19:33:57 yuan
70 * Fixed autosave stuff so that undo restores Cursegp and
73 * Revision 1.13 1993/12/02 12:39:39 matt
74 * Removed extra includes
76 * Revision 1.12 1993/11/28 17:31:34 mike
77 * Use new segment data structure.
79 * Revision 1.11 1993/11/12 16:38:37 mike
80 * Change call to med_propagate_tmaps_to_segments to include new uv_only_flag parameter.
82 * Revision 1.10 1993/11/11 15:53:30 yuan
83 * Fixed undo display message
85 * Revision 1.9 1993/11/08 19:13:46 yuan
86 * Added Undo command (not working yet)
88 * Revision 1.8 1993/11/05 17:32:48 john
92 * Revision 1.7 1993/11/02 10:31:08 mike
93 * Add PropagateTexturesSelected.
95 * Revision 1.6 1993/10/29 11:43:15 mike
96 * Write PropagateTextures
98 * Revision 1.5 1993/10/25 13:26:39 mike
99 * Force redraw whenever a texture map is assigned.
101 * Revision 1.4 1993/10/15 17:42:53 mike
102 * Make AssignTexture also assign texture maps to New_segment.
104 * Revision 1.3 1993/10/15 13:10:24 mike
105 * Adapt AssignTexture to new segment structure.
107 * Revision 1.2 1993/10/14 18:09:17 mike
108 * Debug code for AssignTexture and comment out code.
110 * Revision 1.1 1993/10/14 14:01:49 mike
118 static char rcsid[] = "$Id: ktmap.c,v 1.1 2004-12-19 13:54:27 btb Exp $";
128 // Assign CurrentTexture to Curside in *Cursegp
129 int AssignTexture(void)
131 autosave_mine( mine_filename );
132 strcpy(undo_status[Autosave_count], "Assign Texture UNDONE.");
134 Cursegp->sides[Curside].tmap_num = CurrentTexture;
136 New_segment.sides[Curside].tmap_num = CurrentTexture;
138 // propagate_light_intensity(Cursegp, Curside, CurrentTexture, 0);
140 Update_flags |= UF_WORLD_CHANGED;
145 // Assign CurrentTexture to Curside in *Cursegp
146 int AssignTexture2(void)
148 int texnum, orient, ctexnum, newtexnum;
150 autosave_mine( mine_filename );
151 strcpy(undo_status[Autosave_count], "Assign Texture 2 UNDONE.");
153 texnum = Cursegp->sides[Curside].tmap_num2 & 0x3FFF;
154 orient = ((Cursegp->sides[Curside].tmap_num2 & 0xC000) >> 14) & 3;
155 ctexnum = CurrentTexture;
157 if ( ctexnum == texnum ) {
158 orient = (orient+1) & 3;
159 newtexnum = (orient<<14) | texnum;
164 Cursegp->sides[Curside].tmap_num2 = newtexnum;
165 New_segment.sides[Curside].tmap_num2 = newtexnum;
167 Update_flags |= UF_WORLD_CHANGED;
172 int ClearTexture2(void)
174 autosave_mine( mine_filename );
175 strcpy(undo_status[Autosave_count], "Clear Texture 2 UNDONE.");
177 Cursegp->sides[Curside].tmap_num2 = 0;
179 New_segment.sides[Curside].tmap_num2 = 0;
181 Update_flags |= UF_WORLD_CHANGED;
187 // --------------------------------------------------------------------------------------------------
188 // Propagate textures from Cursegp through Curside.
189 // If uv_flag !0, then only propagate uv coordinates (if 0, then propagate textures as well)
190 // If move_flag !0, then move forward to new segment after propagation, else don't
191 int propagate_textures_common(int uv_flag, int move_flag)
193 autosave_mine( mine_filename );
194 strcpy(undo_status[Autosave_count], "Propogate Textures UNDONE.");
196 if (IS_CHILD(Cursegp->children[Curside]))
197 med_propagate_tmaps_to_segments(Cursegp, &Segments[Cursegp->children[Curside]], uv_flag);
200 SelectCurrentSegForward();
202 Update_flags |= UF_WORLD_CHANGED;
207 // Propagate texture maps from current segment, through current side
208 int PropagateTextures(void)
210 return propagate_textures_common(0, 0);
213 // Propagate texture maps from current segment, through current side
214 int PropagateTexturesUVs(void)
216 return propagate_textures_common(-1, 0);
219 // Propagate texture maps from current segment, through current side
220 // And move to that segment.
221 int PropagateTexturesMove(void)
223 return propagate_textures_common(0, 1);
226 // Propagate uv coordinate from current segment, through current side
227 // And move to that segment.
228 int PropagateTexturesMoveUVs(void)
230 return propagate_textures_common(-1, 1);
234 // -------------------------------------------------------------------------------------
235 int is_selected_segment(int segnum)
239 for (i=0; i<N_selected_segs; i++)
240 if (Selected_segs[i] == segnum)
247 // -------------------------------------------------------------------------------------
248 // Auxiliary function for PropagateTexturesSelected.
250 void pts_aux(segment *sp)
254 Been_visited[sp-Segments] = 1;
256 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++) {
257 if (IS_CHILD(sp->children[side])) {
258 while ((!Been_visited[sp->children[side]]) && is_selected_segment(sp->children[side])) {
259 med_propagate_tmaps_to_segments(sp,&Segments[sp->children[side]],0);
260 pts_aux(&Segments[sp->children[side]]);
266 // -------------------------------------------------------------------------------------
267 // Propagate texture maps from current segment recursively exploring all children, to all segments in Selected_list
268 // until a segment not in Selected_list is reached.
269 int PropagateTexturesSelected(void)
273 autosave_mine( mine_filename );
274 strcpy(undo_status[Autosave_count], "Propogate Textures Selected UNDONE.");
276 for (i=0; i<MAX_SEGMENTS; i++) Been_visited[i] = 0; //clear visited list
277 Been_visited[Cursegp-Segments] = 1;
281 Update_flags |= UF_WORLD_CHANGED;