Generally, assets are groups of properties that control certain characteristics or behaviors of an object. Rendering assets contain data related to the display of materials in renderings and certain types of views. Appearance assets are used to control the display of elements in rendered images. Assets can be connected to each other.
Appearance assets can be an object or an element:
For more details about appearance asset classes, see Overview of Materials.
Materials are view-dependent entities that have graphics settings (such as
color and surface patterns) for shaded rendering and appearance assets for rendering
in realistic mode. An appearance asset contains an array of items, and each
item is a property of a material visual style.
Each property is a descendant of the OdBmAProperty
type and can be accessed by the
getAProperty()
method of OdBmAsset
class:
template <class T> bool getAProperty(const OdString& name, OdBmAPropertyPtr& prop);
Also, an appearance asset can
be shared among different materials by setting the AppearanceAssetId
property
of a material.
An RVT file has 14 default materials: Ceramic, Concrete, Generic, Glazing,
Hardwood, MasonryCMU, Metal, MetallicPaint, Mirror, PlasticVinyl, SolidGlass,
Stone, WallPaint and Water. An appearance asset for each material contains more
than 40 properties and should be set for any newly created material. Default
materials are stored in the PredefinedAppearanceAsset
enumeration. The appearance
of generic materials in rendering views (Realistic and Ray Trace)
can be one of the following types: Image, Checker, Gradient, Marble, Noise, Speckle, Tiles, Waves or Wood.
enum PredefinedAppearanceAsset {
DecalAppearance = -13,
UnifiedBitmap = -12,
Checker = -11,
Gradient = -10,
Marble = -9,
Noise = -8,
Speckle = -7,
Tiles = -6,
Waves = -5,
Wood = -4,
ByName = -3,
ByCategory = -2,
Undefined = -1,
Ceramic = 0,
Concrete = 1,
Generic = 2,
Glazing = 3,
Hardwood = 4,
MasonryCMU = 5,
Metal = 6,
MetallicPaint = 7,
Mirror = 8,
PlasticVinyl = 9,
SolidGlass = 10,
Stone = 11,
WallPaint = 12,
Water = 13,
Generic_026 = 14
};
The constructor of the OdBmAppearanceAssetHelper
class requires a pointer to
the database (pointer to the OdBmDatabase
object), name of the material (OdString
object), pointer to the appearance asset element (pointer to the OdBmAppearanceAssetElem
object), predefined appearance (one value from the PredefinedAppearanceAsset
enumeration) and an optional name of the texture file (OdString
value).
For example, to create an asset based on the ceramic appearance asset:
// Create appearance asset for material
// Create new OdBmAppearanceAssetElem element
OdBmAppearanceAssetElemPtr pAppAsset = OdBmAppearanceAssetElem::createObject();
// Add it to the Database
OdBmObjectId oAppAsset = pDb->addElement(pAppAsset);
// Use OdBmAppearanceAssetHelper to fill appearance asset with Ceramic scheme
OdBmAppearanceAssetHelper appAssetHelper = OdBmAppearanceAssetHelper(pAppAsset);
appAssetHelper.fillAppearanceAssetWith(OdBm::PredefinedAppearanceAsset::Ceramic);
appAssetHelper.setName(OdString(L"Ceramic_sample"));
To apply the appearance asset to a material element, use the
applyToMaterial()
method of the OdBmAppearanceAssetHelper
object. This method requires a pointer
to a material object. For example:
// Create Material Element
OdBmObjectId objIdMat = OdBmMaterialElem::createMaterial(pDb, L"Material_Sample");
// Set material data
OdBmMaterialElemPtr pMaterialElem = objIdMat.safeOpenObject();
OdBmMaterialPtr pMat = pMaterialElem->getMaterial();
pMat->setTransparency(71.5);
pMat->setSmoothness(0.7);
pMat->setShininess(26);
pMat->setGlow(true);
// Fill material data according to appearance asset
appAssetHelper.applyToMaterial(pMat);
// Link appearance asset to material
pMat->setAppearanceAssetId(oAppAsset);
To get access to the appearance asset object of the appearance asset element,
use the getRenderingAsset()
method,
which returns a pointer to the appearance
asset object as a pointer to the OdBmAppearanceAsset
class. For example:
OdBmObjectId pObj = pMat->getAppearanceAssetId();
OdBmAppearanceAssetElemPtr pAppAssElem = pObj.safeOpenObject();
OdBmAppearanceAssetPtr pAppAss = pAppAssElem->getRenderingAsset();
To set a new appearance asset object to an appearance asset element, use the
setRenderingAsset()
method,
which requires a pointer to the OdBmAppearanceAsset
object. For example:
// Create appearance asset for material
// Create new OdBmAppearanceAssetElem element
OdBmAppearanceAssetElemPtr pAppAsset = OdBmAppearanceAssetElem::createObject();
// Create AppearanceAsset
OdBmAppearanceAssetPtr pAppAssetObj = OdBmAppearanceAsset::createObject();
pAppAsset->setRenderingAsset(pAppAssetObj);
An appearance asset can include a texture. To work with a texture, use the
OdBmUnifiedBitmapSchemaHelper
helper class. It contains such properties as blur,
blur offset, texture file name, real world scale and others.
To create an object of the OdBmUnifiedBitmapSchemaHelper
class, use its constructor.
It requires a pointer to an OdBmAsset
class, which you can get from an OdBmAppearanceAssetHelper
object. For example:
if (pMatElem->getUseRenderAppearance())
{
message.format(L"Appearance asset is used");
pIO->putString(message);
OdBmObjectId pObj = pMat->getAppearanceAssetId();
OdBmAppearanceAssetElemPtr pAppAssElem = pObj.safeOpenObject();
OdBmAppearanceAssetPtr pAppAss = pAppAssElem->getRenderingAsset();
// Get appearance name
message.format(L"Appearance asset name: %s", pAppAss->getName().c_str());
pIO->putString(message);
// Get appearance transparency
message.format(L"Appearance asset transparency: %f", pAppAss->getTransparency());
pIO->putString(message);
try
{
OdBmAppearanceAssetHelper pAssetHelper = OdBmAppearanceAssetHelper(pAppAssElem);
OdBmAssetPtr textureAsset;
pAssetHelper.getTextureAsset(textureAsset);
if (textureAsset.get()) {
OdBmUnifiedBitmapSchemaHelper textureHelper(textureAsset);
double dVal;
bool bVal;
// Get blur value
textureHelper.getBlur(dVal);
message.format(L"Blur value: %f", dVal);
pIO->putString(message);
// Get blur offset value
textureHelper.getBlur_Offset(dVal);
message.format(L"Blur offset value: %f", dVal);
pIO->putString(message);
// Get blur offset value
textureHelper.getInvert(bVal);
message.format(L"Texture is %s", (bVal) ? L"inverted" : L"not inverted");
pIO->putString(message);
}
}
Currently there are helpers implemented to work with all assets. Follow the links below to see classes used to work with each asset.
You can use the name of the appearance asset's schema to determine which helper class should to use:
OdBmAppearanceSchemaHelper helper(pMaterial->getAsset());
OdString schemaName = helper.getSchemaName();
Or, you can also use the type of the appearance asset's schema:
OdBm::PredefinedAppearanceAsset::Enum schemaType = helper.getSchemaType();
The following code snippet shows how to work with helpers:
// Set thermal properties
OdBmPropertySetElementPtr pPropSetElement = OdBmPropertySetElement::createObject();
pDb->addElement(pPropSetElement);
OdBmThermalAssetHelper thermalAssetHelper = OdBmThermalAssetHelper(pPropSetElement);
thermalAssetHelper.setElectricalResistivity(0.7);
thermalAssetHelper.setReflectivity(0.5);
thermalAssetHelper.setPorosity(0.2);
pMaterialElem->setThermalAssetId(pPropSetElement->objectId());
// Set structural properties
pPropSetElement = OdBmPropertySetElement::createObject();
pDb->addElement(pPropSetElement);
OdBmStructuralAssetHelper structAssetHelper = OdBmStructuralAssetHelper(pPropSetElement);
structAssetHelper.setStructuralAssetClass(OdBm::StructuralAssetClass::Plastic);
structAssetHelper.setName(L"Plastic_sample");
structAssetHelper.setSubClass(L"Plastic");
structAssetHelper.setReductionFactor(0.3);
structAssetHelper.setBending(0.8);
pMaterialElem->setStructuralAssetId(pPropSetElement->objectId());
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|