50 static char THIS_FILE[] = __FILE__;
66 ON_UPDATE_COMMAND_UI(ID_VIEW_ALL, OnUpdateViewAll)
68 ON_UPDATE_COMMAND_UI(ID_VIEW_FRONT, OnUpdateViewFront)
70 ON_UPDATE_COMMAND_UI(ID_VIEW_PERSPECTIVE, OnUpdateViewPerspective)
72 ON_UPDATE_COMMAND_UI(ID_VIEW_SIDE, OnUpdateViewSide)
74 ON_UPDATE_COMMAND_UI(ID_VIEW_TOP, OnUpdateViewTop)
94 ON_UPDATE_COMMAND_UI(ID_GRID_SNAP, OnUpdateGridSnap)
98 ON_COMMAND(ID_EDIT_SELECT_ALL, OnSelectAll)
100 ON_UPDATE_COMMAND_UI(ID_MODIFY_TEXTURE_MAP, OnUpdateTextureMap)
101 ON_UPDATE_COMMAND_UI(ID_MODIFY_MATERIAL, OnUpdateModifyMaterial)
104 ON_UPDATE_COMMAND_UI(ID_MODIFY_UV_MAP, OnUpdateModifyUVMap)
106 ON_UPDATE_COMMAND_UI(ID_VIEW_SHADOWS, OnUpdateViewShadows)
108 ON_UPDATE_COMMAND_UI(ID_VIEW_ANIMATELIGHT, OnUpdateViewAnimatelight)
110 ON_UPDATE_COMMAND_UI(ID_VIEW_BUMPMAPS, OnUpdateViewBumpmaps)
112 ON_UPDATE_COMMAND_UI(ID_VIEW_VERTEXSHADER, OnUpdateViewVertexshader)
114 ON_UPDATE_COMMAND_UI(ID_VIEW_PIXELSHADER, OnUpdateViewPixelshader)
116 ON_UPDATE_COMMAND_UI(ID_VIEW_VISIBLESHADOWS, OnUpdateViewVisibleshadows)
117 ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
118 ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo)
119 ON_COMMAND(ID_EDIT_REDO, OnEditRedo)
120 ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo)
122 ON_UPDATE_COMMAND_UI(ID_PROP_SURFACE, OnUpdateSurfaceProperties)
125 ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
126 ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
127 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
132 static MagicView* magic_view = 0;
134 MagicView::MagicView()
135 : video(0), video_settings(0), screen(0), scene(0),
136 drag_left(false), drag_right(false), grid(0),
137 main_light(0), back_light(0), view_shadows(true), view_bumpmaps(true),
141 is_minimized =
false;
142 is_maximized =
false;
144 view_mode = VIEW_ALL;
178 if (magic_view ==
this)
197 void MagicView::AssertValid()
const
199 CView::AssertValid();
202 void MagicView::Dump(CDumpContext& dc)
const
209 ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(
MagicDoc)));
245 ::Print(
"ERROR: Could not create Screen object.\n");
249 ::Print(
" Created screen object (%d x %d).\n", w, h);
252 ::
Print(
" WARNING: could not set video background color to Black\n");
256 ::Print(
" Established requested video parameters.\n");
257 ::Print(
" ---------------------------------------\n\n");
264 Point light_pos(3e6, 5e6, 4e6);
284 if (seln && selector) {
293 int mins[2] = { 0, 0 };
294 float weights[2] = { 1, 1 };
302 DWORD view_types[] = {
309 for (
int row = 0; row < 2; row++) {
310 for (
int col = 0; col < 2; col++) {
311 int index = 2*row + col;
349 ::Print(
" Could not establish requested video parameters.\n");
350 ::Print(
" -----------------------------------------------\n\n");
362 for (
int row = 0; row < 2; row++) {
363 for (
int col = 0; col < 2; col++) {
364 int index = 2*row + col;
385 for (
int i = 0; i < 4; i++) {
409 for (
int i = 0; i < 4; i++) {
434 for (
int row = 0; row < 2; row++) {
435 for (
int col = 0; col < 2; col++) {
436 int index = 2*row + col;
460 for (
int i = 0; i < 4; i++) {
484 for (
int row = 0; row < 2; row++) {
485 for (
int col = 0; col < 2; col++) {
486 int index = 2*row + col;
501 if (index >= 0 && index < 4) {
534 if (client_old.right - client_old.left !=
536 client_old.bottom - client_old.top !=
577 if (solid &&
scene) {
596 result.x = (LONG) (( p.x - origin.x) / scale);
597 result.y = (LONG) ((-p.y + origin.y) / scale);
623 if (nType == SIZE_MINIMIZED) {
628 else if (nType == SIZE_MAXIMIZED) {
634 else if (nType == SIZE_RESTORED) {
664 double s = sin(timeGetTime() * 0.001);
665 double c = cos(timeGetTime() * 0.001);
669 Point light_pos(3e6*s, 5e6*c, 4e6*s);
688 ::Print(
"ERROR: Screen refresh failed.\n");
699 if (editor && solid) {
780 CFileDialog ofd(TRUE,
"mag");
782 ofd.m_ofn.lpstrFilter =
"All 3D Files\0*.mag; *.obj; *.3ds\0Magic Files (*.mag)\0*.mag\0Wavefront/OBJ Files (*.obj)\0*.obj\0003DS MAX Files (*.3ds)\0*.3ds\0\0";
783 ofd.m_ofn.lpstrFile = filename;
784 ofd.m_ofn.nMaxFile =
sizeof(filename);
786 if (ofd.DoModal() != IDOK)
790 sprintf_s(mag_name,
"%s", ofd.GetFileName().GetBuffer(0));
795 if (pDoc->ImportFile(mag_name)) {
797 pDoc->SetModifiedFlag(TRUE);
798 pDoc->UpdateAllViews(
this);
807 CFileDialog ofd(FALSE,
"mag");
809 ofd.m_ofn.lpstrFilter =
"All 3D Files\0*.mag; *.obj; *.3ds\0Magic Files (*.mag)\0*.mag\0Wavefront/OBJ Files (*.obj)\0*.obj\0003DS MAX Files (*.3ds)\0*.3ds\0\0";
810 ofd.m_ofn.lpstrFile = filename;
811 ofd.m_ofn.nMaxFile =
sizeof(filename);
813 if (ofd.DoModal() != IDOK)
817 sprintf_s(mag_name,
"%s", ofd.GetFileName().GetBuffer(0));
822 if (pDoc->ExportFile(mag_name)) {
823 pDoc->SetModifiedFlag(FALSE);
824 pDoc->UpdateAllViews(
this);
839 pCmdUI->Enable(solid && solid->
GetModel());
847 if (dlg.DoModal() == IDOK) {
867 doc->SetModifiedFlag(TRUE);
868 doc->UpdateAllViews(
this);
893 pCmdUI->Enable(solid && solid->
GetModel());
967 if (nFlags & MK_CONTROL)
976 else if (mv && selector) {
979 if (nFlags & MK_CONTROL)
1000 else if (selector && selector->
IsActive())
1081 view->
MoveBy(offset.x, offset.y);
1103 else if (selector && selector->
IsActive()) {
1111 CPoint mouse =
LPtoWP(point);
1114 int nv = seln ? seln->
GetVerts().size() : 0;
1118 sprintf_s(xy,
"(%05d,%05d) Verts:%d Polys:%d", mouse.x, mouse.y, nv, np);
1120 sprintf_s(xy,
"(%05d,%05d)", mouse.x, mouse.y);
1135 double len = pos.
length();
1173 for (
int i = 0; i < 4; i++) {
1184 for (
int i = 0; i < 4; i++) {
1196 for (
int i = 0; i < 4; i++) {
1243 CColorDialog chooser(crgb);
1245 if (chooser.DoModal() == IDOK) {
1246 crgb = chooser.GetColor();
1263 else if (solid && selector) {
1278 else if (solid && selector) {
1293 else if (solid && selector) {
1388 pDoc->SetModifiedFlag(TRUE);
1389 pDoc->UpdateAllViews(
this);
1397 pCmdUI->Enable(TRUE);
1398 pCmdUI->SetText(CString(
"Undo ") + pDoc->
GetUndoName() + CString(
"\tCtrl+Z"));
1401 pCmdUI->Enable(FALSE);
1402 pCmdUI->SetText(
"Can't Undo\tCtrl+Z");
1421 pDoc->SetModifiedFlag(TRUE);
1422 pDoc->UpdateAllViews(
this);
1430 pCmdUI->Enable(TRUE);
1431 pCmdUI->SetText(CString(
"Redo ") + pDoc->
GetRedoName() + CString(
"\tCtrl+Y"));
1434 pCmdUI->Enable(FALSE);
1435 pCmdUI->SetText(
"Can't Redo");