parented linked data lamps made the export crash.

fix for two bugs reported by Diego Pino, an endian issue with vertex colors,
and the plugin code didn't export multiple colorbands correctly.

Updated the ortho camera export code for the new Blender ortho camera model.
This commit is contained in:
Alfredo de Greef 2005-05-09 03:46:21 +00:00
parent 09fb5d6b8d
commit e9545cb9cd
3 changed files with 26 additions and 31 deletions

@ -3127,9 +3127,10 @@ void RE_rotateBlenderScene(void)
yafray only needs to know about one, the rest can be instanciated. yafray only needs to know about one, the rest can be instanciated.
The dupliMtx list is used for this purpose */ The dupliMtx list is used for this purpose */
if (R.r.renderer==R_YAFRAY) { if (R.r.renderer==R_YAFRAY) {
/* Special case, parent object dupli's: ignore lattices & empty's */ /* Special case, parent object dupli's: ignore if object itself is lamp or parent is lattice or empty */
if (ob->parent) { if (ob->parent) {
if ((ob->parent->type!=OB_EMPTY) && (ob->parent->type!=OB_LATTICE) && YAF_objectKnownData(ob)) if ((ob->type!=OB_LAMP) && (ob->parent->type!=OB_EMPTY) &&
(ob->parent->type!=OB_LATTICE) && YAF_objectKnownData(ob))
printf("From parent: Added dupli matrix for linked data object %s\n", ob->id.name); printf("From parent: Added dupli matrix for linked data object %s\n", ob->id.name);
else else
init_render_object(ob); init_render_object(ob);

@ -1191,19 +1191,15 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_li
// since Blender seems to need vcols when uvs are used, for yafray only export when the material actually uses vcols // since Blender seems to need vcols when uvs are used, for yafray only export when the material actually uses vcols
if ((EXPORT_VCOL) && (vlr->vcol)) { if ((EXPORT_VCOL) && (vlr->vcol)) {
// vertex colors // vertex colors
float vr, vg, vb; unsigned char* pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui1]);
vr = ((vlr->vcol[ui1] >> 24) & 255)/255.0; ostr << " vcol_a_r=\"" << (float)pt[3]/255.f << "\" vcol_a_g=\"" << (float)pt[2]/255.f
vg = ((vlr->vcol[ui1] >> 16) & 255)/255.0; << "\" vcol_a_b=\"" << (float)pt[1]/255.f << "\"";
vb = ((vlr->vcol[ui1] >> 8) & 255)/255.0; pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui2]);
ostr << " vcol_a_r=\"" << vr << "\" vcol_a_g=\"" << vg << "\" vcol_a_b=\"" << vb << "\""; ostr << " vcol_b_r=\"" << (float)pt[3]/255.f << "\" vcol_b_g=\"" << (float)pt[2]/255.f
vr = ((vlr->vcol[ui2] >> 24) & 255)/255.0; << "\" vcol_b_b=\"" << (float)pt[1]/255.f << "\"";
vg = ((vlr->vcol[ui2] >> 16) & 255)/255.0; pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui3]);
vb = ((vlr->vcol[ui2] >> 8) & 255)/255.0; ostr << " vcol_c_r=\"" << (float)pt[3]/255.f << "\" vcol_c_g=\"" << (float)pt[2]/255.f
ostr << " vcol_b_r=\"" << vr << "\" vcol_b_g=\"" << vg << "\" vcol_b_b=\"" << vb << "\""; << "\" vcol_c_b=\"" << (float)pt[1]/255.f << "\"";
vr = ((vlr->vcol[ui3] >> 24) & 255)/255.0;
vg = ((vlr->vcol[ui3] >> 16) & 255)/255.0;
vb = ((vlr->vcol[ui3] >> 8) & 255)/255.0;
ostr << " vcol_c_r=\"" << vr << "\" vcol_c_g=\"" << vg << "\" vcol_c_b=\"" << vb << "\"";
} }
ostr << " shader_name=\"" << fmatname << "\" />\n"; ostr << " shader_name=\"" << fmatname << "\" />\n";
@ -1535,8 +1531,10 @@ void yafrayFileRender_t::writeCamera()
ostr << "\" aspect_ratio=\"" << R.ycor << "\""; ostr << "\" aspect_ratio=\"" << R.ycor << "\"";
// dof params, only valid for real camera // dof params, only valid for real camera
float fdist = 1; // only changes for ortho
if (maincam_obj->type==OB_CAMERA) { if (maincam_obj->type==OB_CAMERA) {
Camera* cam = (Camera*)maincam_obj->data; Camera* cam = (Camera*)maincam_obj->data;
if (R.r.mode & R_ORTHO) fdist = cam->ortho_scale*(mainCamLens/32.f);
ostr << "\n\tdof_distance=\"" << cam->YF_dofdist << "\""; ostr << "\n\tdof_distance=\"" << cam->YF_dofdist << "\"";
ostr << " aperture=\"" << cam->YF_aperture << "\""; ostr << " aperture=\"" << cam->YF_aperture << "\"";
string st = "on"; string st = "on";
@ -1573,8 +1571,6 @@ void yafrayFileRender_t::writeCamera()
ostr << "\t<from x=\"" << maincam_obj->obmat[3][0] << "\"" ostr << "\t<from x=\"" << maincam_obj->obmat[3][0] << "\""
<< " y=\"" << maincam_obj->obmat[3][1] << "\"" << " y=\"" << maincam_obj->obmat[3][1] << "\""
<< " z=\"" << maincam_obj->obmat[3][2] << "\" />\n"; << " z=\"" << maincam_obj->obmat[3][2] << "\" />\n";
float fdist = fabs(R.viewmat[3][2]);
if (R.r.mode & R_ORTHO) fdist *= 0.01f;
ostr << "\t<to x=\"" << maincam_obj->obmat[3][0] - fdist * R.viewmat[0][2] ostr << "\t<to x=\"" << maincam_obj->obmat[3][0] - fdist * R.viewmat[0][2]
<< "\" y=\"" << maincam_obj->obmat[3][1] - fdist * R.viewmat[1][2] << "\" y=\"" << maincam_obj->obmat[3][1] - fdist * R.viewmat[1][2]
<< "\" z=\"" << maincam_obj->obmat[3][2] - fdist * R.viewmat[2][2] << "\" />\n"; << "\" z=\"" << maincam_obj->obmat[3][2] - fdist * R.viewmat[2][2] << "\" />\n";

@ -363,6 +363,9 @@ void yafrayPluginRender_t::writeTextures()
for (map<string, MTex*>::const_iterator blendtex=used_textures.begin(); for (map<string, MTex*>::const_iterator blendtex=used_textures.begin();
blendtex!=used_textures.end();++blendtex) blendtex!=used_textures.end();++blendtex)
{ {
lparams.clear();
params.clear();
MTex* mtex = blendtex->second; MTex* mtex = blendtex->second;
Tex* tex = mtex->tex; Tex* tex = mtex->tex;
// name is image name instead of texture name when type is image (see TEX_IMAGE case below) // name is image name instead of texture name when type is image (see TEX_IMAGE case below)
@ -549,6 +552,7 @@ void yafrayPluginRender_t::writeTextures()
ColorBand* cb = tex->coba; ColorBand* cb = tex->coba;
if (cb) if (cb)
{ {
lparams.clear();
params.clear(); params.clear();
params["type"]=yafray::parameter_t("colorband"); params["type"]=yafray::parameter_t("colorband");
params["name"]=yafray::parameter_t(blendtex->first + "_coba"); params["name"]=yafray::parameter_t(blendtex->first + "_coba");
@ -1007,18 +1011,12 @@ void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol, VlakRen *vlr, b
ui2 = (ui2+2) & 3; ui2 = (ui2+2) & 3;
ui3 = (ui3+2) & 3; ui3 = (ui3+2) & 3;
} }
float vr = ((vlr->vcol[ui1] >> 24) & 255)/255.0; unsigned char* pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui1]);
float vg = ((vlr->vcol[ui1] >> 16) & 255)/255.0; vcol.push_back((float)pt[3]/255.f); vcol.push_back((float)pt[2]/255.f); vcol.push_back((float)pt[1]/255.f);
float vb = ((vlr->vcol[ui1] >> 8) & 255)/255.0; pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui2]);
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb); vcol.push_back((float)pt[3]/255.f); vcol.push_back((float)pt[2]/255.f); vcol.push_back((float)pt[1]/255.f);
vr = ((vlr->vcol[ui2] >> 24) & 255)/255.0; pt = reinterpret_cast<unsigned char*>(&vlr->vcol[ui3]);
vg = ((vlr->vcol[ui2] >> 16) & 255)/255.0; vcol.push_back((float)pt[3]/255.f); vcol.push_back((float)pt[2]/255.f); vcol.push_back((float)pt[1]/255.f);
vb = ((vlr->vcol[ui2] >> 8) & 255)/255.0;
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb);
vr = ((vlr->vcol[ui3] >> 24) & 255)/255.0;
vg = ((vlr->vcol[ui3] >> 16) & 255)/255.0;
vb = ((vlr->vcol[ui3] >> 8) & 255)/255.0;
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb);
} }
else else
{ {
@ -1514,8 +1512,10 @@ void yafrayPluginRender_t::writeCamera()
params["aspect_ratio"] = yafray::parameter_t(R.ycor); params["aspect_ratio"] = yafray::parameter_t(R.ycor);
// dof params, only valid for real camera // dof params, only valid for real camera
float fdist = 1; // only changes for ortho
if (maincam_obj->type==OB_CAMERA) { if (maincam_obj->type==OB_CAMERA) {
Camera* cam = (Camera*)maincam_obj->data; Camera* cam = (Camera*)maincam_obj->data;
if (R.r.mode & R_ORTHO) fdist = cam->ortho_scale*(mainCamLens/32.f);
params["dof_distance"] = yafray::parameter_t(cam->YF_dofdist); params["dof_distance"] = yafray::parameter_t(cam->YF_dofdist);
params["aperture"] = yafray::parameter_t(cam->YF_aperture); params["aperture"] = yafray::parameter_t(cam->YF_aperture);
if (cam->flag & CAM_YF_NO_QMC) if (cam->flag & CAM_YF_NO_QMC)
@ -1548,8 +1548,6 @@ void yafrayPluginRender_t::writeCamera()
params["from"]=yafray::parameter_t( params["from"]=yafray::parameter_t(
yafray::point3d_t(maincam_obj->obmat[3][0], maincam_obj->obmat[3][1], maincam_obj->obmat[3][2])); yafray::point3d_t(maincam_obj->obmat[3][0], maincam_obj->obmat[3][1], maincam_obj->obmat[3][2]));
float fdist = fabs(R.viewmat[3][2]);
if (R.r.mode & R_ORTHO) fdist *= 0.01f;
params["to"]=yafray::parameter_t( params["to"]=yafray::parameter_t(
yafray::point3d_t(maincam_obj->obmat[3][0] - fdist * R.viewmat[0][2], yafray::point3d_t(maincam_obj->obmat[3][0] - fdist * R.viewmat[0][2],
maincam_obj->obmat[3][1] - fdist * R.viewmat[1][2], maincam_obj->obmat[3][1] - fdist * R.viewmat[1][2],