1 /* $Id: ktmap.c,v 1.2 2004-12-19 14:52:48 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.
23 static char rcsid[] = "$Id: ktmap.c,v 1.2 2004-12-19 14:52:48 btb Exp $";
33 // Assign CurrentTexture to Curside in *Cursegp
34 int AssignTexture(void)
36 autosave_mine( mine_filename );
37 strcpy(undo_status[Autosave_count], "Assign Texture UNDONE.");
39 Cursegp->sides[Curside].tmap_num = CurrentTexture;
41 New_segment.sides[Curside].tmap_num = CurrentTexture;
43 // propagate_light_intensity(Cursegp, Curside, CurrentTexture, 0);
45 Update_flags |= UF_WORLD_CHANGED;
50 // Assign CurrentTexture to Curside in *Cursegp
51 int AssignTexture2(void)
53 int texnum, orient, ctexnum, newtexnum;
55 autosave_mine( mine_filename );
56 strcpy(undo_status[Autosave_count], "Assign Texture 2 UNDONE.");
58 texnum = Cursegp->sides[Curside].tmap_num2 & 0x3FFF;
59 orient = ((Cursegp->sides[Curside].tmap_num2 & 0xC000) >> 14) & 3;
60 ctexnum = CurrentTexture;
62 if ( ctexnum == texnum ) {
63 orient = (orient+1) & 3;
64 newtexnum = (orient<<14) | texnum;
69 Cursegp->sides[Curside].tmap_num2 = newtexnum;
70 New_segment.sides[Curside].tmap_num2 = newtexnum;
72 Update_flags |= UF_WORLD_CHANGED;
77 int ClearTexture2(void)
79 autosave_mine( mine_filename );
80 strcpy(undo_status[Autosave_count], "Clear Texture 2 UNDONE.");
82 Cursegp->sides[Curside].tmap_num2 = 0;
84 New_segment.sides[Curside].tmap_num2 = 0;
86 Update_flags |= UF_WORLD_CHANGED;
92 // --------------------------------------------------------------------------------------------------
93 // Propagate textures from Cursegp through Curside.
94 // If uv_flag !0, then only propagate uv coordinates (if 0, then propagate textures as well)
95 // If move_flag !0, then move forward to new segment after propagation, else don't
96 int propagate_textures_common(int uv_flag, int move_flag)
98 autosave_mine( mine_filename );
99 strcpy(undo_status[Autosave_count], "Propogate Textures UNDONE.");
101 if (IS_CHILD(Cursegp->children[Curside]))
102 med_propagate_tmaps_to_segments(Cursegp, &Segments[Cursegp->children[Curside]], uv_flag);
105 SelectCurrentSegForward();
107 Update_flags |= UF_WORLD_CHANGED;
112 // Propagate texture maps from current segment, through current side
113 int PropagateTextures(void)
115 return propagate_textures_common(0, 0);
118 // Propagate texture maps from current segment, through current side
119 int PropagateTexturesUVs(void)
121 return propagate_textures_common(-1, 0);
124 // Propagate texture maps from current segment, through current side
125 // And move to that segment.
126 int PropagateTexturesMove(void)
128 return propagate_textures_common(0, 1);
131 // Propagate uv coordinate from current segment, through current side
132 // And move to that segment.
133 int PropagateTexturesMoveUVs(void)
135 return propagate_textures_common(-1, 1);
139 // -------------------------------------------------------------------------------------
140 int is_selected_segment(int segnum)
144 for (i=0; i<N_selected_segs; i++)
145 if (Selected_segs[i] == segnum)
152 // -------------------------------------------------------------------------------------
153 // Auxiliary function for PropagateTexturesSelected.
155 void pts_aux(segment *sp)
159 Been_visited[sp-Segments] = 1;
161 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++) {
162 if (IS_CHILD(sp->children[side])) {
163 while ((!Been_visited[sp->children[side]]) && is_selected_segment(sp->children[side])) {
164 med_propagate_tmaps_to_segments(sp,&Segments[sp->children[side]],0);
165 pts_aux(&Segments[sp->children[side]]);
171 // -------------------------------------------------------------------------------------
172 // Propagate texture maps from current segment recursively exploring all children, to all segments in Selected_list
173 // until a segment not in Selected_list is reached.
174 int PropagateTexturesSelected(void)
178 autosave_mine( mine_filename );
179 strcpy(undo_status[Autosave_count], "Propogate Textures Selected UNDONE.");
181 for (i=0; i<MAX_SEGMENTS; i++) Been_visited[i] = 0; //clear visited list
182 Been_visited[Cursegp-Segments] = 1;
186 Update_flags |= UF_WORLD_CHANGED;