Raytracing: Added aspect ratio to POV output - fixes #1315

This commit is contained in:
Yorik van Havre 2013-12-22 20:18:19 -02:00
parent 90a80da1cd
commit 163340392f
3 changed files with 11 additions and 3 deletions

View File

@ -57,7 +57,7 @@ using namespace std;
// angle 45
//}
std::string PovTools::getCamera(const CamDef& Cam)
std::string PovTools::getCamera(const CamDef& Cam, int width, int height)
{
std::stringstream out;
out << "// declares positon and view direction\n" << endl
@ -80,6 +80,7 @@ std::string PovTools::getCamera(const CamDef& Cam)
<< " look_at cam_look_at" << endl
<< " sky cam_sky" << endl
<< " angle cam_angle " << endl
<< " right x*" << width << "/" << height << endl
<< "}"<< endl;
return out.str();
}

View File

@ -75,7 +75,9 @@ class AppRaytracingExport PovTools
{
public:
/// returns the given camera position as povray defines in a file
static std::string getCamera(const CamDef& Cam);
static std::string getCamera(const CamDef& Cam,
int width=800,
int height=600);
/// writes the given camera position as povray defines in a file
static void writeCamera(const char* FileName,

View File

@ -130,8 +130,13 @@ povViewCamera(PyObject *self, PyObject *args)
gp_Vec gpLookAt(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
gp_Vec gpUp(upvec.getValue()[0],upvec.getValue()[1],upvec.getValue()[2]);
// getting image format
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Raytracing");
int width = hGrp->GetInt("OutputWidth", 800);
int height = hGrp->GetInt("OutputHeight", 600);
// call the write method of PovTools....
out = PovTools::getCamera(CamDef(gpPos,gpDir,gpLookAt,gpUp));
out = PovTools::getCamera(CamDef(gpPos,gpDir,gpLookAt,gpUp),width,height);
return Py::new_reference_to(Py::String(out));
} PY_CATCH;