|

楼主 |
发表于 2016-12-17 17:34:02
|
显示全部楼层
// Form1.h
#pragma once
namespace Test03 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
/// 変更する必要があります。この変更を行わないと、
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
public: System::Windows::Forms::PictureBox^ pictureBox1;
public: System::Windows::Forms::TextBox^ uiLooks;
public: System::Windows::Forms::TextBox^ uiFov;
public: System::Windows::Forms::TextBox^ uiTimeZoom;
public: System::Windows::Forms::TextBox^ uiInfo;
public: System::Windows::Forms::TextBox^ uiStands;
public:
public:
public:
public:
public:
protected:
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->uiLooks = (gcnew System::Windows::Forms::TextBox());
this->uiFov = (gcnew System::Windows::Forms::TextBox());
this->uiTimeZoom = (gcnew System::Windows::Forms::TextBox());
this->uiInfo = (gcnew System::Windows::Forms::TextBox());
this->uiStands = (gcnew System::Windows::Forms::TextBox());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit();
this->SuspendLayout();
//
// pictureBox1
//
this->pictureBox1->BackColor = System::Drawing::Color::Black;
this->pictureBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
this->pictureBox1->Location = System::Drawing::Point(12, 12);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(800, 600);
this->pictureBox1->TabIndex = 0;
this->pictureBox1->TabStop = false;
this->pictureBox1->MouseCaptureChanged += gcnew System::EventHandler(this, &Form1::pictureBox1_MouseCaptureChanged);
this->pictureBox1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseMove);
this->pictureBox1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseDown);
this->pictureBox1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::pictureBox1_MouseUp);
//
// uiLooks
//
this->uiLooks->Location = System::Drawing::Point(12, 629);
this->uiLooks->Name = L"uiLooks";
this->uiLooks->Size = System::Drawing::Size(56, 19);
this->uiLooks->TabIndex = 1;
this->uiLooks->TextChanged += gcnew System::EventHandler(this, &Form1::uiLooks_TextChanged);
//
// uiFov
//
this->uiFov->Location = System::Drawing::Point(116, 629);
this->uiFov->Name = L"uiFov";
this->uiFov->Size = System::Drawing::Size(78, 19);
this->uiFov->TabIndex = 2;
this->uiFov->TextChanged += gcnew System::EventHandler(this, &Form1::uiFov_TextChanged);
//
// uiTimeZoom
//
this->uiTimeZoom->Location = System::Drawing::Point(237, 629);
this->uiTimeZoom->Name = L"uiTimeZoom";
this->uiTimeZoom->Size = System::Drawing::Size(100, 19);
this->uiTimeZoom->TabIndex = 3;
this->uiTimeZoom->TextChanged += gcnew System::EventHandler(this, &Form1::uiTimeZoom_TextChanged);
//
// uiInfo
//
this->uiInfo->Location = System::Drawing::Point(343, 629);
this->uiInfo->Multiline = true;
this->uiInfo->Name = L"uiInfo";
this->uiInfo->Size = System::Drawing::Size(469, 49);
this->uiInfo->TabIndex = 4;
//
// uiStands
//
this->uiStands->Location = System::Drawing::Point(12, 659);
this->uiStands->Name = L"uiStands";
this->uiStands->Size = System::Drawing::Size(56, 19);
this->uiStands->TabIndex = 5;
this->uiStands->TextChanged += gcnew System::EventHandler(this, &Form1::uiStands_TextChanged);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(824, 690);
this->Controls->Add(this->uiStands);
this->Controls->Add(this->uiInfo);
this->Controls->Add(this->uiTimeZoom);
this->Controls->Add(this->uiFov);
this->Controls->Add(this->uiLooks);
this->Controls->Add(this->pictureBox1);
this->KeyPreview = true;
this->Name = L"Form1";
this->Text = L"Form1";
this->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Form1::Form1_KeyPress);
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void uiLooks_TextChanged(System::Object^ sender, System::EventArgs^ e) {
try
{
Looks = int::Parse(uiLooks->Text);
}
catch (Exception ^ex)
{
Looks = -1;
}
ChildCamFront = ChildCamFront0;
ChildCamUp = ChildCamUp0;
}
private: System::Void uiStands_TextChanged(System::Object^ sender, System::EventArgs^ e) {
try
{
Stands = int::Parse(uiStands->Text);
}
catch (Exception ^ex)
{
Stands = -1;
}
ChildCamPos = ChildCamPos0;
}
private: System::Void uiFov_TextChanged(System::Object^ sender, System::EventArgs^ e) {
try
{
FovDeg = R::Parse(uiFov->Text);
}
catch (Exception ^ex)
{
}
}
private: System::Void uiTimeZoom_TextChanged(System::Object^ sender, System::EventArgs^ e) {
try
{
TimeZoom = R::Parse(uiTimeZoom->Text);
}
catch (Exception ^ex)
{
}
}
private: Nullable<Point> oldMousePos;
private: System::Void pictureBox1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
oldMousePos = e->Location;
}
private: System::Void pictureBox1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
if (oldMousePos.HasValue == false)
return;
int dx = e->X - oldMousePos.Value.X;
int dy = e->Y - oldMousePos.Value.Y;
oldMousePos = e->Location;
R φ = (dx / 1000.0) * Fov();
R θ = (- dy / 1000.0) * Fov();
ChildCamFront = R3(cos(φ) * ChildCamFront(0) - sin(φ) * ChildCamFront(2),
ChildCamFront(1),
sin(φ) * ChildCamFront(0) + cos(φ) * ChildCamFront(2));
ChildCamUp = R3(cos(φ) * ChildCamUp(0) - sin(φ) * ChildCamUp(2),
ChildCamUp(1),
sin(φ) * ChildCamUp(0) + cos(φ) * ChildCamUp(2));
// or via base-trans
DXMatrix homoMat;
homoMat.RotateAxis(ToDXVec(Cross(ChildCamUp, ChildCamFront)), θ);
ChildCamFront = FromDXVec<R31>(Vector3::TransformNormal(ToDXVec(ChildCamFront), homoMat));
ChildCamUp = FromDXVec<R31>(Vector3::TransformNormal(ToDXVec(ChildCamUp), homoMat));
}
private: System::Void pictureBox1_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
oldMousePos = Nullable<Point>();
}
private: System::Void pictureBox1_MouseCaptureChanged(System::Object^ sender, System::EventArgs^ e) {
oldMousePos = Nullable<Point>();
}
private: System::Void Form1_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e) {
/*switch (e->KeyChar)
{
}*/
}
};
}
又整了个3D版的。
g_solarsys_simu_3d.rar
(41.1 KB, 下载次数: 110)
|
|