DG Kernel (ActiveX) Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
What is new
Upgrading Native Apps
Licensing
Collapse ModelsModels
Collapse DG Kernel ControlsDG Kernel Controls
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse ViewsViews
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Go to DGKC docs Search Documentation


IMeshShading_KC(64) Interface

SetShadingType
GetShadingType
SetVertexColor
GetVertexColor
IsShaderInitOK
DeleteShader

IMeshShading_KC allows to define per vertex color of an object as opposed the default flat color defined by material properties

IMeshShading_KC can be obtained from IMesh via query: kernelCAD > GetModel() > IModel > GetEntity() > ISection > IMesh > IMeshShading_KC

See also: Morph sample


HRESULT SetShadingType(int type)

Parameters

type - [in] 0 to disable shading, 1 - to enable shading

Remarks:

Call this methos with type = 1 to enable shading and type = 0 to disable it. When type is 0, and there are internal memory resources (shader) allocated, the shader is not deleted and the colors can be redisplayed by call to SetShadingType(1). If requeried, use DeleteShader() method below to free the resources.

Warning: When the entity which owns the mesh is current in the model the shading is not displayed. Either switch the current entity or call IModel2.SetCurrentObject(null) to make it not current.


HRESULT GetShadingType(int* type)

Remarks:

Returns the value set for the mesh in the last SetShadingType() call.


HRESULT SetVertexColor(POSN vertex, byte red, byte green, byte blue, byte alpha)

Parameters

vertex- [in] Position of the vertex in the mesh. See remarks

red, green, blue, alpha- [in] Components of the color. The numbers must be in range 0 to 255, where 255 means the maximal intensity of the component

Remarks:

Modifies color of the vertex. The vertex is defined by its position in the mesh. Use IMesh > GetVertexIterator() > IIterator.GetHeadPosition(), IIterator.GetNext() to browse vertices of the mesh. By default color of all vertices is black.

The first call to this method allocates memory resources for the shader, which keeps the colors. Call DeleteShader() method below to release the resources when shading is not longer needed.


HRESULT GetVertexColor(POSN vertex, byte* red, byte* green, byte* blue, byte* alpha)

Parameters

vertex- [in] Position of the vertex in the mesh. See remarks for SetVertexColor() above

red, green, blue, alpha- [out] Components of the color. The numbers are in range 0 to 255, where 255 means the maximal intensity of the component

Remarks:

The method returns the color set with a call to SetVertexColor() above


HRESULT IsShaderInitOK(VARIANT_BOOL* ret)

Remarks:

The method returns true if the current shading type is 1 as set with a SetShadingType() call and there was at least one call to SetVertexColor() so that resources are allocated for the shader


HRESULT DeleteShader()

Remarks:

The method releases resources allocated for the shader. The shader is automatically deleted on destruction of the mesh. This method is useful to reduce memory consumption for large meshes when it is know that shading in no longer required for the mesh.