Fixed incorrect camera position when saving images from the command line.

This commit is contained in:
Leonardo Zide 2016-12-07 21:57:53 -08:00
parent 923e7513f1
commit b2b143af99
5 changed files with 12 additions and 6 deletions

View file

@ -386,7 +386,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
else
Frame = FileName;
lcGetActiveModel()->SaveStepImages(Frame, ImageStart != ImageEnd, ImageWidth, ImageHeight, ImageStart, ImageEnd);
lcGetActiveModel()->SaveStepImages(Frame, ImageStart != ImageEnd, true, ImageWidth, ImageHeight, ImageStart, ImageEnd);
}
if (SaveWavefront)

View file

@ -43,6 +43,8 @@ public:
mInputState.x = 0;
mInputState.y = 0;
mInputState.Modifiers = Qt::NoModifier;
mWidth = 1;
mHeight = 1;
mContext = new lcContext();
mDeleteContext = true;
}

View file

@ -1182,7 +1182,7 @@ void lcModel::DrawBackground(lcContext* Context)
glDepthMask(GL_TRUE);
}
void lcModel::SaveStepImages(const QString& BaseName, bool AddStepSuffix, int Width, int Height, lcStep Start, lcStep End)
void lcModel::SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, int Width, int Height, lcStep Start, lcStep End)
{
gMainWindow->mPreviewWidget->MakeCurrent();
lcContext* Context = gMainWindow->mPreviewWidget->mContext;
@ -1195,8 +1195,12 @@ void lcModel::SaveStepImages(const QString& BaseName, bool AddStepSuffix, int Wi
lcStep CurrentStep = mCurrentStep;
lcCamera* Camera = gMainWindow->GetActiveView()->mCamera;
if (Zoom)
ZoomExtents(Camera, (float)Width / (float)Height);
View View(this);
View.SetCamera(gMainWindow->GetActiveView()->mCamera, false);
View.SetCamera(Camera, false);
View.mWidth = Width;
View.mHeight = Height;
View.SetContext(Context);

View file

@ -213,7 +213,7 @@ public:
void GetScene(lcScene& Scene, lcCamera* ViewCamera, bool DrawInterface) const;
void SubModelAddRenderMeshes(lcScene& Scene, const lcMatrix44& WorldMatrix, int DefaultColorIndex, bool Focused, bool Selected) const;
void DrawBackground(lcContext* Context);
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, int Width, int Height, lcStep Start, lcStep End);
void SaveStepImages(const QString& BaseName, bool AddStepSuffix, bool Zoom, int Width, int Height, lcStep Start, lcStep End);
void RayTest(lcObjectRayTest& ObjectRayTest) const;
void BoxTest(lcObjectBoxTest& ObjectBoxTest) const;

View file

@ -1294,7 +1294,7 @@ void Project::ExportHTML()
}
QString StepImageBaseName = QFileInfo(Dir, BaseName + QLatin1String("-%1.png")).absoluteFilePath();
Model->SaveStepImages(StepImageBaseName, true, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
Model->SaveStepImages(StepImageBaseName, true, false, Options.StepImagesWidth, Options.StepImagesHeight, 1, LastStep);
if (Options.PartsListImages)
{
@ -1788,7 +1788,7 @@ void Project::SaveImage()
if (Dialog.mStart != Dialog.mEnd)
Dialog.mFileName = Dialog.mFileName.insert(Dialog.mFileName.length() - Extension.length() - 1, QLatin1String("%1"));
mActiveModel->SaveStepImages(Dialog.mFileName, Dialog.mStart != Dialog.mEnd, Dialog.mWidth, Dialog.mHeight, Dialog.mStart, Dialog.mEnd);
mActiveModel->SaveStepImages(Dialog.mFileName, Dialog.mStart != Dialog.mEnd, false, Dialog.mWidth, Dialog.mHeight, Dialog.mStart, Dialog.mEnd);
}
void Project::UpdatePieceInfo(PieceInfo* Info) const