70
// find object by name in global scene (+'OB'!)
71
Object* yafrayRender_t::findObject(const char* name)
73
Base* bs = (Base*)G.scene->base.first;
75
Object* obj = bs->object;
76
if (!strcmp(name, obj->id.name)) return obj;
82
71
// gets all unique face materials & textures,
83
72
// and sorts the facelist rejecting anything that is not a quad or tri,
84
73
// as well as associating them again with the original Object.
79
// Blender does not include object which have total 0 alpha materials,
80
// however, the objects might have been included in the dupliMtx list,
81
// so this will cause a 'Duplilist non-empty...' error after going through the renderlist.
82
// To solve this, keep track of all render objects included sofar,
83
// and remove from dupliMtx_list if object not found.
84
// This should also help to solve some other yet undetected 'dupli..' errors,
85
// but on the other hand that could also hide the real problem of course...
86
map<string, Object*> renderobs;
90
88
for (int i=0;i<R.totvlak;i++) {
92
90
if ((i & 255)==0) vlr=R.blovl[i>>8]; else vlr++;
101
99
if (strlen(matr->id.name)==0)
102
100
used_materials["blender_default"] = matr;
104
used_materials[matr->id.name] = matr; // <-- full name to avoid name collision in yafray
105
//used_materials[matr->id.name+2] = matr; // skip 'MA' id
102
used_materials[matr->id.name] = matr;
106
103
// textures, all active channels
107
for (int m=0;m<8;m++) {
104
for (int m=0;m<MAX_MTEX;m++) {
108
105
if (matr->septex & (1<<m)) continue; // only active channels
109
106
MTex* mx = matr->mtex[m];
110
107
// if no mtex, ignore
114
111
if (tx==NULL) continue;
115
112
short txtp = tx->type;
116
113
// if texture type not available in yafray, ignore
117
if ((txtp!=TEX_STUCCI) &&
118
(txtp!=TEX_CLOUDS) &&
120
(txtp!=TEX_MARBLE) &&
121
(txtp!=TEX_IMAGE)) continue;
122
// in the case of an image texture, check that there is an actual image, otherwise ignore
123
if ((txtp & TEX_IMAGE) && (!tx->ima)) continue;
124
used_textures[tx->id.name] = make_pair(matr, mx); // <-- full name to avoid name collision in yafray
125
//used_textures[tx->id.name+2] = make_pair(matr, mx);
116
(txtp==TEX_PLUGIN) ||
117
(txtp==TEX_ENVMAP)) continue;
118
// if texture is stucci, only export if 'nor' enabled
119
if ((txtp==TEX_STUCCI) && !((mx->mapto & MAP_NORM) || (mx->maptoneg & MAP_NORM))) continue;
120
// In the case of an image texture, check that there is an actual image, otherwise ignore.
121
// Stupid error was here (...if (txtp & TEX_IMAGE)...),
122
// which happened to work sofar, but not anymore with the extended texture support..
123
if ((txtp==TEX_IMAGE) && (!tx->ima)) continue;
124
used_textures[tx->id.name] = mx;
129
// make list of faces per object, ignore <3 vert faces, duplicate vertex sorting done later
130
// make sure null object pointers are ignored
128
// Make list of faces per object, ignore <3 vert faces, duplicate vertex sorting done later.
129
// ignore null object pointers.
130
// Also make list of facetexture images (material 'TexFace').
132
132
int nv = 0; // number of vertices
133
133
if (vlr->v4) nv=4; else if (vlr->v3) nv=3;
134
if (nv) all_objects[vlr->ob].push_back(vlr);
136
//else cout << "WARNING: VlakRen struct with null obj.ptr!\n";
135
renderobs[vlr->ob->id.name] = vlr->ob;
136
all_objects[vlr->ob].push_back(vlr);
138
Image* fc_img = (Image*)vlr->tface->tpage;
140
Material* fmat = vlr->mat;
141
// only save if TexFace enabled
142
if (fmat && (fmat->mode & MA_FACETEXTURE)) imagetex[fc_img].insert(fmat);
150
// now remove any objects from dupliMtx_list which are not in the renderlist
151
for (map<string, vector<float> >::iterator dL=dupliMtx_list.begin();
152
dL!=dupliMtx_list.end();++dL)
154
string ro_name = dL->first;
155
if (renderobs.find(ro_name)==renderobs.end()) {
156
cout << "Object " << ro_name << " not in renderlist, removing from dupliMtx_list" << endl;
158
dupliMtx_list.erase(ro_name);
140
162
// in case dupliMtx_list not empty, make sure that there is at least one source object
152
174
// if the name reference list is empty, return now, something was seriously wrong
153
175
if (dup_srcob.empty()) {
154
// error() doesn't work to well, when switching from Blender to console at least, so use stdout instead
176
// error() doesn't work to well, when switching from Blender to console at least, so use stdout instead
155
177
cout << "ERROR: Duplilist non_empty, but no srcobs\n";