1 /* $Id: ktmap.c,v 1.3 2004-12-19 15:21:11 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Texture map key bindings.
22 static char rcsid[] = "$Id: ktmap.c,v 1.3 2004-12-19 15:21:11 btb Exp $";
36 // Assign CurrentTexture to Curside in *Cursegp
37 int AssignTexture(void)
39 autosave_mine( mine_filename );
40 strcpy(undo_status[Autosave_count], "Assign Texture UNDONE.");
42 Cursegp->sides[Curside].tmap_num = CurrentTexture;
44 New_segment.sides[Curside].tmap_num = CurrentTexture;
46 // propagate_light_intensity(Cursegp, Curside, CurrentTexture, 0);
48 Update_flags |= UF_WORLD_CHANGED;
53 // Assign CurrentTexture to Curside in *Cursegp
54 int AssignTexture2(void)
56 int texnum, orient, ctexnum, newtexnum;
58 autosave_mine( mine_filename );
59 strcpy(undo_status[Autosave_count], "Assign Texture 2 UNDONE.");
61 texnum = Cursegp->sides[Curside].tmap_num2 & 0x3FFF;
62 orient = ((Cursegp->sides[Curside].tmap_num2 & 0xC000) >> 14) & 3;
63 ctexnum = CurrentTexture;
65 if ( ctexnum == texnum ) {
66 orient = (orient+1) & 3;
67 newtexnum = (orient<<14) | texnum;
72 Cursegp->sides[Curside].tmap_num2 = newtexnum;
73 New_segment.sides[Curside].tmap_num2 = newtexnum;
75 Update_flags |= UF_WORLD_CHANGED;
80 int ClearTexture2(void)
82 autosave_mine( mine_filename );
83 strcpy(undo_status[Autosave_count], "Clear Texture 2 UNDONE.");
85 Cursegp->sides[Curside].tmap_num2 = 0;
87 New_segment.sides[Curside].tmap_num2 = 0;
89 Update_flags |= UF_WORLD_CHANGED;
95 // --------------------------------------------------------------------------------------------------
96 // Propagate textures from Cursegp through Curside.
97 // If uv_flag !0, then only propagate uv coordinates (if 0, then propagate textures as well)
98 // If move_flag !0, then move forward to new segment after propagation, else don't
99 int propagate_textures_common(int uv_flag, int move_flag)
101 autosave_mine( mine_filename );
102 strcpy(undo_status[Autosave_count], "Propogate Textures UNDONE.");
104 if (IS_CHILD(Cursegp->children[Curside]))
105 med_propagate_tmaps_to_segments(Cursegp, &Segments[Cursegp->children[Curside]], uv_flag);
108 SelectCurrentSegForward();
110 Update_flags |= UF_WORLD_CHANGED;
115 // Propagate texture maps from current segment, through current side
116 int PropagateTextures(void)
118 return propagate_textures_common(0, 0);
121 // Propagate texture maps from current segment, through current side
122 int PropagateTexturesUVs(void)
124 return propagate_textures_common(-1, 0);
127 // Propagate texture maps from current segment, through current side
128 // And move to that segment.
129 int PropagateTexturesMove(void)
131 return propagate_textures_common(0, 1);
134 // Propagate uv coordinate from current segment, through current side
135 // And move to that segment.
136 int PropagateTexturesMoveUVs(void)
138 return propagate_textures_common(-1, 1);
142 // -------------------------------------------------------------------------------------
143 int is_selected_segment(int segnum)
147 for (i=0; i<N_selected_segs; i++)
148 if (Selected_segs[i] == segnum)
155 // -------------------------------------------------------------------------------------
156 // Auxiliary function for PropagateTexturesSelected.
158 void pts_aux(segment *sp)
162 Been_visited[sp-Segments] = 1;
164 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++) {
165 if (IS_CHILD(sp->children[side])) {
166 while ((!Been_visited[sp->children[side]]) && is_selected_segment(sp->children[side])) {
167 med_propagate_tmaps_to_segments(sp,&Segments[sp->children[side]],0);
168 pts_aux(&Segments[sp->children[side]]);
174 // -------------------------------------------------------------------------------------
175 // Propagate texture maps from current segment recursively exploring all children, to all segments in Selected_list
176 // until a segment not in Selected_list is reached.
177 int PropagateTexturesSelected(void)
181 autosave_mine( mine_filename );
182 strcpy(undo_status[Autosave_count], "Propogate Textures Selected UNDONE.");
184 for (i=0; i<MAX_SEGMENTS; i++) Been_visited[i] = 0; //clear visited list
185 Been_visited[Cursegp-Segments] = 1;
189 Update_flags |= UF_WORLD_CHANGED;