Browse Subversion Repository
Contents of /trunk/CTiePlugin.cpp
Parent Directory
| Revision Log
Revision 1 -
( show annotations)
( download)
( as text)
Sun Aug 15 01:53:13 2010 UTC
(13 years, 9 months ago)
by okadu
File MIME type: text/x-c++src
File size: 1755 byte(s)
| 1 |
#include "stdafx.h" |
| 2 |
#include "CRailPlugin.h" |
| 3 |
#include "CTiePlugin.h" |
| 4 |
#include "CTieSelectMode.h" |
| 5 |
|
| 6 |
/* |
| 7 |
* ロード |
| 8 |
*/ |
| 9 |
bool CTiePlugin::Load(){ |
| 10 |
char *str = m_Script, *tmp, *eee; |
| 11 |
if(!ChDir() || !m_Script) return false; |
| 12 |
try{ |
| 13 |
if(!(str = BeginBlock(eee = str, "TieInfo"))) throw CSynErr(eee); |
| 14 |
if(!(str = AsgnFloat(eee = str, "Height", &m_Height))) throw CSynErr(eee); |
| 15 |
if(tmp = AsgnYesNo(eee = str, "FlattenCant", &m_FlattenCant)) str = tmp; |
| 16 |
else m_FlattenCant = false; |
| 17 |
if(!(str = EndBlock(eee = str))) throw CSynErr(eee, ERR_ENDBLOCK); |
| 18 |
|
| 19 |
if(!(str = ReadProfile(eee = str))) throw CSynErr(eee); |
| 20 |
|
| 21 |
if(*(eee = str)) throw CSynErr(eee); |
| 22 |
} |
| 23 |
catch(CSynErr err){ |
| 24 |
HandleError(&err); |
| 25 |
return false; |
| 26 |
} |
| 27 |
LoadData(); |
| 28 |
DELETE_A(m_Buffer); |
| 29 |
return true; |
| 30 |
} |
| 31 |
|
| 32 |
/* |
| 33 |
* プレビュー設定 |
| 34 |
*/ |
| 35 |
void CTiePlugin::SetPreview(){ |
| 36 |
ms_PreviewState = true; |
| 37 |
g_Tie = this; |
| 38 |
string desc = g_Tie->GetBasicInfo(); |
| 39 |
desc += "\n"+g_Tie->GetDescription(); |
| 40 |
g_TieSelectMode->SetProperty((char *)desc.c_str()); |
| 41 |
} |
| 42 |
|
| 43 |
/* |
| 44 |
* ダンプ後処理 |
| 45 |
*/ |
| 46 |
void CTiePlugin::AfterDump( |
| 47 |
VEC3 &p1, VEC3 &u1, // 始点 (正規化済) |
| 48 |
VEC3 &ip1, VEC3 &iu1, // 非カント始点 (正規化済) |
| 49 |
VEC3 &p2, VEC3 &u2, // 終点 (正規化済) |
| 50 |
VEC3 &ip2, VEC3 &iu2 // 非カント終点 (正規化済) |
| 51 |
){ |
| 52 |
ip1 -= m_Height*iu1; |
| 53 |
ip2 -= m_Height*iu2; |
| 54 |
if(m_FlattenCant){ |
| 55 |
p1 = ip1; u1 = iu1; |
| 56 |
p2 = ip2; u2 = iu2; |
| 57 |
}else{ |
| 58 |
p1 -= m_Height*u1; |
| 59 |
p2 -= m_Height*u2; |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
/* |
| 64 |
* 橋脚設置位置計算 |
| 65 |
*/ |
| 66 |
void CTiePlugin::CalcPierPos( |
| 67 |
VEC3 *pos, // 位置 |
| 68 |
VEC3 *right, // right (正規化済) |
| 69 |
VEC3 *up, // up (正規化済) |
| 70 |
VEC3 *dir // dir (正規化済) |
| 71 |
){ |
| 72 |
if(m_FlattenCant){ |
| 73 |
right->y = 0.0f; |
| 74 |
V3Norm(up, V3Cross(up, dir, V3Norm(right, right))); |
| 75 |
} |
| 76 |
*pos -= *up*m_Height; |
| 77 |
} |
| |