carl.sutton Posted November 21, 2011 Posted November 21, 2011 Hello. I have an object and I set its material base_transform parameter to its only surface like so; object.setMaterialParameter("base_transform", vec4(2,2,0,0), 0); This works and I get a repetition of my texture over my object. The problem lies in when I now set my material to a buffer as in the one found in editor_materials_buffer.h. When I hit the following code... // copy parameters forloop(int i = 0; material.getNumParameters()) { int type = material.getParameterType(i); string name = material.getParameterName(i); if(type == MATERIAL_PARAMETER_COLOR) parameters.append(name,material.getParameter(i)); else if(type == MATERIAL_PARAMETER_SLIDER) parameters.append(name,material.getParameterSlider(i)); else if(type == MATERIAL_PARAMETER_EXPRESSION) { parameters.append(name,material.getParameterExpression(i)); log.message("%s: %s\n", name, material.getParameterExpression(i)); //log message added for example } } ...I get the following in my log file: 16:03:05 base_transform: 16:03:05 detail_transform: vec4(1.0f,1.0f,0.0f,0.0f) Somewhere in the works through setting my base_transform manually, the expression data has been lost and I can't see where it would be going wrong my side. Any ideas? (Note I'm on SDK 2011-11-11)
ulf.schroeter Posted November 21, 2011 Posted November 21, 2011 Do you initialize material variable via object.getMaterial(0) just before data access ? If so you could try object.getMaterialInherit(0) alternatively, as your base transform modification creates an inherited material instance for the surface
carl.sutton Posted November 22, 2011 Author Posted November 22, 2011 I assumed getMaterialInherit would provide the parent material data and getMaterial was recieving the instanced data? How does this explain how parameters of type MATERIAL_PARAMETER_SLIDER and MATERIAL_PARAMETER_COLOR will work with my current approach of using getMaterial? Well for now I'll have a play with getMaterialInherit and see what happens.
carl.sutton Posted November 22, 2011 Author Posted November 22, 2011 I have come to the conclusion that the problem was with me using Object::setMaterialParameter to set my expression. Even though my expression is a string representing a vec4, it is not the same as the vec4 value parameter in the function Object::setMaterialParameter. As object doesn't define a function for setParameterExpression as the material Class does I just assumed setMaterialParamter would set a parameter expression. I think I'll be able to fix this now. Thanks
Recommended Posts