Information technology — Computer graphics, image processing and environmental data representation — Extensible 3D (X3D) language bindings —
Part 3:  C

7 Function definitions

--- X3D separator bar ---

cube 7.1 Introduction and topics

7.1.1 Introduction

This clause describes key concepts in this part of ISO/IEC 19777. This includes conformance criteria and abstract concepts of the binding specified in this part of ISO/IEC 19777 to the abstract definitions specified in Part 2 of ISO/IEC 19775.

7.1.2 Topics

See Table 7.1 for the topics in this clause.

Table 7.1 — Topics in this clause

--- X3D separator bar ---

7.2 Browser services and connections

7.2.1 BrowserFactory

The following scenarios are possible when creating a reference to an X3D browser:

  1. server application talking to a browser on a separate machine, or
  2. a component in a standalone C application.

Each of these requires a separate solution in order to maintain implementation independence.

The function of access to an X3D browser shall be through a single factory style class. This class contains functions for each type of access. To provide implementation independence, an interface for the implementation dependent parts is defined. Browsers shall subclass this interface to provide the necessary dependent code. This interface is loaded by the X3D browser factory using dynamic functions or by having the code explicitly set.

The browser factory shall also contain a setBrowserFactoryImpl() function to allow an explicit setting of the factory implementation. If this function is the first function called of all the factory functions, it shall be used as the factory implementation. If any other function is called prior to calling this function, the name of the factory implementation shall be drawn from the properties file and loaded. Any other attempt to call the set implementation function shall result in an error being generated.

The factory implementation shall return the appropriate data type for each of the functions. If the implementation does not support the particular connection requested, it shall generate an invalid error. If it is supported, it shall return the appropriate data type of the object for that function.

7.2.2 getBrowser

A browser that operates as part of a browser requires a number of different parameters for correct determination of the plug-in to access.

An application server may wish to access browsers on client machines. The server application requests the browser reference of the remote machine. Once the browser reference is returned, the server application may manipulate the browser contents like any other SAI using application.

7.2.3 createBrowser

The component browser is required to fit into the standard model and is implemented as a data type of X3DComponent. It shall provide a getBrowser() function that returns a reference to a standard Browser object. The component implementation may implement the component in any manner it requires. Both lightweight components (all rendering performed in C) and heavyweight components are permitted. These details shall be hidden within the implementation specific data types and not accessible to the general SAI API user.

The factory shall include a function that generates an instance of this component data type. Each call to the component shall result in a new independent instance of an X3D browser capable of running as a component. The browser shall be capable of runningin standalone applications with the restrictions appropriate to the underlying environment. It shall also use whatever hints are supported in the parameter argument passed to it.

--- X3D separator bar ---

TODO: Need to check on the format for adding exceptions to function specifications

7.3 Browser services

7.3.1 getName

char * Browser.getName(void*)

The name returned is a char array representing the name of the browser. If this is not supported, NULL shall be returned.

7.3.2 getVersion

char * Browser.getVersion(void*) 

The version returned is a char array representing the version number of the browser. If this is not supported, NULL shall be returned.

7.3.3 getCurrentSpeed

float Browser.getCurrentSpeed(void*) 

The speed value returned shall be a floating point number. A value of 0.0f shall be returned if this is not supported.

7.3.4 getCurrentFrameRate

float Browser.getCurrentFrameRate(void*) 

The frame rate value shall be a floating point number. A value of 0.0f shall be returned if this is not supported.

7.3.5 getSupportedProfiles

ProfileInfo* Browser.getSupportedProfiles(void*) 

This service returns an array that always contains at least one item and shall be the complete list of profiles that this browser supports.

7.3.6 getProfile

ProfileInfo Browser.getProfile(void*, const char*)

The profile declaration that corresponds to the named profile is returned if the browser supports that profile.

7.3.7 getSupportedComponents

ComponentInfo* Browser.getSupportedComponents(void*)

A list of the component declarations for all components that are supported is returned with their respective support levels.

7.3.8 getComponent

ComponentInfo Browser.getComponent(void*, const char *, int)

The component declaration that corresponds to the named component and level is returned if the browser supports that capability.

7.3.9 getExecutionContext

X3DExecutionContext Browser.getExecutionContext(void*)

If the execution context is the full scene rather than inside a prototype instance or an Inline node, the X3DExecutionContext instance returned will be an instance of the derived X3DScene interface. User code may test for this situation by using the instanceof operator.

7.3.10 createScene

X3DScene Browser.createScene(void*, ProfileInfo, ComponentInfo*)

A new, empty scene is created that represents the given profile and component collection. The profile shall always be specified and, if no supplementary components are desired, the second parameter shall be null.

7.3.11 replaceWorld

void Browser.replaceWorld(void*, X3DScene)

The world is replaced with the new scene. If the parameter is NULL, the existing scene is cleared and the browser is left with no scene and no activity; nothing shall be rendered.

7.3.12 importDocument

X3DScene Browser.importDocument(void*, DOMNode)

A document described by the standard DOM strcutrues is converted to an X3D scene.

7.3.14 setDescription

void Browser.setDescription(void*, const char *)

This service sets the description char array of the browser. If the browser is running as a plug-in, this shall set the title of the page (if the containing web browser supports this). For component browsers the result shall be implementation dependent.

7.3.15 createX3DFromString

X3DScene Browser.createX3DFromString(void*, const char *)

An X3DScene instance corresponding to the given char array is returned. The parameter shall be a char array that contains legal syntax as defined in ISO/IEC 19776 X3D encodings. The char array may be any one of the formal encodings defined by ISO/IEC 19776 X3D encodings that can be represented by Latin characters.

The header statement need not be present as the first line in the char array. If the char array does not contain legal X3D syntax, an InvalidX3DException shall be generated. If the encoding of the given char array is not supported, the NotSupportedException shall be generated.

7.3.16 createX3DFromStream

X3DScene Browser.createX3DFromStream(void*, Stream *)

An X3DScene instance corresponding to the given stream is returned. The parameter shall be an already established stream that contains legal syntax as defined in ISO/IEC 19776 X3D encodings. The stream may be any one of the formal encodings defined by ISO/IEC 19776 X3D encodings.

The header statement need not be present as the first line in the stream. If the stream does not contain legal X3D syntax, an InvalidX3DException shall be generated. If the encoding of the given stream is not supported, the NotSupportedException shall be generated.

7.3.17 updateControl

void ExternalBrowser.beginUpdate(void*)

This service is split into two separate functions beginUpdate and endUpdate. The functionality is as described in 7.3.19, Update Control of ISO/IEC 19775-2.

7.3.18 registerBrowserInterest

void Browser.addBrowserListener(void*, BrowserListener)

Registering interest in browser events is through a browser event listener. The listener is an interface which is passed browser events when the state of the browser changes or asynchronous error messages are sent.

EXAMPLE  Inability to load any of the requested events

functions shall be provided to allow listeners to be added and removed dynamically. A separate event data type shall be used to indicate the event information. This data type has, as a minimum, the predefined events listed in Table 4.4 Event type names listed alphabetically by abstract name.  Specific browser implementation may define additional event types. Any extra event types shall not have values below the figure defined by LAST_IDENTIFIER.

7.3.19 getRenderingProperties

const char ** Browser.getRenderingProperties(void*)

The map will contain key/value pairs for all rendering properties that may be set. A table of the standard properties is defined in Table 7.5 Standard rendering property definitions of ISO/IEC 19775-2. All keys shall be char * instances that name the property. Values may be of the data type wrapper type representing the primitive value.

EXAMPLE  Numerical values will be returned.

If the property does not exist in the table, it shall be interpreted as not being supported by the browser implementation.

The map shall be immutable. It shall be an error for the user to attempt to insert additional properties or change existing properties.

7.3.20 getBrowserProperties

const char ** Browser.getBrowserProperties(void*)

The map will contain key/value pairs for all the available browser properties that may be set. A table of the standard properties is defined in Table 6.6 Standard properties describing extension capabilities of ISO/IEC 19775-2. All keys shall be const char * instances that name the property. Values may be of the data type wrapper type representing the primitive value.

EXAMPLE  Numerical values will be returned.

Where the properties represents the extensions of the browser interface available, the key shall be the SAI extension name, and the value will be a bool representing true or false values. If the browser supports the extended interface, there shall be an entry with a true value. If an entry has a false value, or there is no entry at all for the named extension, then that shall be treated as the browser not supporting that extension.

The map shall be immutable. It shall be an error for the user to attempt to insert or change the existing properties.

7.3.21 changeViewpoint

void Browser.nextViewpoint(void*, int)

void Browser.previousViewpoint(void*, int)

void Browser.firstViewpoint(void*, int)

void Browser.lastViewpoint(void*, int)

Change the currently bound viewpoint in the specified layer to the viewpoint given.

7.3.22 print, println

void Browser.print(void*, const char*)

void Browser.println(void*, const char*)

Print information directly to the console of the browser. The browser has the option of redirecting the stdout and stderr input streams to wherever considered appropriate, but shall always have these two functions print directly to the console.

7.3.23 dispose

void Browser.dispose(void*)

Dispose shall notify the browser that the C implementation is no longer interested in the X3D browser. Any further requests to functions of this instance of the browser interface shall generate an InvalidBrowserException.

--- X3D separator bar ---

7.4 Execution context services

7.4.1 getSpecificationVersion

char* X3DExecutionContext.getSpecificationVersion(void*)

The char array shall represent the basic specification version used by the parsed file in decimal format. For example, a scene conforming to this specification returns a value such as "3.3".

7.4.2 getEncoding

int X3DExecutionContext.getEncoding(void*)

The returned encoding value is defined as a constant that is part of the X3DExecutionContext interface. The values for these are defined in Table 7.3.

Table 7.3 — Constants describing the encoding for current scene

Encoding Constant Value Comment
NO_SCENE static int NO_SCENE 0 There is no scene defined. This value should never be seen directly.
SCRIPTED_ENCODING static int SCRIPTED_ENCODING
1 The scene was created dynamically through scripting calls.
ASCII_ENCODING static int ASCII_ENCODING
2 The scene described an original VRML 1.0 encoding.
CLASSIC_VRML_ENCODING static int CLASSIC_VRML_ENCODING 3 The execution context is encoded using the Classic VRML encoding specified in ISO/IEC 19776-2 or the encoding specified in ISO/IEC 14772-1.
XML_ENCODING static int XML_ENCODING
4 The execution context is encoded using the XML encoding specified in ISO/IEC 19776-1.
BINARY_ENCODING static int BINARY_ENCODING
5 The scene was encoded using the binary format specified in ISO/IEC 19776-3.  It shall be an error to use this value to describe a browser-specific proprietary binary format.
BIFS_ENCODING static int BIFS_ENCODING
6 The execution context is encoded using the MPEG4 BIFS encoding.
LAST_STD_ENCODING static int LAST_STD_ENCODING
100 A definition of the last constant used by the standard encodings. A browser is permitted to allow other, proprietary encoding mechanisms, and therefore any constant used to describe that shall use a value greater than this number. Code using these values shall not expect to be transportable across multiple browser implementations.

7.4.3 getProfile

ProfileInfo X3DExecutionContext.getProfile(void*)

The profile declaration as defined for this scene is returned.

7.4.4 getComponents

ComponentInfo* X3DExecutionContext.getComponents(void*)

A listing of the explicit components declared in this scene is returned. If the scene does not have any extra components declared, this function shall return null.

7.4.5 getUnits

UnitInfo* X3DExecutionContext.getUnits(void*)

A listing of all declared and default units for this scene is returned.

7.4.6 getNode

X3DNode X3DExecutionContext.getNamedNode(void*,char*)

X3DNode X3DExecutionContext.getImportedNode(void*,char*)

The return value is a Node reference. The parameter is a char array defining the DEF name of the required node. If the browser cannot find the node name, an InvalidNodeException shall be generated.

7.4.7 createNode

X3DNode X3DExecutionContext.createNode(void*,char*)

The return value is a X3DNode reference if it is part of the currently set profile. If the node is not available in the current profile and components, the browser shall generate InvalidNameException.

7.4.8 createProto

X3DProtoInstance X3DExecutionContext.createProto(void*,char*)

The return value is a proto instance reference if it can be found using the name spacing rule for protos. If the proto name cannot be found, the browser shall generate InvalidNameException.

7.4.9 namedNodeHandling

void X3DExecutionContext.updateNamedNode(void*, char*, X3DNode)

void X3DExecutionContext.updateImportedNode(void*, char*, char*, X3DNode)

void X3DExecutionContext.removeNamedNode(void*,char*)

void X3DExecutionContext.removeImportedNode(void*,char*)

Separate function signatures are defined for each of the operation types. This allows for strong type safety.

7.4.10 getProtoDeclaration

X3DProtoDeclaration X3DExecutionContext.getProtoDeclaration(void*,char*)

7.4.11 protoDeclarationHandling

void X3DExecutionContext.updateProtoDeclaration(void*,char*, X3DProtoDeclaration)

void X3DExecutionContext.removeProtoDeclaration(void*,char*)

7.4.12 getExternprotoDeclaration

X3DExternProtoDeclaration X3DExecutionContext.getExternProtoDeclaration(void*,char*)

7.4.13 externprotoDeclarationHandling

void X3DExecutionContext.updateExternProtoDeclaration(void*,char*, X3DExternProtoDeclaration)

void X3DExecutionContext.removeExternProtoDeclaration(void*,char*)

7.4.14 getRootNodes

X3DNode* X3DExecutionContext.getRootNodes(void*)

Get a listing of the root nodes in the current execution context. If this context is a proto, then this will list all of the top-level nodes of the proto. The order shall be maintained as declared in the source encoding. If there are no root level nodes, this shall return null.

7.4.15 getRoutes

X3DRoute* X3DExecutionContext.getRoutes(void*)

Show the list of routes currently available in the execution context. If there are no routes the function shall return null.

7.4.16 dynamicRouteHandling

X3DRoute X3DExecutionContext.addRoute(void*, X3DNode, char*, X3DNode, char*)

void X3DExecutionContext.deleteRoute(void*, X3DRoute)

This service is split into two separate functions: addRoute and deleteRoute. They both take the same argument list. The first parameter is a Node reference that the event will leave from. The second is a char array describing the name of the output-capable field. Third and forth parameters are the destination node reference and the input-capable field as a String. If either of the Node references have been disposed of, an InvalidNodeException shall be generated. If either of the nodes do not contain the nominated input-capable / output-capable fields, an InvalidWritableFieldException / InvalidReadableFieldException shall be generated appropriately.

7.4.17 dispose

void X3DExecutionContext.dispose(void*)

Dispose shall notify browser that the C implementation for the current context is no longer available.

--- X3D separator bar ---

7.5 Scene services

7.5.1 General concepts

Scene services are implemented by the X3DScene interface, which extends from the X3DExecutionContext interface. The additional functions required by the extra services are described below.

7.5.2 getMetaData

char* X3DScene.getMetaData(void*, char*)

The char array describes a metadata key and the return value shall be the metadata value previously set. This returns the metadata specified by the META statement. If no metadata value is set, the return value is null.

7.5.3 setMetaData

void X3DScene.setMetaData(void*, char*, char*)

The metadata value specified by the metadata key is set or changed to the new metadata value. The first parameter is the metadata key and the second parameter is the metadata value to use. This sets the metadata specified by the META statement. If the metadata value is null, it shall be treated as deleting any currently set item of metadata for that metadata key.

7.5.4 getNode

X3DNode X3DScene.getExportedNode(void*, char*)

The return value is a Node reference. The parameter is a char array defining the DEF name of the required node. If the browser cannot find the node name, an InvalidNodeException shall be generated.

7.5.5 namedNodeHandling

void X3DScene.updateExportedNode(void*, char*, char*)

void X3DScene.removeExportedNode(char*)

7.5.6 rootNodeHandling

void X3DScene.addRootNode(void*, CX3DNode)

void X3DScene.removeRootNode(void*, CX3DNode)

--- X3D separator bar ---

7.6 Node services

7.6.1 Node representation

Node services are implemented as the data type X3DNode. This is a base interface to represent any node in the system. Additional interfaces that extend the base X3DNode interface are defined as part of this specification and shall be supported. The additional interfaces represent each of the abstract node types as defined in ISO/IEC 19775-1 (see 2.[I19775]). An additional capability that a browser may support is to provide interfaces that represent the individual node types. If a browser supports this capability, it shall return TRUE for the browser property CONCRETE_NODES (see 7.3.24 getBrowserProperties).

7.6.2 getTypeName

char* X3DNode.getNodeName(void*)

The getTypeName service is implemented through the getNodeName function. For a built-in node the function shall return the node's specified type name. For an instance of a PROTO, the function shall return the name of the PROTO.

7.6.3 getType

int* X3DNode.getType(void*)

The getType service is implemented as the function getType(). The function shall return an array of int values that represent all of the base node types of which the node is composed. For example, a Group node returns an array of length two, with the two values X3DGroupingNode and X3DBoundedObject. The definition of the int values shall be found in the X3DNodeTypes interface as constants. The constants that shall be defined in the X3DNodeTypes interface is defined in Table 7.4.

Table 7.4 — Node type constant value definitions

Abstract Node Type C Constant Value
X3DBoundedObject static int X3DBoundedObject 1
X3DMetadataObject static int X3DMetadataObject 2
X3DUrlObject static int X3DUrlObject 3
X3DAppearanceNode static int X3DAppearanceNode 10
X3DAppearanceChildNode static int X3DAppearanceChildNode 11
X3DMaterialNode static int X3DMaterialNode 12
X3DTextureNode static int X3DTextureNode 13
X3DTexture2DNode static int X3DTexture2DNode 14
X3DTextureTransformNode static int X3DTextureTransformNode 16
X3DTextureTransform2DNode static int X3DTextureTransform2DNode 17
X3DGeometryNode static int X3DGeometryNode 18
X3DGeometricPropertyNode static int X3DGeometricPropertyNode 19
X3DParametricGeometryNode static int X3DParametricGeometryNode 20
X3DNurbsSurfaceGeometryNode static int X3DNurbsSurfaceGeometryNode 21
X3DColorNode static int X3DColorNode 22
X3DCoordinateNode static int X3DCoordinateNode 23
X3DNormalNode static int X3DNormalNode 24
X3DTextureCoordinateNode static int X3DTextureCoordinateNode 25
X3DFontStyleNode static int X3DFontStyleNode 26
X3DProtoInstance static int X3DProtoInstance 27
X3DChildNode static int X3DChildNode 28
X3DBindableNode static int X3DBindableNode 29
X3DBackgroundNode static int X3DBackgroundNode 30
X3DGroupingNode static int X3DGroupingNode 31
X3DShapeNode static int X3DShapeNode 32
X3DInterpolatorNode static int X3DInterpolatorNode 33
X3DLightNode static int X3DLightNode 34
X3DScriptNode static int X3DScriptNode 35
X3DSensorNode static int X3DSensorNode 36
X3DEnvironmentalSensorNode static int X3DEnvironmentalSensorNode 37
X3DKeyDeviceSensorNode static int X3DKeyDeviceSensorNode 38
X3DNetworkSensorNode static int X3DNetworkSensorNode 39
X3DPointingDeviceSensorNode static int X3DPointingDeviceSensorNode 40
X3DDragSensorNode static int X3DDragSensorNode 41
X3DTouchSensorNode static int X3DTouchSensorNode 42
X3DSequencerNode static int X3DSequencerNode 43
X3DTimeDependentNode static int X3DTimeDependentNode 44
X3DSoundSourceNode static int X3DSoundSourceNode 45
X3DTriggerNode static int X3DTriggerNode 46
X3DInfoNode static int X3DInfoNode 47
X3DNurbsControlCurveNode static int X3DNurbsControlCurveNode 48

Nodes types defined as standard extension types, but not formalized as part of this specification shall start with constant value of 100. Types that are browser-specific extensions to this interface shall have a starting constant value offset of 1000.

If this node instance represents a prototype instance, this function shall return an array of length one with the value X3DProtoInstance as the value. The implementation node type shall be made available through the X3DProtoInstance.getImplementationType() function.

7.6.4 getField

X3DField X3DNode.getField(void*, char*)

The getField service is implemented as the function getField(char*), which allows access to all field types. The normal field name or with the set_ or _changed modifier may be used to describe the writable and readable fields respectively or either form may be used to access a readable and writable field.

7.6.5 getFieldDefinitions

X3DFieldDefinition* X3DNode.getFieldDefinitions(void*)

Fetch a list of all field defintions of a node. Nodes that do not contain any fields (for example a blank PROTO) shall return null.

7.6.6 dispose

void X3DNode.dispose(void*)

Dispose shall notify the browser that the C implementation is no longer interested in this node instance and it is free to do as required with the node representation. Any further requests to functions of this instance of the node reference shall generate an InvalidNodeException. If two separate instances of the same data type represent the same node (as defined by the equals() function returning true) and one has dispose called, this shall not effect the other instance.

--- X3D separator bar ---

7.7 Field services

7.7.1 Field representation

The C implementation of the field services does not directly follow the model outlined in 7.7, Field Services of ISO/IEC 19775-2 (see 2.[I19775]). Instead, it makes heavy use of the object-oriented nature of C to provide directly the capabilities suggested by the services specified. All the services are implemented in the data types provided in the org.web3d.x3d.sai package.

The basic field is defined by the interface X3DField. A derived interface of this, MField is used to represent the sub set of all field types that represent multiple-values. From these base interfaces, there shall be derived interfaces for each of the appropriate field types.

The following outlines how the C binding conforms to the requirements of the SAI.

7.7.2 getAccessType

getAccessType is represented by two functions of the X3DField interface.

bool X3DField.isWritable(void*)

bool X3DField.isReadable(void*)

These functions describe whether the field is readable or writable at the time the function is called. The values that the functions return may change over time as the lifecycle of the node changes and can be determined from Table 4.2 — Permitted field access capabilities during the node lifecycle of ISO/IEC 19775-2 (see 2.[I19775]).

7.7.3 getType

int X3DFieldDefintion.getType(void*)

The type of an X3DField is determined by the field definition data type X3DFieldDefinition and it's function getType(). The getType() function returns an identifier of the type of field that the instance of the interface represents. The list of legal type identifiers is included as public final variables in the interface X3DFieldTypes. The return value of the getType() function shall be one of these values.

7.7.4 getName

char* X3DFieldDefintion.getName(void*)

The getName service is supported through the getName() function on the X3DFieldDefinition that accompanies the given field.

7.7.5 getValue

type X3DField.getValue(void*)

void X3DField.getValue(void*, type)

int MField.getSize(void*)

The getValue() function returns values in a format appropriate to the individual field type. For single valued field types, the return value of the function is used to pass values to user code. If the function returns an array of values, the implementation may reuse return value references between calls to the functions. User code should not expect to receive consistent data reference values if it holds an array value.

For multi-valued fields derived from the base interface MField, the getSize() function provides a number which is the number of elements currently set in that field. An element is the equivalent single value type. For example:

field MFFloat [ 0.5 0.2 14]

would return a size of three, where

field MFVec3f [ 0.5 0.2 14]

would return a size of one. The corresponding getValue() field defines void as the return type for accessors. The parameter takes a user provided array of the appropriate data type (see Table 5.4 — Mapping of X3D data types to C primitive data types) into which the values shall be copied. If the array is not of sufficient length to contain all the field values, the browser implementation shall copy as many values in as possible, starting from the zeroth element of the underlying field value.

A get1Value() function is provided for all multi-valued fields. This allows access to a single value out of the many values. When an attempt is made to access a value at an index greater than the number of items in that field, a ArrayIndexOutOfBoundsException shall be generated. The following example shows signature of this function for setting an MFInt32 field:

void MFInt32.set1Value(void* obj, int index, int value)

The SFImage/MFImage field types shall define an additional behaviour. The getValue service will be supplemented by the getImage() function. This shall return an instance. Typically, the concrete data type will be an instance, but this shall not be required. User code may make use of the instanceof operator to check for this. Drawing to this image shall have no effect on the visual output or the value of the field, until the corresponding setImage() function is called. (See B.4.18 MFImage for more details)

7.7.6 setValue

void X3DField.setValue(void*, type)

A set1Value() function is provided for MFields. This allows the ability to change a single value of a field without having to re-create the entire array of values. When an attempt is made to set a value at an index greater than the number of items in that field, a ArrayIndexOutOfBoundsException shall be generated.

To append a value to a value to an exising multi-valued field, an append() function shall be defined. This shall place the new value on the end of the existing array and increase the size by one.

To insert a value into a given position of an existing multi-valued field, an insertValue() function shall be defined. This function shall take the index of the value to be inserted and the value. All items from the index to the end of the array shall be moved up one index value and the new value copied into the now vacant index position. The size shall be increased by one. When an attempt is made to set a value at an index greater than the number of items in that field, a ArrayIndexOutOfBoundsException shall be generated.

To completely clear a field, a clear() function shall be defined. When this is called, all values set in the field shall be removed and the size is set to zero.

To remove an individual value from a field, a remove() function shall be defined. This shall take the index of the item to be removed. The return value shall be null. All items above the given index shall move down one position in the underlying representation.

The SFImage/MFImage field types shall define an additional behaviour. The setValue service is supplemented by setImage() functions. These shall have the following signature:

void SFImage.setImage(void*, Image)

void SFImage.setSubImage(void*, Image, int, int, int, int, int, int)

The former replaces the entire image with the new image. There shall be no restrictions and shall be treated the same as the integer-based SFImage. The second form copies the image as a sub-image region to replace a portion of the current image. The integer parameters, in order, are: source image width, source image height, source image x location offset, source image y location offset, destination image x location offset and destination y location offset. The sub-image set shall not resize the base image representation and therefore performs an intersection clip of the provided image. The user provided image shall be of the same format (pixel depth, pixel representation) as the original image obtained through the getImage() function.

7.7.7 registerFieldInterest

void X3DField.addFieldEventListener(void*, X3DFieldEventListener)

void X3DField.removeFieldEventListener(void*, X3DFieldEventListener)

This specification only requires that there shall be listeners available for readable fields. Browser implementations may also permit adding listeners to writable fields. It shall be an error to register a listener with initialize-only fields.

The field that caused the listener to trigger shall be made available through the getSource() function.

7.7.8 dispose

void X3DField.dispose(void*)

--- X3D separator bar ---

7.8 Route services

7.8.1 Route representation

Route services are implemented as the interface X3DRoute. This interface has four functions as defined in the remainder of this subclause.

7.8.2 getSourceNode

X3DNode X3DRoute.getSourceNode(void*)

The node representation that is used at the source of the ROUTE is returned.

7.8.3 getSourceField

char* X3DRoute.getSourceField(void*)

The name of the source field in the source node is returned.

7.8.4 getDestinationNode

X3DNode X3DRoute.getDestinationNode(void*)

The node representation that is used at the source of the ROUTE is returned.

7.8.5 getDestinationField

char* X3DRoute.getDestinationField(void*)

The name of the destination field in the node is returned.

7.8.6 dispose

void X3Route.dispose(void*)

--- X3D separator bar ---

7.9 Prototype services

7.9.1 isExternproto

X3DProtoDeclaration

X3DExternProtoDeclaration

Protos are represented by the specific data type for the capability. This service request is implemented by using the data types and the C instanceof operator.

7.9.2 createInstance

X3DProtoInstance X3DProtoDeclaration.createInstance(void*)

X3DProtoInstance X3DExternProtoDeclaration.createInstance(void*)

Both interfaces have a createInstance() function that instantiates a new prototype instance. If the EXTERNPROTO instance has not yet been fetched, the implementation shall throw InvalidNodeException.

7.9.3 getFieldDefinitions

X3DFieldDefinition* X3DProtoDeclaration.getFieldDefinitions(void*)

X3DFieldDefinition* X3DExternProtoDeclaration.getFieldDefinitions(void*)

7.9.4 checkLoadState

int X3DExternProtoDeclaration.getLoadState(void*)

The values returned by this function are defined in Table 5.5 — Load state type value defintions.

7.9.5 requestImmediateLoad

void X3DExternProtoDeclaration.loadNow(void*)

7.9.6 dispose

void X3DProtoDeclaration.dispose(void*)

void X3DExternProtoDeclaration.dispose(void*)

--- X3D separator bar ---

7.10 Script content services

7.10.1 implementationMarkerInterface

C code that is to run as a script is marked by implementing the X3DScriptImplementation interface.

void X3DScriptImplementation.setBrowser(void*, Browser browser)
void X3DScriptImplementation.setFields(void*, CX3DScriptNode externalView, Map fields)
void X3DScriptImplementation.initialize(void*)
void X3DScriptImplementation.eventsProcessed(void*)
void X3DScriptImplementation.shutdown(void*)

7.10.2 prepareEvents notification

For efficiency reasons, a derived interface is defined for scripts that wish to know about pre-"event cascade" processing.  The derived interface shall be named X3DPerFrameObserverScript and extends X3DScriptImplementation. The additional function signature shall be:

void X3DPerFrameObserverScript.prepareEvents(void*)

--- X3D separator bar ---

7.11 Matrix services

7.11.1 Description

The matrix services are provided by two specialized data types that represent a 3x3 and 4x4 matrix. The internal implementation of these data types are not defined. When initially constructed, both matrices default to an identity matrix.

7.11.2 Matrix3

struct Matrix3 {
      Matrix3(void* obj);
      void (*setIdentity)(void* obj);
      void (*set)(void* obj, int row, int column)
      float (*get)(void* obj,int row, int column)
      void (*setTransform)(void* obj,
                           SFVec2f translation,
                           SFVec3f rotation,
                           SFVec2f scale,
                           SFVec3f scaleOrientation,
                           SFVec2f center)
     void (*getTransform)(void* obj, 
                          SFVec2f translation,
                          SFVec3f rotation,
                          SFVec2f scale)
     Matrix3 (*inverse)(void* obj)
     Matrix3 (*transpose)(void* obj)
     Matrix3 (*multiplyLeft)(void* obj , Matrix3 mat)
     Matrix3 (*multiplyRight)(void* obj, Matrix3 mat)
     Matrix3 (*multiplyRowVector)(void* obj, SFVec3f vec)
     Matrix3 (*multiplyColVector)(void* obj, SFVec3f vec)
}

7.11.3 Matrix4

struct Matrix4 {
      Matrix4(void* obj);
      void (*setIdentity)(void* obj);
      void (*set)(void* obj ,int row, int column)
      float (*get)(void* obj ,int row, int column)
      void (*setTransform)(void* obj ,SFVec3f translation,
                           SFRotation rotation,
                           SFVec3f scale,
                           SFRotation scaleOrientation,
                           SFVec3f center)
      void (*getTransform)(void* obj ,SFVec3f translation,
                           SFRotation rotation,
                           SFVec3f scale)
      Matrix3 (*inverse)(void* obj)
      Matrix3 (*transpose)(void* obj)
      Matrix3 (*multiplyLeft)(void* obj ,Matrix4 mat)
      Matrix3 (*multiplyRight)(void* obj ,Matrix4 mat)
      Matrix3 (*multiplyRowVector)(void* obj ,SFVec3f vec)
      Matrix3 (*multiplyColVector)(void* obj ,SFVec3f vec)
}

--- X3D separator bar ---