Creating AcDbMaterial object 3



Author Erhan Toker
Profession Architect M.Sc.
  Autodesk Authorized Consultant
  Software Specialist
e-mail  

AutoCAD 2007

After defining hasMaterial() and addMaterial() functions, from now on, we are ready to create a simple texture material. Any AutoCAD material has one or more of diffuse, bump, specular, refraction, opacitiy and reflection properties. At least, a simple material has a diffuse color and in this article I will explain such a material.

A simple material only has the property of color diffusion. In ObjectARX library, color object is AcGiMaterialColor. Let’s define a color now (Fig. 1):

Fig.1
Fig. 1.

Together with setMethod() method, we can use kInherit ( last used color from AcGi stream ) or kOverride ( new color definition) options. And, by using setColor() method, we are defining the color that the material is going to make diffused by using RGB components. Besides, we are setting the diffusivity rate of the color by using setFactor() method. Now, let’s create a material and define its diffusion properties ( Fig.2 ).

Fig.2
Fig. 2.

Our material definition is almost finished. However, diffusion property doesn’t spread enough light by itself. We are adding the same color to our material by using setAmbient() function (Fig. 3) as an environment property by using 0.5 factor.

Fig.3
Fig. 3.

Now, our material is ready to be added to the drawing. We are inserting the new material that we have created into drawing data base by using addMaterial() method ( Fig.4 ).

Fig.4
Fig. 4.

I would like to finalize my article by noting that, pointer acdbWDB points to current drawing database, and it is a macro definition.
#define acdbWDB acdbHostApplicationServices()-> workingDatabase().

Similar Posts

Rate this article:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply