DG Kernel Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
Overview of the software
What is new
Licensing
Collapse ModelsModels
Collapse DG Kernel ComponentsDG Kernel Components
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Search Documentation


Texture Sample

Source code for Gear sample is available in Samples\VC folder of the installation directory. If you are going to compile the project we suggest to copy whole VC directory to location outside of the installation folder. Texture is an MFC dialog-based application which demonstrates usage of ITexture interface. The application allows to change textures for different surfaces of an object interactively..

See also Visual C++ Samples, All samples

Running Texture Sample

By default the application displays model (Models\Samples\Texture.mdg) of a box with two embedded textures. The first texture, which was assigned on modeling stage my 3D Debugger, is a picture Data\Textures\Uluru.bmp from the installation folder. It is assigned to the front surface of the box. Note that the same technique can be used to display textual information on a surface patch. All side surface patches are using the same texture loaded from file Data\Textures\Wood\wood001.bmp.

Object Group loads a texture bitmap file and assigns it to all surfaces in the object. To display the texture "Enable" check box has to be turned on. To disable blending the texture with underlying color of the surface, turn on the "Texture Only" check box. The texture can be unloaded by using the "Load/Unload" button.  

Side Surface group allows assigning texture to an individual surface patch in the object. If enabled, the texture will override texture loaded for the object. "Use for all" button will make the texture to be shared among all side patch strips in the object (excluding front and back surfaces).  

Vertical Surfaces group manages textures assigned to the Front and Back surfaces.

 Texture application loads by default Cube.mdg model. The user can load and save any DInsight model using File menu. 

Implementation

All implementation of texture handling is contained in TextureDlg class. m_pITexObj member of the class of type ITexture * keeps reference to the texture of the whole object. It is retrieved CTextureDlg::UpdateEntityInfo() method using 

m_pIEntity->QueryInterface( IID_ITexture, (void**)&m_pITexObj);  call.

m_pITexCurSurf member keeps ITexture for the current patch strip selected in the Side Surface group. It is obtained in UpdateSurfaceInfo() with 

m_pIElemSurf->QueryInterface( IID_ITexture, (void**)&m_pITexCurSurf); 

where m_pIElemSurf is the IElement reference implemented by the current surface patch (segment in the strip of patch strips which is the whole side surface).

m_pITexBack and m_pITexFront, responsible for textures of the Front and Back surfaces, are obtained in UpdateFrontBack() from the Texture Array property of the object. This property is an array itself. The first and last elements in the Texture Array are ITexture interface pointers for the Front and Back surfaces. Texture Array is obtained by queering it from ISection implemented by the object. Line pIPropArray->GetProperty("TextureArray", (IUnknown**)&pIArray); retrieves then the Texture Array.