Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: converter/cross/converter.cc

Issue 147192: Updates the o3dConverter to turn on filtering by default... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 return false; 126 return false;
127 } 127 }
128 128
129 // Remove the animation param_object (and indirectly the param_float) 129 // Remove the animation param_object (and indirectly the param_float)
130 // if there is no animation. 130 // if there is no animation.
131 if (param_float->output_connections().empty()) { 131 if (param_float->output_connections().empty()) {
132 pack->RemoveObject(param_object); 132 pack->RemoveObject(param_object);
133 } 133 }
134 134
135 // Mark all Samplers to use tri-linear filtering
136 if (!options.keep_filters) {
137 std::vector<Sampler*> samplers = pack->GetByClass<Sampler>();
138 for (unsigned ii = 0; ii < samplers.size(); ++ii) {
139 Sampler* sampler = samplers[ii];
140 sampler->set_mag_filter(Sampler::ANISOTROPIC);
apatrick 2009/06/26 20:04:29 Sampler::LINEAR?
141 sampler->set_min_filter(Sampler::ANISOTROPIC);
142 sampler->set_mip_filter(Sampler::ANISOTROPIC);
143 }
144 }
145
146 // Mark all Materials that are on Primitives that have no normals as constant.
147 if (!options.keep_materials) {
148 std::vector<Primitive*> primitives = pack->GetByClass<Primitive>();
149 for (unsigned ii = 0; ii < primitives.size(); ++ii) {
150 Primitive* primitive = primitives[ii];
151 StreamBank* stream_bank = primitive->stream_bank();
152 if (stream_bank && !stream_bank->GetVertexStream(Stream::NORMAL, 0)) {
153 Material* material = primitive->material();
154 if (material) {
155 ParamString* lighting_param = material->GetParam<ParamString>(
156 Collada::kLightingTypeParamName);
157 if (lighting_param) {
158 // If the lighting type is lambert, blinn, or phong
159 // copy the diffuse color to the emissive since that's most likely
160 // what the user wants to see.
161 if (lighting_param->value().compare(
162 Collada::kLightingTypeLambert) == 0 ||
163 lighting_param->value().compare(
164 Collada::kLightingTypeBlinn) == 0 ||
165 lighting_param->value().compare(
166 Collada::kLightingTypePhong) == 0) {
167 // There's 4 cases: (to bad they are not the same names)
168 // 1) Diffuse -> Emissive
169 // 2) DiffuseSampler -> Emissive
170 // 3) Diffuse -> EmissiveSampler
171 // 4) DiffuseSamer -> EmissiveSampler
apatrick 2009/06/26 20:04:29 DiffuseSamer->DiffuseSampler
172 ParamFloat4* diffuse_param = material->GetParam<ParamFloat4>(
173 Collada::kMaterialParamNameDiffuse);
174 ParamFloat4* emissive_param = material->GetParam<ParamFloat4>(
175 Collada::kMaterialParamNameEmissive);
176 ParamSampler* diffuse_sampler_param =
177 material->GetParam<ParamSampler>(
178 Collada::kMaterialParamNameDiffuseSampler);
179 ParamSampler* emissive_sampler_param =
180 material->GetParam<ParamSampler>(
181 Collada::kMaterialParamNameEmissive);
182 Param* source_param = diffuse_param ?
183 static_cast<Param*>(diffuse_param) :
184 static_cast<Param*>(diffuse_sampler_param);
185 Param* destination_param = emissive_param ?
186 static_cast<Param*>(emissive_param) :
187 static_cast<Param*>(emissive_sampler_param);
188 if (!source_param->IsA(destination_param->GetClass())) {
189 // The params do not match type so we need to make the emissive
190 // Param the same as the diffuse Param.
191 material->RemoveParam(destination_param);
192 destination_param = material->CreateParamByClass(
193 diffuse_param ? Collada::kMaterialParamNameEmissive :
194 Collada::kMaterialParamNameEmissiveSampler,
195 source_param->GetClass());
196 DCHECK(destination_param);
197 }
198 destination_param->CopyDataFromParam(source_param);
199 }
200 lighting_param->set_value(Collada::kLightingTypeConstant);
201 }
202 }
203 }
204 }
205 }
206
135 // Attempt to open the output file. 207 // Attempt to open the output file.
136 FILE* out_file = file_util::OpenFile(out_filename, "wb"); 208 FILE* out_file = file_util::OpenFile(out_filename, "wb");
137 if (out_file == NULL) { 209 if (out_file == NULL) {
138 O3D_ERROR(&service_locator) << "Could not open output file \"" 210 O3D_ERROR(&service_locator) << "Could not open output file \""
139 << FilePathToUTF8(out_filename).c_str() 211 << FilePathToUTF8(out_filename).c_str()
140 << "\""; 212 << "\"";
141 if (error_messages) { 213 if (error_messages) {
142 *error_messages += error_collector.errors(); 214 *error_messages += error_collector.errors();
143 } 215 }
144 return false; 216 return false;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 << FilePathToUTF8(in_filename).c_str() << "'"; 375 << FilePathToUTF8(in_filename).c_str() << "'";
304 } 376 }
305 } 377 }
306 if (error_messages) { 378 if (error_messages) {
307 *error_messages = error_collector.errors(); 379 *error_messages = error_collector.errors();
308 } 380 }
309 return true; 381 return true;
310 } 382 }
311 } // end namespace converter 383 } // end namespace converter
312 } // end namespace o3d 384 } // end namespace o3d
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698