home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / MEDIT.LZH / DINPUT.CPP < prev    next >
C/C++ Source or Header  |  1996-07-18  |  6KB  |  186 lines

  1. /*  Project medit
  2.     Project Team DoGA
  3.     Copyright (c) 1995. All Rights Reserved.
  4.  
  5.     サブシステム:    medit.apx Application
  6.     ファイル:        dinput.cpp
  7.     作成者:          Taka2
  8.  
  9.  
  10.     概要
  11.     ====
  12.     TDDirectInput (TDialog) のインプリメンテーション用のソースファイル
  13. */
  14.  
  15. #include <owl\owlpch.h>
  16. #pragma hdrstop
  17.  
  18. #include <stdio.h>
  19. #include <owl\edit.h>
  20. #include "dinput.h"
  21. #include "matrix.h"
  22. #include "anim.h"
  23. #include "parts.h"
  24.  
  25. //
  26. // このアプリケーションで処理するすべてのメッセージ/コマンドの
  27. // 応答テーブルを作成する
  28. //
  29.  
  30. DEFINE_RESPONSE_TABLE1(TDDirectInput, TDialog)
  31. //{{TDDirectInputRSP_TBL_BEGIN}}
  32.     EV_BN_CLICKED(IDOK, CmOK),
  33. //{{TDDirectInputRSP_TBL_END}}
  34. END_RESPONSE_TABLE;
  35.  
  36. //{{TDDirectInput Implementation}}
  37.  
  38.  
  39. TDDirectInput::TDDirectInput (TWindow* parent, AnimationData *a, int initialpos, TResId resId, TModule* module):
  40.     TDialog(parent, resId, module)
  41. {
  42.     // INSERT>> コンストラクタ用のコードはここに
  43. //    SetBkgndColor(TColor::LtGray);
  44.  
  45.     m1 = new TStatic(this, IDC_DIRECT_M1);
  46.     m2 = new TStatic(this, IDC_DIRECT_M2);
  47.     m3 = new TStatic(this, IDC_DIRECT_M3);
  48.     m4 = new TStatic(this, IDC_DIRECT_M4);
  49.     m5 = new TStatic(this, IDC_DIRECT_M5);
  50.     tsx = new TStatic(this, IDC_DIRECT_TEXT_SX);
  51.     tsy = new TStatic(this, IDC_DIRECT_TEXT_SY);
  52.     tsz = new TStatic(this, IDC_DIRECT_TEXT_SZ);
  53.  
  54.     px = new TEdit(this, IDC_DIRECT_PX);
  55.     py = new TEdit(this, IDC_DIRECT_PY);
  56.     pz = new TEdit(this, IDC_DIRECT_PZ);
  57.     rx = new TEdit(this, IDC_DIRECT_RX);
  58.     ry = new TEdit(this, IDC_DIRECT_RY);
  59.     rz = new TEdit(this, IDC_DIRECT_RZ);
  60.     sx = new TEdit(this, IDC_DIRECT_SX);
  61.     sy = new TEdit(this, IDC_DIRECT_SY);
  62.     sz = new TEdit(this, IDC_DIRECT_SZ);
  63.     bf = new TEdit(this, IDC_DIRECT_BEGIN);
  64.     ef = new TEdit(this, IDC_DIRECT_END);
  65.  
  66.     anim = a;
  67.     ipos = initialpos;
  68. }
  69.  
  70.  
  71. TDDirectInput::~TDDirectInput ()
  72. {
  73.     Destroy();
  74.  
  75.     // INSERT>> デストラクタ用のコードはここに
  76.  
  77. }
  78.  
  79.  
  80. void TDDirectInput::SetupWindow ()
  81. {
  82.     TDialog::SetupWindow();
  83.  
  84.     // INSERT>> 追加のコードはここに
  85.  
  86.     if (anim->select != NULL) {
  87.         Motion *m = anim->select;
  88.         char str[16];
  89.         if (anim->select == anim->camera || anim->select == anim->camera->target) {
  90.             m = anim->camera;
  91.             Motion *t = anim->camera->target;
  92.             sprintf(str, "%5.0lf", m->position.x);        px->SetText(str);
  93.             sprintf(str, "%5.0lf", m->position.y);        py->SetText(str);
  94.             sprintf(str, "%5.0lf", m->position.z);        pz->SetText(str);
  95.             sprintf(str, "%5.0lf", t->position.x);        rx->SetText(str);
  96.             sprintf(str, "%5.0lf", t->position.y);        ry->SetText(str);
  97.             sprintf(str, "%5.0lf", t->position.z);        rz->SetText(str);
  98.             m1->SetText("カメラ");
  99.             m2->SetText("ターゲット");
  100. //            rx->Show(SW_HIDE);
  101. //            ry->Show(SW_HIDE);
  102. //            rz->Show(SW_HIDE);
  103.             m3->Show(SW_HIDE);
  104.             sx->Show(SW_HIDE);
  105.             sy->Show(SW_HIDE);
  106.             sz->Show(SW_HIDE);
  107.             tsx->Show(SW_HIDE);
  108.             tsy->Show(SW_HIDE);
  109.             tsz->Show(SW_HIDE);
  110.  
  111.             m4->Show(SW_HIDE);
  112.             m5->Show(SW_HIDE);
  113.             bf->Show(SW_HIDE);
  114.             ef->Show(SW_HIDE);
  115.         } else {
  116.             sprintf(str, "%5.0lf", m->position.x);        px->SetText(str);
  117.             sprintf(str, "%5.0lf", m->position.y);        py->SetText(str);
  118.             sprintf(str, "%5.0lf", m->position.z);        pz->SetText(str);
  119.             sprintf(str, "%4.0lf", rad(m->rotation.x));    rx->SetText(str);
  120.             sprintf(str, "%4.0lf", rad(m->rotation.y));    ry->SetText(str);
  121.             sprintf(str, "%4.0lf", rad(m->rotation.z));    rz->SetText(str);
  122.             sprintf(str, "%5.3lf", m->scale.x);            sx->SetText(str);
  123.             sprintf(str, "%5.3lf", m->scale.y);            sy->SetText(str);
  124.             sprintf(str, "%5.3lf", m->scale.z);            sz->SetText(str);
  125.             sprintf(str, "%d", m->beginframe);            bf->SetText(str);
  126.             sprintf(str, "%d", m->endframe);            ef->SetText(str);
  127.         }
  128.     }
  129. }
  130.  
  131.  
  132. static void limit(Vector& v)
  133. {
  134.     if (v.x >  limitdim) v.x =  limitdim;
  135.     if (v.x < -limitdim) v.x = -limitdim;
  136.     if (v.y >  limitdim) v.y =  limitdim;
  137.     if (v.y < -limitdim) v.y = -limitdim;
  138.     if (v.z >  limitdim) v.z =  limitdim;
  139.     if (v.z < -limitdim) v.z = -limitdim;
  140. }
  141.  
  142. void TDDirectInput::CmOK ()
  143. {
  144.     // INSERT>> 追加コードはここに
  145.     char str[16];
  146.     Motion *m = anim->select;
  147.     if (m != NULL) {
  148.         if (anim->select == anim->camera || anim->select == anim->camera->target) {
  149.             m = anim->camera;
  150.             px->GetText(str,16); m->position.x = atof(str);
  151.             py->GetText(str,16); m->position.y = atof(str);
  152.             pz->GetText(str,16); m->position.z = atof(str);
  153.             limit(m->position);
  154.             Motion *t = anim->camera->target;
  155.             rx->GetText(str,16); t->position.x = atof(str);
  156.             ry->GetText(str,16); t->position.y = atof(str);
  157.             rz->GetText(str,16); t->position.z = atof(str);
  158.             limit(t->position);
  159.         } else {
  160.             px->GetText(str,16); m->position.x = atof(str);
  161.             py->GetText(str,16); m->position.y = atof(str);
  162.             pz->GetText(str,16); m->position.z = atof(str);
  163.             limit(m->position);
  164.             rx->GetText(str,16); m->rotation.x = deg(atof(str));
  165.             ry->GetText(str,16); m->rotation.y = deg(atof(str));
  166.             rz->GetText(str,16); m->rotation.z = deg(atof(str));
  167.             m->rotation = Matrix::m_rot(m->rotation).GetRotation();
  168.             sx->GetText(str,16); m->scale.x    = atof(str);
  169.             sy->GetText(str,16); m->scale.y    = atof(str);
  170.             sz->GetText(str,16); m->scale.z    = atof(str);
  171.  
  172.             int b, e;
  173.             bf->GetText(str,16); b = atoi(str);
  174.             ef->GetText(str,16); e = atoi(str);
  175.             if (BEGIN <= b && b <= e && e <= anim->maxframe
  176.              && (m->motiondata == NULL || b < e)) {
  177.                 m->beginframe = b;
  178.                 m->endframe = e;
  179.             }
  180.         }
  181.     }
  182.     CloseWindow(IDOK);
  183. }
  184.  
  185.  
  186.