HStreamFileToolkit

class HStreamFileToolkit

The HStreamFileToolkit class provides support for exporting/importing HOOPS Stream File information from/to a HOOPS/3dGS scene-graph.

The HSF file reading process involves reading the opcode at the start of each piece of binary information, and calling the Read method of the associated opcode handler. After the opcode handler reports that reading is complete, the Execute method should be called. The ParseBuffer method of the BStreamFileToolkit object encapsulates this process.

The HSF file writing process involves determining the proper opcode for each piece of binary information, and calling the Interpret method of the associated opcode handler. After interpretation is complete, the Write method of the opcode handler should be called until writing is complete. The GenerateBuffer method of the HStreamFileToolkit encapsualetes this process.

This class provides a HOOPS/3dGS-specific implementation of the BStreamFileToolkit object. It has HOOPS/3dGS-specific opcode handlers registered with it (of the naming convention HTK_XXX). These opcode handlers overload the following two methods of the base opcode handler:

  • Interpret : this method will query the HOOPS/3dGS scene-graph (meaning, extract the graphics data); the data will then be written out to an HSF via the Write method
  • Execute : this method will map the HSF data to custom data structures after it has been read in from the HSF file via the Read method

Inherits from: BStreamFileToolkit

Enumerations

Methods

void HStreamFileToolkit::cleanup_deferred_styles()

private

void HStreamFileToolkit::apply_deferred_styles()

private

bool HStreamFileToolkit::issorted_revisit(Internal_Revisit_Item *array[], int count)

private

void HStreamFileToolkit::qsort_revisit(Internal_Revisit_Item **first, Internal_Revisit_Item **last)

private

void HStreamFileToolkit::qsort_revisit(Internal_Revisit_Item**, Internal_Revisit_Item**, int)

private

TK_Status HStreamFileToolkit::sort_revisit()

private

TK_Status HStreamFileToolkit::find_textures()

private

TK_Status HStreamFileToolkit::write_custom_shader_definition(BStreamFileToolkit &tk)

private

HStreamFileToolkit::HStreamFileToolkit()

Default constructor for an HStreamFileToolkit object

HStreamFileToolkit::~HStreamFileToolkit()
void HStreamFileToolkit::Restart()

Initializes the file toolkit. This is useful if a single toolkit object is to be used for dealing with different files, rather than deleting the current toolkit object and creating a new instance. Call this function after processing of the current file is complete.

TK_Status HStreamFileToolkit::GenerateBuffer(char *b, int s, int &f, char const *start_segment = 0)

Traverses the HOOPS database beginning at the currently open segment and calls the Interpret method of the opcode handler associated with each object encountered. The Interpret methods of the default object handlers query the HOOPS database to obtain segment, geometry and attribute information. After interpretation is complete, GenerateBuffer continually calls the Write method of the opcode handler until writing is complete. The Write methods of the default handlers convert the HOOPS database information into a specific binary format.

A HOOPS segment must currently be open before calling GenerateBuffer, or a segment name must be given.

If the buffer being generated ends in the middle of an object, it will be saved along with any HOOPS database state information and the next buffer will be appended to it.

Parameters

b: A character pointer. Returned to user.

s: An integer denoting the length of the buffer in bytes.

f: An integer denoting the length of the buffer that was written back, in bytes.

start_segment: Explicit name of a hoops segment to process (currently open segment if null)

Returns

The result of the function call.
TK_Status HStreamFileToolkit::GenerateOneItemBuffer(char *b, int s, int &f, HC_KEY item)

This method is similar to GenerateBuffer. However, instead of traversing the HOOPS database beginning at the currently open segment, only the item specified will be processed.

If the buffer being generated ends in the middle of an object, it will be saved along with any HOOPS database state information and the next buffer will be appended to it.

Parameters

b: A character pointer. Returned to user.

s: An integer denoting the length of the buffer in bytes.

f: An integer denoting the length of the buffer that was written back, in bytes.

item: Key of the single segment or piece of geometry to process.

Returns

The result of the function call.
unsigned long HStreamFileToolkit::CountObjects(char const *start_segment = 0)

Traverses the HOOPS database beginning at the currently open segment and estimates the number of objects that will be written by a matching call (or series of calls) to GenerateBuffer()

A HOOPS/3dGS segment must currently be open before calling CountObjects, or a segment must be specified.

Parameters

start_segment: Explicit name of a Hoops segment to process (current segment if null).

Returns

The result of the function call.
void HStreamFileToolkit::ActivateContext(ID_Key key)
void HStreamFileToolkit::DeactivateContext(ID_Key key)
void HStreamFileToolkit::NewFileContext(ID_Key key)
int HStreamFileToolkit::GetHoopsVersion()

Determines the version of HOOPS/3dGS the toolkit is using. Some features may not be present on older versions or may be handled differently or can be emulated; querying the version allows opcode handlers to adjust their behaviour accordingly.

Returns

The version times 100, for instance, version 7.15 would be returned as 715.
TK_Status HStreamFileToolkit::StringToHandler(char const *type, BBaseOpcodeHandler **handler)

Generates clones of OpcodeHandlers to interpret geometry lists, such as those found in LODs intended primarily (but not exclusively) for internal use.

Parameters

type: the string returned from HOOPS’ Find_Contents.

handler: the opcode handler (returned to user)

Returns

TK_Error on failure.
TK_Status HStreamFileToolkit::StringToOpcode(char const *type, unsigned char *opcode_out)

maps HOOPS strings to the opcodes that handle them. intended primarily (but not exclusively) for internal use.

Parameters

type: the string returned from HOOPS’ Find_Contents.

opcode_out: the opcode (returned to user), assigned to one of the TKE_Object_Types as defined in BOpcodeEnums.h

Returns

TK_Error on failure.
void HStreamFileToolkit::SetThumbnail(BBaseOpcodeHandler *handler)
Registers an opcode handler which will be called by the toolkit after the header and before it gets into

other processing (and possibly compressing data). This allows the user to include a simple thumbnail image which an application might load as a preview for things like file selection.

Parameters

handler: A pointer to an BBaseOpcodeHandler object.
void HStreamFileToolkit::SetThumbnail(int format, int width, int height, unsigned char const *data)
Generates an opcode handler preset with the provided image data which will be called by the toolkit after the header and

before it gets into other processing (and possibly compressing data). This allows the user to include a simple thumbnail image which an application might load as a preview for things like file selection.

Parameters

format: format of the thumbnail. Formats are specified in #TKO_Thumbnail_Formats

width: width of the thumbnail image

height: height of the thumbnail image

data: array of thumbnail image data

TK_Status HStreamFileToolkit::Write_Stream_File()

Writes the file associated with the toolkit (internal utility).

Returns

The result of the function call.
void HStreamFileToolkit::AddExcludedSegments(int count, HC_KEY const keys[])

Adds to the list of keys indicating segments to skip during write

Parameters

count: the number of keys in the array

keys: the array of keys of segments

void HStreamFileToolkit::AddExcludedSegment(HC_KEY key)

Adds one key to the list of segments to skip during write

Parameters

key: the key of one segment
bool HStreamFileToolkit::SegmentIsExcluded(HC_KEY key) const

const

Determines if a particular segment key is on the exclusion list

Parameters

key: key of the segment to be checked

Returns

true if the segment is to be excluded
void HStreamFileToolkit::ClearExcludedSegments()

Clears the list of excluded segments;

int HStreamFileToolkit::GetExcludedSegmentCount() const

const

Gets the current number of keys of excluded segments

Returns

number of keys
HC_KEY const *HStreamFileToolkit::GetExcludedSegments() const

const

Gets the array of keys of excluded segments

Returns

the array of keys of excluded segments
void HStreamFileToolkit::SetPrependRootSegment(char const *segment)

Sets a segment to prepend to rooted segments well reading

Parameters

segment: name of segment
char const *HStreamFileToolkit::GetPrependRootSegment()

Gets the segment to prepend to rooted segments well reading

Parameters

segment: name of segment
bool HStreamFileToolkit::MatchPreviousExRef() const

const

See if we can match a previous ExRef and just include the segment it generated

Returns

true if the function matched and handled the reference, false if we need to try to read the reference
void HStreamFileToolkit::SetAttributePrecisionMode(int mode)

Sets the manner in which double-precision attributes (primarily modelling matrices) are handled

Parameters

mode: handling mode
int HStreamFileToolkit::GetAttributePrecisionMode()

Returns the chosen the manner in which double-precision attributes (primarily modelling matrices) are handled

Returns

double-precision handling mode
int HStreamFileToolkit::GetAddedDoubleTypes() const

const

Indicates whether double-precision data was added to the database

Returns

bitmask of types which were added as double-precision
void HStreamFileToolkit::AddDoubleType(int type)

internal use

void HStreamFileToolkit::record_texture_chain(char const *name)
bool HStreamFileToolkit::check_one_texture(char const *geometry, char const *channel)
void HStreamFileToolkit::check_diffuse_textures(char const *geometry)
void HStreamFileToolkit::validate_hoops_version()

protected

internal use

void HStreamFileToolkit::add_unnamed_segment(HC_KEY key)

protected

internal use

void HStreamFileToolkit::read_completed()

protected

internal use

void HStreamFileToolkit::empty_lists()

protected

internal use

TK_Status HStreamFileToolkit::tag(int variant)

protected

internal use

unsigned long HStreamFileToolkit::count_segment_objects(HC_KEY key, char const *start_segment = 0)

protected

internal use

unsigned long HStreamFileToolkit::count_custom_shader_objects()

protected

internal use

virtual void HStreamFileToolkit::FileDone()

protected virtual

Variables

int HStreamFileToolkit::m_hoops_version

private

int
Internal_Segment_List *HStreamFileToolkit::m_unnamed_segments

private

Internal_Segment_List
HC_KEY *HStreamFileToolkit::m_excluded_segments

private

HC_KEY
int HStreamFileToolkit::m_excluded_count

private

int
Internal_Segment_Processor *HStreamFileToolkit::m_segment_processor

private

Internal_Segment_Processor
Internal_Pending_Tag *HStreamFileToolkit::m_pending_tags

private

Internal_Pending_Tag
Internal_Texture_List *HStreamFileToolkit::m_texture_list

private

Internal_Texture_List
bool HStreamFileToolkit::m_non_segment_revisits

private

bool
int HStreamFileToolkit::m_revisit_offset

private

int
BBaseOpcodeHandler *HStreamFileToolkit::m_thumbnail

private

BBaseOpcodeHandler
int HStreamFileToolkit::m_local_attributes

private

int
BBaseOpcodeHandler *HStreamFileToolkit::m_must_delete

private

BBaseOpcodeHandler
char *HStreamFileToolkit::m_prepend_root

private

char
int HStreamFileToolkit::m_revisit_state

private

int
int HStreamFileToolkit::m_attribute_precision_mode

private

int
int HStreamFileToolkit::m_geometry_precision_mode

private

int
int HStreamFileToolkit::m_double_added

private

int
void *HStreamFileToolkit::m_deferred_styles_ptr

private

void
char const **HStreamFileToolkit::m_search_strings
char const