GetMaterialColor (inline)
Syntax
// // Strong typing definition // static inline void GetMaterialColor( OwlInstance owlInstanceMaterial, uint32_t * ambient, uint32_t * diffuse, uint32_t * emissive, uint32_t * specular ) { assert(IsInstanceOfClass(owlInstanceMaterial, "Material")); OwlInstance * values = nullptr; int64_t card = 0; GetObjectProperty( owlInstanceMaterial, GetPropertyByName( GetModel(owlInstanceMaterial), "color" ), &values, &card ); OwlInstance owlInstanceColor = (card == 1) ? values[0] : 0; if (owlInstanceColor) { GetColor( owlInstanceColor, ambient, diffuse, emissive, specular ); } else { GetDefaultColor( GetModel(owlInstanceMaterial), ambient, diffuse, emissive, specular ); } } // // Weak typing definition // static inline void GetMaterialColor( int64_t owlInstanceMaterial, uint32_t * ambient, uint32_t * diffuse, uint32_t * emissive, uint32_t * specular ) { assert(IsInstanceOfClass(owlInstanceMaterial, "Material")); OwlInstance * values = nullptr; int64_t card = 0; GetObjectProperty( owlInstanceMaterial, GetPropertyByName( GetModel(owlInstanceMaterial), "color" ), &values, &card ); OwlInstance owlInstanceColor = (card == 1) ? values[0] : 0; if (owlInstanceColor) { GetColor( owlInstanceColor, ambient, diffuse, emissive, specular ); } else { GetDefaultColor( GetModel(owlInstanceMaterial), ambient, diffuse, emissive, specular ); } }
Property owlInstanceMaterial
Size: 64 bit / 8 byte (value)Property ambient
Size: 64 bit / 8 byte (reference)Property diffuse
Size: 64 bit / 8 byte (reference)Property emissive
Size: 64 bit / 8 byte (reference)Property specular
Size: 64 bit / 8 byte (reference)
Example (based on pure and inline API calls)
Here you can find code snippits that show how the API call GetMaterialColor can be used.
#include "./include/engine.h" void main() { int64_t model = CreateModel(); if (model) { // // Classes // int64_t classBox = GetClassByName(model, "Box"); // // Datatype Properties (attributes) // int64_t propertyLength = GetPropertyByName(model, "length"), propertyWidth = GetPropertyByName(model, "width"), propertyHeight = GetPropertyByName(model, "height"); // // Instances (creating) // int64_t instanceBox = CreateInstance(classBox, nullptr); double length = 2.8, width = 1.3, height = 1.4; SetDatatypeProperty(instanceBox, propertyLength, &length, 1); SetDatatypeProperty(instanceBox, propertyWidth, &width, 1); SetDatatypeProperty(instanceBox, propertyHeight, &height, 1); // // Simple use of the derived information functions // double centroid[3], volume = GetCentroid(instanceBox, nullptr, nullptr, ¢roid); GetMaterialColor(instanceBox); int64_t vertexBufferSize = 0, indexBufferSize = 0; CalculateInstance(instanceBox, &vertexBufferSize, &indexBufferSize, 0); if (vertexBufferSize && indexBufferSize) { float * vertexBuffer = new float[6 * vertexBufferSize]; UpdateInstanceVertexBuffer(instanceBox, vertexBuffer); int32_t * indexBuffer = new int32_t[indexBufferSize]; UpdateInstanceIndexBuffer(instanceBox, indexBuffer); // // Reuse knowledge to improve performance (in case of single precision, with less accuracy) // volume = GetCentroid(instanceBox, vertexBuffer, indexBuffer, ¢roid); } // // The resulting model can be viewed in 3D-Editor.exe // SaveModel(model, "c:\\created\\myFile.bin"); CloseModel(model); } }