Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CRailDumpCurve.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download) (as text)
Tue Nov 23 14:34:03 2010 UTC (13 years, 5 months ago) by okadu
File MIME type: text/x-c++src
File size: 8224 byte(s)
[okadu] Version 2.13
1 #include "stdafx.h"
2 #include "RailMap.h"
3 #include "CRailDetectCurve.h"
4 #include "CRailDumpCurve.h"
5 #include "CRailPlugin.h"
6 #include "CTiePlugin.h"
7 #include "CGirderPlugin.h"
8 #include "CCamera.h"
9
10 // 外部グローバル
11 extern bool g_ShowRailSelect;
12 extern bool g_ShowRailWaySelect;
13 extern bool g_ShowRailBlockSelect;
14 extern bool g_ShowSpeedLimitSelect;
15 extern bool g_MultiTrackDummy;
16 extern int g_DummyTrackNum;
17 extern float g_DummyTrackInterval;
18 extern VEC3 g_RailMapCenter;
19 extern VEC2 g_RailMapOffset;
20
21 // 内部グローバル
22 // diffuse, ambient, specular, emissive
23 MAT8 g_MatSelect[5] = { // 選択マテリアル (不透明)
24 {{0,0,0,1}, {0,0,0,1}, {0,0,0,1}, {1,1,1,1}, 1.0f}, // 非選択
25 {{0,0,0,1}, {0,0,0,1}, {0,0,0,1}, {1,0,0,1}, 1.0f}, // ハイライト
26 {{0,0,0,1}, {0,0,0,1}, {0,0,0,1}, {0,1,0,1}, 1.0f}, // 選択
27 {{0,0,0,1}, {0,0,0,1}, {0,0,0,1}, {1,1,0,1}, 1.0f}, // 選択+ハイライト
28 {{0,0,0,1}, {0,0,0,1}, {0,0,0,1}, {1,0.5f,0,1}, 1.0f}}; // 薄いハイライト
29 MAT8 g_MatSelectA[5] = { // 選択マテリアル (半透明)
30 {{0,0,0,0.75f}, {0,0,0,1}, {0,0,0,1}, {1,1,1,1}, 1.0f}, // 非選択
31 {{0,0,0,0.75f}, {0,0,0,1}, {0,0,0,1}, {1,0,0,1}, 1.0f}, // ハイライト
32 {{0,0,0,0.75f}, {0,0,0,1}, {0,0,0,1}, {0,1,0,1}, 1.0f}, // 選択
33 {{0,0,0,0.75f}, {0,0,0,1}, {0,0,0,1}, {1,1,0,1}, 1.0f}, // 選択+ハイライト
34 {{0,0,0,0.75f}, {0,0,0,1}, {0,0,0,1}, {1,0.5f,0,1}, 1.0f}}; // 薄いハイライト
35 D3DCOLOR g_ColorSelect[5] = {
36 0xffffffff, 0xffff0000, 0xff00ff00, 0xffffff00, 0xff800000}; // D3DCOLOR 版
37
38 /*
39 * トレース完了
40 */
41 void CRailDumpCurve::FinishTrace(
42 VEC3 &pos1, VEC3 &right1, VEC3 &up1, VEC3 &dir1, // 始点
43 VEC3 &pos2, VEC3 &right2, VEC3 &up2, VEC3 &dir2, // 終点
44 float sumlen, float seglen, // 積算距離・セグメント距離
45 CRailSplitter &splitter // 分割子
46 ){
47 VEC3 tpos1 = pos1, ipos1 = pos1, tpos2 = pos2, ipos2 = pos2;
48 VEC3 icright1, icup1 = V3UP, icright2, icup2 = V3UP;
49 V3NormAxis(&icright1, &icup1, &dir1);
50 V3NormAxis(&icright2, &icup2, &dir2);
51 if(m_RailPlugin){
52 if(g_MultiTrackDummy){
53 m_RailPlugin->BeforeDump(
54 tpos1, right1, R2L(VEC3(up1)),
55 tpos2, right2, R2L(VEC3(up2)));
56 m_RailPlugin->AfterDump(
57 tpos1, R2L(VEC3(up1)), ipos1, icup1,
58 tpos2, R2L(VEC3(up2)), ipos2, icup2);
59 }else{
60 m_RailPlugin->Dump(
61 tpos1, right1, R2L(VEC3(up1)), ipos1, icright1, icup1,
62 tpos2, right2, R2L(VEC3(up2)), ipos2, icright2, icup2, seglen, 4);
63 }
64 }
65 if(m_TiePlugin){
66 if(g_MultiTrackDummy){
67 m_TiePlugin->AfterDump(
68 tpos1, R2L(VEC3(up1)), ipos1, icup1,
69 tpos2, R2L(VEC3(up2)), ipos2, icup2);
70 }else{
71 m_TiePlugin->Dump(
72 tpos1, right1, R2L(VEC3(up1)), ipos1, icright1, icup1,
73 tpos2, right2, R2L(VEC3(up2)), ipos2, icright2, icup2, seglen, 4);
74 }
75 }
76 if(m_GirderPlugin && g_MultiTrackDummy==m_GirderPlugin->IsMultiTrack())
77 m_GirderPlugin->Dump(
78 tpos1, right1, R2L(VEC3(up1)), ipos1, icright1, icup1,
79 tpos2, right2, R2L(VEC3(up2)), ipos2, icright2, icup2, seglen, 4);
80 }
81
82 ////////////////////////////////////////////////////////////////////////////////
83 ////////////////////////////////////////////////////////////////////////////////
84
85 /*
86 * トレース完了
87 */
88 void CRailRenderCurve::FinishTrace(
89 VEC3 &pos1, VEC3 &right1, VEC3 &up1, VEC3 &dir1, // 始点
90 VEC3 &pos2, VEC3 &right2, VEC3 &up2, VEC3 &dir2, // 終点
91 float sumlen, float seglen, // 積算距離・セグメント距離
92 CRailSplitter &splitter // 分割子
93 ){
94 if(!g_MultiTrackDummy) RailMapLine(pos1, 0xffffffff, pos2, 0xffffffff);
95 VEC3 tpos1 = pos1, ipos1 = pos1, tpos2 = pos2, ipos2 = pos2;
96 VEC3 icright1, icup1 = V3UP, icright2, icup2 = V3UP;
97 V3NormAxis(&icright1, &icup1, &dir1);
98 V3NormAxis(&icright2, &icup2, &dir2);
99 int terminate = (ms_Terminate1 ? 1 : 0)|(ms_Terminate2 ? 2 : 0);
100 int tmp_selected = splitter.m_Selected;
101 if(!tmp_selected && CRailDetectCurve2D::IsDetected() &&
102 (g_ShowRailWaySelect && CRailDetectCurve2D::GetDetect().m_Link==m_RailWay
103 || g_ShowRailBlockSelect && m_RailWay->IsRailBlock()
104 && m_RailWay->GetRailBlock()==CRailDetectCurve2D::GetDetect().m_Link->GetRailBlock()
105 || g_ShowSpeedLimitSelect && m_RailWay->IsSpeedLimit()
106 && m_RailWay->GetSpeedLimit()==CRailDetectCurve2D::GetDetect().m_Link->GetSpeedLimit())){
107 tmp_selected = 4;
108 }
109 bool use_altmat = g_ShowRailSelect && tmp_selected;
110 MAT8 *altmat = use_altmat ? &g_MatSelect[tmp_selected] : NULL;
111 MAT8 *altmat2 = use_altmat ? &g_MatSelectA[tmp_selected] : NULL;
112 int render_mode;
113 if(m_RailPlugin){
114 if(g_MultiTrackDummy){
115 m_RailPlugin->BeforeDump(
116 tpos1, right1, R2L(VEC3(up1)),
117 tpos2, right2, R2L(VEC3(up2)));
118 m_RailPlugin->AfterDump(
119 tpos1, R2L(VEC3(up1)), ipos1, icup1,
120 tpos2, R2L(VEC3(up2)), ipos2, icup2);
121 }else{
122 if(use_altmat || m_RailWay->GetParent()){
123 devSetTexture(0, NULL);
124 if(use_altmat){
125 devSetMaterial(altmat2);
126 render_mode = 1;
127 }else{
128 render_mode = 7;
129 }
130 devResetMatrix();
131 m_RailPlugin->Dump(
132 R2L(VEC3(tpos1)), R2L(VEC3(right1)), R2L(VEC3(up1)),
133 R2L(VEC3(ipos1)), R2L(VEC3(icright1)), R2L(VEC3(icup1)),
134 R2L(VEC3(tpos2)), R2L(VEC3(right2)), R2L(VEC3(up2)),
135 R2L(VEC3(ipos2)), R2L(VEC3(icright2)), R2L(VEC3(icup2)), seglen, render_mode);
136 }
137 m_RailPlugin->Render(
138 tpos1, right1, R2L(VEC3(up1)), dir1, ipos1, icright1, icup1,
139 tpos2, right2, R2L(VEC3(up2)), dir2, ipos2, icright2, icup2,
140 terminate, seglen, altmat);
141 }
142 }
143 if(m_TiePlugin){
144 if(g_MultiTrackDummy){
145 m_TiePlugin->AfterDump(
146 tpos1, R2L(VEC3(up1)), ipos1, icup1,
147 tpos2, R2L(VEC3(up2)), ipos2, icup2);
148 }else{
149 if(use_altmat || m_RailWay->GetParent()){
150 devSetTexture(0, NULL);
151 if(use_altmat){
152 devSetMaterial(altmat2);
153 render_mode = 1;
154 }else{
155 render_mode = 7;
156 }
157 devResetMatrix();
158 m_TiePlugin->Dump(
159 R2L(VEC3(tpos1)), R2L(VEC3(right1)), R2L(VEC3(up1)),
160 R2L(VEC3(ipos1)), R2L(VEC3(icright1)), R2L(VEC3(icup1)),
161 R2L(VEC3(tpos2)), R2L(VEC3(right2)), R2L(VEC3(up2)),
162 R2L(VEC3(ipos2)), R2L(VEC3(icright2)), R2L(VEC3(icup2)), seglen, render_mode);
163 }
164 m_TiePlugin->Render(
165 tpos1, right1, R2L(VEC3(up1)), dir1, ipos1, icright1, icup1,
166 tpos2, right2, R2L(VEC3(up2)), dir2, ipos2, icright2, icup2,
167 terminate, seglen, altmat);
168 }
169 }
170 if(g_MultiTrackDummy){
171 right1.y = right2.y = 0.0f;
172 V3Norm(&up1, V3Cross(&up1, &dir1, V3Norm(&right1, &right1)));
173 V3Norm(&up2, V3Cross(&up2, &dir2, V3Norm(&right2, &right2)));
174 }
175 if(m_GirderPlugin && g_MultiTrackDummy==m_GirderPlugin->IsMultiTrack()){
176 if(use_altmat || m_RailWay->GetParent()){
177 devSetTexture(0, NULL);
178 if(use_altmat){
179 devSetMaterial(altmat2);
180 render_mode = 1;
181 }else{
182 render_mode = 7;
183 }
184 devResetMatrix();
185 m_GirderPlugin->Dump(
186 R2L(VEC3(tpos1)), R2L(VEC3(right1)), R2L(VEC3(up1)),
187 R2L(VEC3(ipos1)), R2L(VEC3(icright1)), R2L(VEC3(icup1)),
188 R2L(VEC3(tpos2)), R2L(VEC3(right2)), R2L(VEC3(up2)),
189 R2L(VEC3(ipos2)), R2L(VEC3(icright2)), R2L(VEC3(icup2)), seglen, render_mode);
190 }
191 m_GirderPlugin->Render(
192 tpos1, right1, R2L(VEC3(up1)), dir1, ipos1, icright1, icup1,
193 tpos2, right2, R2L(VEC3(up2)), dir2, ipos2, icright2, icup2, terminate, seglen, altmat);
194 }else if(g_MultiTrackDummy){
195 if(g_ShowRailSelect && tmp_selected){
196 devSetTexture(0, NULL);
197 devSetMaterial(altmat);
198 devResetMatrix();
199 devSetZRead(FALSE);
200 int i;
201 for(i = 0; i<g_DummyTrackNum; i++){
202 VEC3 p11 = tpos1+right1*((i-0.5f*g_DummyTrackNum)*g_DummyTrackInterval);
203 VEC3 p12 = tpos1+right1*((i+1-0.5f*g_DummyTrackNum)*g_DummyTrackInterval);
204 VEC3 p21 = tpos2+right2*((i-0.5f*g_DummyTrackNum)*g_DummyTrackInterval);
205 VEC3 p22 = tpos2+right2*((i+1-0.5f*g_DummyTrackNum)*g_DummyTrackInterval);
206 if(!i) Draw3DLine(p11, p21, 0xffffffff, 0xffffffff);
207 Draw3DLine(p11, p22, 0xffffffff, 0xffffffff);
208 Draw3DLine(p12, p21, 0xffffffff, 0xffffffff);
209 Draw3DLine(p12, p22, 0xffffffff, 0xffffffff);
210 Draw3DLine(p11, p12, 0xffffffff, 0xffffffff);
211 Draw3DLine(p21, p22, 0xffffffff, 0xffffffff);
212 }
213 devSetZRead(TRUE);
214 }
215 }
216 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26