www.pudn.com > 3DEDITOR.rar > 3DEDITORDOC.CPP
// 3DEditorDoc.cpp : implementation of the CMy3DEditorDoc class
//
#include "stdafx.h"
#include "3DEditor.h"
#include "3DEditorDoc.h"
#include "DlgImport.h"
#include "ImportProgress.h"
#include "3DEditorView.h"
#include "DlgMaterial.h"
#include "DlgMapping.h"
#include "DlgProperties.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CStatusBar *statbar;
char str[256]="",docpath[256]="";
/////////////////////////////////////////////////////////////////////////////
// CMy3DEditorDoc
IMPLEMENT_DYNCREATE(CMy3DEditorDoc, CDocument)
BEGIN_MESSAGE_MAP(CMy3DEditorDoc, CDocument)
//{{AFX_MSG_MAP(CMy3DEditorDoc)
ON_COMMAND(ID_FILE_IMPORT, OnFileImport)
ON_COMMAND(ID_PROPERTIES, OnProperties)
ON_UPDATE_COMMAND_UI(ID_PROPERTIES, OnUpdateProperties)
ON_COMMAND(ID_MAPPING, OnMapping)
ON_UPDATE_COMMAND_UI(ID_MAPPING, OnUpdateMapping)
ON_COMMAND(ID_EDIT_BACKGROUND_BLACK, OnEditBackgroundBlack)
ON_UPDATE_COMMAND_UI(ID_EDIT_BACKGROUND_BLACK, OnUpdateEditBackgroundBlack)
ON_COMMAND(ID_EDIT_BACKGROUND_CUSTOM, OnEditBackgroundCustom)
ON_UPDATE_COMMAND_UI(ID_EDIT_BACKGROUND_CUSTOM, OnUpdateEditBackgroundCustom)
ON_COMMAND(ID_EDIT_BACKGROUND_WHITE, OnEditBackgroundWhite)
ON_UPDATE_COMMAND_UI(ID_EDIT_BACKGROUND_WHITE, OnUpdateEditBackgroundWhite)
ON_COMMAND(ID_EDIT_LIGHTS_CONSTANT, OnEditLightsConstant)
ON_UPDATE_COMMAND_UI(ID_EDIT_LIGHTS_CONSTANT, OnUpdateEditLightsConstant)
ON_COMMAND(ID_EDIT_LIGHTS_HEADLIGHT, OnEditLightsHeadlight)
ON_UPDATE_COMMAND_UI(ID_EDIT_LIGHTS_HEADLIGHT, OnUpdateEditLightsHeadlight)
ON_COMMAND(ID_EDIT_LIGHTS_SCENE, OnEditLightsScene)
ON_UPDATE_COMMAND_UI(ID_EDIT_LIGHTS_SCENE, OnUpdateEditLightsScene)
ON_COMMAND(ID_EDIT_AMBIENTLIGHT, OnEditAmbientlight)
ON_COMMAND(ID_TEXTINTERP, OnTextinterp)
ON_UPDATE_COMMAND_UI(ID_TEXTINTERP, OnUpdateTextinterp)
ON_COMMAND(IDM_BACKCULL, OnBackcull)
ON_UPDATE_COMMAND_UI(IDM_BACKCULL, OnUpdateBackcull)
ON_COMMAND(ID_FILE_EXPORT, OnFileExport)
ON_COMMAND(ID_INVERTNORMALS, OnInvertnormals)
ON_UPDATE_COMMAND_UI(ID_INVERTNORMALS, OnUpdateInvertnormals)
ON_COMMAND(ID_MATERIALS, OnMaterials)
ON_UPDATE_COMMAND_UI(ID_MATERIALS, OnUpdateMaterials)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMy3DEditorDoc construction/destruction
CMy3DEditorDoc::CMy3DEditorDoc()
{
// TODO: add one-time construction code here
bboxC.Vec(0,0,0);
bbox1.Vec(-1,-1,-1);
bbox2.Vec(1,1,1);
bboxdiag=2.0;
dlgprop=0;
dlgmat=0;
dlgmap=0;
selobj=0;
selface=-1;
}
CMy3DEditorDoc::~CMy3DEditorDoc()
{
}
BOOL CMy3DEditorDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMy3DEditorDoc serialization
void CMy3DEditorDoc::Serialize(CArchive& ar)
{
int i,j,k;
char c;
unsigned short s;
ChunkFile cf(ar.GetFile());
if (ar.IsStoring())
{
cf.Open(MAGIC_NUMBER);
cf.Open(1);
cf.Write(&bbox1, sizeof(vector));
cf.Write(&bbox2, sizeof(vector));
c=headlight;
cf.Write(&c,1);
c=backface;
cf.Write(&c,1);
c=textinterp;
cf.Write(&c,1);
cf.Write(&amblight,sizeof(vector));
cf.Write(&background,sizeof(vector));
cf.Open(2);
cf.Write(&ncamlib, sizeof(int));
for( i=0;iSerialize(cf,true);
ncoef+=o->ncoef;
o=o->next;
}
cf.Close();
cf.Close();
cf.Open(6);
cf.Write(&ncoef, sizeof(int));
float d,dm;
object *om;
int e,em;
int im;
do
{
i=0;
om=0;
dm=0;
o=obj0;
while(o)
{
for( e=0;enelem;e++ )
{
d=0;
if (o->elem[e].ncoef)
if (o->elem[e].cur_coef==0)
d=o->elem[e].coef->weight;
else if (o->elem[e].cur_coef->next)
d=o->elem[e].cur_coef->next->weight;
if (d>dm)
{
dm=d;
om=o;
em=e;
im=i;
}
}
o=o->next;
i++;
}
if(om!=0)
{
cf.Write(&im, sizeof(int));
cf.Write(&em, sizeof(int));
if(om->elem[em].cur_coef==0)
om->elem[em].cur_coef=om->elem[em].coef;
else
om->elem[em].cur_coef=om->elem[em].cur_coef->next;
if(om->nv>65535 || om->nf>65535)
{
cf.Write(om->elem[em].cur_coef,sizeof(ctlist)-sizeof(int *)-2*sizeof(ctlist *));
cf.Write(om->elem[em].cur_coef->fv,sizeof(int)*om->elem[em].cur_coef->nfv);
}
else
{
cf.Write(om->elem[em].cur_coef,sizeof(ctlist)-sizeof(int *)-2*sizeof(ctlist *)-10*sizeof(int));
s=om->elem[em].cur_coef->vert1;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->vert2;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->vert3;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->vert4;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face1;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face2;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face3;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face4;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face5;
cf.Write(&s,sizeof(unsigned short));
s=om->elem[em].cur_coef->face6;
cf.Write(&s,sizeof(unsigned short));
for( i=0;ielem[em].cur_coef->nfv;i++ )
{
s=om->elem[em].cur_coef->fv[i];
cf.Write(&s,sizeof(unsigned short));
}
}
}
} while(om!=0);
cf.Close();
o=obj0;
while(o)
{
for( e=0;enelem;e++ )
{
o->elem[e].cur_coef=0;
i=o->elem[e].cur_ncoef;
o->elem[e].cur_ncoef=-1;
while( o->elem[e].cur_ncoefAddCoef(e);
}
o=o->next;
}
cf.Close();
}
else
{
cf.ReadHeader();
if(cf.Id!=MAGIC_NUMBER)
return;
while(!cf.End())
{
cf.ReadHeader();
switch(cf.Id)
{
case 1:
cf.Read(&bbox1,sizeof(vector));
cf.Read(&bbox2,sizeof(vector));
cf.Read(&c,1);
headlight=c;
cf.Read(&c,1);
backface=c;
cf.Read(&c,1);
textinterp=c;
cf.Read(&amblight,sizeof(vector));
cf.Read(&background,sizeof(vector));
while(!cf.End())
{
cf.ReadHeader();
switch(cf.Id)
{
case 2:
cf.Read(&ncamlib, sizeof(int));
if(ncamlib)
{
camlib=new camera[ncamlib];
for( i=0;inext=obj0;
obj0=o;
o->Serialize(cf, false);
o->cur_ncoef=-1;
o->ncoef=0;
for( j=0;jnelem;j++ )
{
o->cur_ncoef=-1;
o->ncoef+=o->elem[j].ncoef;
o->elem[j].cur_coef=0;
}
}
break;
}
cf.Next();
}
break;
case 6:
{
cf.Read(&ncoef, sizeof(int));
int im, em;
object **io=new object *[nobj];
int n_ele=0;
object *o=obj0;
for(i=nobj-1;i>=0;i--)
{
io[i]=o;
n_ele+=o->nelem;
o=o->next;
}
int j,p=0;
int *n_iant=new int[n_ele];
for(i=0;inelem;j++)
{
n_iant[p++]=io[i]->elem[j].cur_ncoef;
io[i]->elem[j].cur_ncoef=-1;
io[i]->elem[j].ncoef=0;
}
for(i=0; inv>65535 || io[im]->nf>65535)
{
cf.Read(c,sizeof(ctlist)-sizeof(int *)-2*sizeof(ctlist *));
c->fv=new int[c->nfv];
cf.Read(c->fv,sizeof(int)*c->nfv);
}
else
{
cf.Read(c,sizeof(ctlist)-sizeof(int *)-2*sizeof(ctlist *)-10*sizeof(int));
cf.Read(&s,sizeof(unsigned short));
c->vert1=s;
cf.Read(&s,sizeof(unsigned short));
c->vert2=s;
cf.Read(&s,sizeof(unsigned short));
c->vert3=s;
cf.Read(&s,sizeof(unsigned short));
c->vert4=s;
cf.Read(&s,sizeof(unsigned short));
c->face1=s;
cf.Read(&s,sizeof(unsigned short));
c->face2=s;
cf.Read(&s,sizeof(unsigned short));
c->face3=s;
cf.Read(&s,sizeof(unsigned short));
c->face4=s;
cf.Read(&s,sizeof(unsigned short));
c->face5=s;
cf.Read(&s,sizeof(unsigned short));
c->face6=s;
c->fv=new int[c->nfv];
for( k=0;knfv;k++ )
{
cf.Read(&s,sizeof(unsigned short));
c->fv[k]=s;
}
}
c->prev=io[im]->elem[em].cur_coef;
if (io[im]->elem[em].cur_coef)
io[im]->elem[em].cur_coef->next=c;
else io[im]->elem[em].coef=c;
io[im]->elem[em].ncoef++;
io[im]->AddCoef(em);
}
p=0;
for(i=0;inelem;j++)
{
while(io[i]->elem[j].cur_ncoef!=n_iant[p])
io[i]->DelCoef(j);
p++;
}
delete io;
delete n_iant;
}
break;
}
cf.Next();
}
ComputeBBoxes();
CFile* fp = ar.GetFile();
strcpy(docpath,(char *)(LPCSTR)fp->GetFilePath());
if (strrchr(docpath,'\\'))
*strrchr(docpath,'\\')=0;
else docpath[0]=0;
load_images();
}
}
/////////////////////////////////////////////////////////////////////////////
// CMy3DEditorDoc diagnostics
#ifdef _DEBUG
void CMy3DEditorDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMy3DEditorDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy3DEditorDoc commands
void CMy3DEditorDoc::OnFileImport()
{
// TODO: Add your command handler code here
CString s;
s.LoadString(IDS_FD_3DS3D);
CFileDialog fd(TRUE,0,0,OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,s);
if (fd.DoModal()==IDOK)
{
DlgImport di;
di.doc=this;
strcpy(di.filename,(char *)(LPCSTR)fd.GetPathName());
char *c=strrchr(di.filename,'.');
if (c==0 || stricmp(c+1,"3d"))
if (di.DoModal()==IDOK)
{
ComputeBBoxes();
SetModifiedFlag();
ImportProgress ip;
ip.doc=this;
ip.DoModal();
BeginWaitCursor();
CString s;
s.LoadString(IDS_LOADTEXT);
statbar->SetPaneText(0,s);
statbar->UpdateWindow();
docpath[0]=0;
load_images();
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(pos);
if (((CMy3DEditorView *)pView)->cur_cam==-1)
if (ncamlib)
{
((CMy3DEditorView *)pView)->LookAt(camlib[0].Vp,camlib[0].Lp);
((CMy3DEditorView *)pView)->cur_cam=0;
}
else ((CMy3DEditorView *)pView)->OnViewViewall();
}
EndWaitCursor();
statbar->SetPaneText(0,"");
}
else ;
else
{
FILE *fp=fopen(di.filename,"rt");
if (fp)
{
BeginWaitCursor();
int a,i,j,k,t;
object *o=new object;
nobj++;
o->next=obj0;
obj0=o;
o->textcoord=0;
strcpy(o->name,(char *)(LPCSTR)fd.GetFileName());
fscanf(fp,"%i",&o->nv);
o->vt=new vtlist *[o->nv];
memset(o->vt,0,sizeof(vtlist *)*o->nv);
for( a=0;anv;a++ )
{
o->vt[a]=new vtlist;
fscanf(fp,"%f %f %f",&o->vt[a]->pos.x,&o->vt[a]->pos.y,&o->vt[a]->pos.z);
}
fscanf(fp,"%i",&o->nf);
o->ft=new ftlist *[o->nf];
memset(o->ft,0,sizeof(ftlist *)*o->nf);
for( a=0;anf;a++ )
{
o->ft[a]=new ftlist;
fscanf(fp,"%i %i %i %i",&t,&i,&j,&k);
o->ft[a]->lv[0]=o->vt[i];
o->ft[a]->lv[1]=o->vt[j];
o->ft[a]->lv[2]=o->vt[k];
o->ft[a]->material=0;
}
ComputeBBoxes();
SetModifiedFlag();
ImportProgress ip;
ip.doc=this;
ip.DoModal();
if (obj0->next==0)
{
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(pos);
((CMy3DEditorView *)pView)->OnViewViewall();
}
}
EndWaitCursor();
}
}
}
}
void CMy3DEditorDoc::OnProperties()
{
// TODO: Add your command handler code here
if (dlgprop)
((DlgProperties *)dlgprop)->Close();
else
{
dlgprop=new DlgProperties;
((DlgProperties *)dlgprop)->doc=this;
dlgprop->Create(IDD_PROPERTIES);
CString s;
s.LoadString(IDS_DETAIL);
sprintf(str,s,GetTitle());
dlgprop->SetWindowText(str);
dlgprop->ShowWindow(SW_SHOW);
}
}
void CMy3DEditorDoc::OnUpdateProperties(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(obj0!=0);
pCmdUI->SetCheck(dlgprop!=0);
}
void CMy3DEditorDoc::OnMapping()
{
// TODO: Add your command handler code here
if (dlgmap)
((DlgMapping *)dlgmap)->Close();
else
{
if (CheckMapping()==0)
return;
dlgmap=new DlgMapping;
((DlgMapping *)dlgmap)->doc=this;
dlgmap->Create(IDD_MAPPING);
CString s;
s.LoadString(IDS_MAPPING);
sprintf(str,s,GetTitle());
dlgmap->SetWindowText(str);
dlgmap->ShowWindow(SW_SHOW);
}
}
void CMy3DEditorDoc::OnUpdateMapping(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(nmatlib!=0 && obj0!=0);
pCmdUI->SetCheck(dlgmap!=0);
}
int CMy3DEditorDoc::CheckMapping()
{
object *o=obj0;
while(o)
{
int i;
for( i=0;inv;i++ )
if (fabs(o->vt[i]->tx[0])>1.0f || fabs(o->vt[i]->tx[1])>1.0f)
break;
if (inv)
break;
o=o->next;
}
if (o)
{
CString s;
s.LoadString(IDS_MAPPINGTILE);
if (IDNO==AfxMessageBox(s,MB_YESNO))
return 0;
o=obj0;
while(o)
{
int i;
for( i=0;inv;i++ )
{
o->vt[i]->tx[0]=(float)fmod(fabs(o->vt[i]->tx[0]),1.0);
o->vt[i]->tx[1]=-(float)fmod(fabs(o->vt[i]->tx[1]),1.0);
}
o=o->next;
}
UpdateAllViews(0);
}
return 1;
}
void CMy3DEditorDoc::OnEditBackgroundBlack()
{
// TODO: Add your command handler code here
background.Vec(0,0,0);
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateEditBackgroundBlack(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(background.x==0 && background.y==0 && background.z==0);
}
void CMy3DEditorDoc::OnEditBackgroundCustom()
{
// TODO: Add your command handler code here
COLORREF c=RGB((int)(background.x*255),(int)(background.y*255),(int)(background.z*255));
CColorDialog cd(c);
if (cd.DoModal()==IDOK)
{
c=cd.GetColor();
background.x=(float)GetRValue(c)/255;
background.y=(float)GetGValue(c)/255;
background.z=(float)GetBValue(c)/255;
UpdateAllViews(0);
SetModifiedFlag();
}
}
void CMy3DEditorDoc::OnUpdateEditBackgroundCustom(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio( (background.x>0 && background.x<1) ||
(background.y>0 && background.y<1) ||
(background.z>0 && background.z<1) );
}
void CMy3DEditorDoc::OnEditBackgroundWhite()
{
// TODO: Add your command handler code here
background.Vec(1,1,1);
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateEditBackgroundWhite(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(background.x==1 && background.y==1 && background.z==1);
}
void CMy3DEditorDoc::OnEditLightsConstant()
{
// TODO: Add your command handler code here
headlight=-1;
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateEditLightsConstant(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(headlight==-1);
}
void CMy3DEditorDoc::OnEditLightsHeadlight()
{
// TODO: Add your command handler code here
headlight=1;
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateEditLightsHeadlight(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(headlight==1);
}
void CMy3DEditorDoc::OnEditLightsScene()
{
// TODO: Add your command handler code here
headlight=0;
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateEditLightsScene(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetRadio(headlight==0);
}
void CMy3DEditorDoc::OnEditAmbientlight()
{
// TODO: Add your command handler code here
COLORREF c=RGB((int)(amblight.x*255),(int)(amblight.y*255),(int)(amblight.z*255));
CColorDialog cd(c);
if (cd.DoModal()==IDOK)
{
c=cd.GetColor();
amblight.x=(float)GetRValue(c)/255;
amblight.y=(float)GetGValue(c)/255;
amblight.z=(float)GetBValue(c)/255;
UpdateAllViews(0);
SetModifiedFlag();
}
}
void CMy3DEditorDoc::OnTextinterp()
{
// TODO: Add your command handler code here
textinterp=!textinterp;
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateTextinterp(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(textinterp);
}
void CMy3DEditorDoc::OnBackcull()
{
// TODO: Add your command handler code here
backface=!backface;
UpdateAllViews(0);
SetModifiedFlag();
}
void CMy3DEditorDoc::OnUpdateBackcull(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->SetCheck(backface);
}
void CMy3DEditorDoc::OnCloseDocument()
{
// TODO: Add your specialized code here and/or call the base class
if (dlgprop)
((DlgProperties *)dlgprop)->Close();
if (dlgmat)
((DlgMaterial *)dlgmat)->Close();
if (dlgmap)
((DlgMapping *)dlgmap)->Close();
CDocument::OnCloseDocument();
}
void CMy3DEditorDoc::OnFileExport()
{
// TODO: Add your command handler code here
CString s;
s.LoadString(IDS_FD_3DS);
CFileDialog fd(FALSE,"3ds",0,OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,s);
if(fd.DoModal()==IDOK)
{
BeginWaitCursor();
if (export((char *)(LPCSTR)fd.GetPathName())==0)
AfxMessageBox(IDS_ERRORSAVING,MB_OK|MB_ICONEXCLAMATION);
EndWaitCursor();
}
}
void CMy3DEditorDoc::OnInvertnormals()
{
// TODO: Add your command handler code here
BeginWaitCursor();
selobj->invert_normal(selobj->ft[selobj->elem[selface].elem]);
UpdateAllViews(0);
EndWaitCursor();
}
void CMy3DEditorDoc::OnUpdateInvertnormals(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(selobj!=0 && selface!=-1);
}
BOOL CMy3DEditorDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
POSITION pos = GetFirstViewPosition();
while (pos != NULL)
{
CView* pView = GetNextView(pos);
if (ncamlib)
{
((CMy3DEditorView *)pView)->LookAt(camlib[0].Vp,camlib[0].Lp);
((CMy3DEditorView *)pView)->cur_cam=0;
}
else ((CMy3DEditorView *)pView)->OnViewViewall();
}
CString s;
s.LoadString(IDS_DETAIL);
sprintf(str,s,GetTitle());
if (dlgprop)
dlgprop->SetWindowText(str);
s.LoadString(IDS_MATERIAL);
sprintf(str,s,GetTitle());
if (dlgmat)
dlgmat->SetWindowText(str);
s.LoadString(IDS_MAPPING);
sprintf(str,s,GetTitle());
if (dlgmap)
dlgmap->SetWindowText(str);
return TRUE;
}
BOOL CMy3DEditorDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
BOOL ret=CDocument::OnSaveDocument(lpszPathName);
CString s;
s.LoadString(IDS_DETAIL);
sprintf(str,s,GetTitle());
if (dlgprop)
dlgprop->SetWindowText(str);
s.LoadString(IDS_MATERIAL);
sprintf(str,s,GetTitle());
if (dlgmat)
dlgmat->SetWindowText(str);
s.LoadString(IDS_MAPPING);
sprintf(str,s,GetTitle());
if (dlgmap)
dlgmap->SetWindowText(str);
return ret;
}
void CMy3DEditorDoc::OnMaterials()
{
// TODO: Add your command handler code here
if (dlgmat)
((DlgMaterial *)dlgmat)->Close();
else
{
dlgmat=new DlgMaterial;
((DlgMaterial *)dlgmat)->doc=this;
dlgmat->Create(IDD_MATERIAL);
CString s;
s.LoadString(IDS_MATERIAL);
sprintf(str,s,GetTitle());
dlgmat->SetWindowText(str);
dlgmat->ShowWindow(SW_SHOW);
}
}
void CMy3DEditorDoc::OnUpdateMaterials(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(nmatlib!=0);
pCmdUI->SetCheck(dlgmat!=0);
}