ParallelGraphics
Home  »  Developer Zone  »  Products  »  VrmlPad  »  References  »  MFValue
Up to References

Document 

Documents 

Entity 

Field 

Fields 

MFValue 

Node 

Nodes 

Proto 

Protos 

Range 

Route 

Routes 

SFColor 

SFRotation 

SFVec2f 

SFVec3f 

VrmlMatrix 

Window 


Subscribe to Newsletter
 


Google Searchsite search:

 

%(domain)s %(domain)s
Install Cortona VRML Client!

Outline 3D

Try RobinZone!


MFValue

MFValue Collection

 
Add
 
Clear
 
Item
 
_NewEnum
 
Array
 
Count
 
Remove

See also: Using collections, Using field value objects.
 
Add method, ( [Value], [Before] ) As Object.

Adds a new value to the specified MFValue collection. Returns a Node object that represents the node to be added for MFNode field type, or Nothing for all other field types.

Value (Optional)
A Variant that represents the value you want to add.

The following table summarizes the results of using the Add property depending on a field type of the Field object.

TypeAdd Results
SFImageAdds an Integer (or compatible) number.
MFColorAdds an array of three Single (or compatible) numbers, that represents the Red, Green and Blue components of the value.
MFFloatAdds a Single (or compatible) value.
MFInt32Adds a Long (or compatible) value.
MFNodeAdds a String value, that represents the typename of a new node,
or a Proto object, that represents a template for a new node,
or a Node object, that represents the definition for a new node (by means of the DEF/USE syntax).
MFRotationAdds an array of four Single (or compatible) numbers, that represents the X, Y, Z and Angle components of the value.
MFStringAdds a String value.
MFTimeAdds a Double (or compatible) value.
MFVec2fAdds an array of two Single (or compatible) numbers, that represents the X and Y components of the value.
MFVec3fAdds an array of three Single (or compatible) numbers, that represents the X, Y and Z components of the value.

Omitting the Value argument or adding Empty to the MFValue collection adds a default value, that is 0 0 1 0 for MFRotation, "" for MFString and so on.

Before (Optional)
An index of a new item in the collection. The value to be added is inserted in the collection before the value identified by the Before argument.
If a numeric expression, Before must be a number from 1 to Count.
If an object expression, Before is a Node object from the collection.

By default, a new subvalue is inserted at the end of the collection.

The following VBScript macro adds a Shape node to the children field, adds reference to this node and then inserts reference to a parent node before the Shape node.

Set f = RootNodes.Add("Group")("children")
f.Add "Shape"
f.Add f(1)
f.Add f.Owner, 1




 
Array property, read-only, Variant.

Return an array of all subvalues in the specified collection. The largest available subscript for the first dimension of the array is one less than the value of the collection's Count property.

The following table summarizes the results of using the Array property depending on a field type of the Field object.

TypeResults
SFImageArray of Integer numbers.
MFColorTwo-dimensional array N x 3 of Single numbers, that represents the Red, Green and Blue components of the value.
MFFloatArray of Single numbers.
MFInt32Array of Long numbers.
MFNodeArray of Node objects.
MFRotationTwo-dimensional array N x 4 of Single numbers, that represents the X, Y, Z and Angle components of the value.
MFStringArray of String values.
MFTimeArray of Double numbers.
MFVec2fTwo-dimensional array N x 2 of Single numbers, that represents the X and Y components of the value.
MFVec3fTwo-dimensional array N x 3 of Single numbers, that represents the X, Y and Z components of the value.

The following example is a Visual C++ code snippet uses the Array property to iterate through all subvalues of a MFVec3f field and calculate a bounding box of the points.

VARIANT varVal, varArr, varElem;

VariantInit( &varVal );
pField->get_Value( &varVal );

MFValue *pValue;
varVal.pdispVal->QueryInterface( IID_MFValue, (void**) &pValue);
VariantClear( &varVal );

VariantInit( &varArr );
pValue->get_Array( &varArr );
pValue->Release();

VariantInit( &varElem );

float aMin [3] = { FLT_MAX, FLT_MAX, FLT_MAX };
float aMax [3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };

long lBound;
SafeArrayGetUBound( varArr.pArray, 1, &lBound );

for (long i = 0; i <= lBound; i++)
{
  for (long j = 0; j < 3; j++)
  {
    long aInds [2] = { i, j };
    SafeArrayGetElement( varArr.pArray, aInds, &varElem );
    VariantChangeType( &varElem, &varElem, 0, VT_R4 );
    aMin[j] = min( aMin[j], varElem.fltVal);
    aMax[j] = max( aMax[j], varElem.fltVal);
    VariantClear( &varElem );
  }
}
VariantClear( &varArr );




 
Clear method.

Deletes all values from the specified collection and sets the Count property to 0.




 
Count property, read-only, Long.

Returns the number of items in the specified collection.




 
Item property, default, read/write, ( Index As Long ) As Variant.

Gets or sets a subvalue of the specified collection.

Index
An index in the collection representing the appropriate subvalue (a number from 1 to the value of the collection's Count property).

The following table summarizes the results of using the Item property depending on a field type of the Field object.

TypeGet ResultsSet Results
SFImageGets an Integer value.Sets an Integer (or compatible) value.
MFColorReturns a SFColor object.Sets an array of three Single (or compatible) numbers, that represents the Red, Green and Blue components of the value.
MFFloatGets a Single field value.Sets a Single (or compatible) value.
MFInt32Gets a Long field value.Sets a Long (or compatible) value.
MFNodeReturns a Node object.Sets a String value, that represents the typename of a new node,
or a Proto object, that represents a template for a new node,
or a Node object, that represents the definition for a new node (by means of the DEF/USE syntax).
MFRotationReturns a SFRotation object.Sets an array of four Single (or compatible) numbers, that represents the X, Y, Z and Angle components of the value.
MFStringGets a String value.Sets a String value.
MFTimeGets a Double value.Sets a Double (or compatible) value.
MFVec2fReturns a SFVec2f object.Sets an array of two Single (or compatible) numbers, that represents the X and Y components of the value.
MFVec3fReturns a SFVec3f object.Sets an array of three Single (or compatible) numbers, that represents the X, Y and Z components of the value.

Assigning Empty to the Item property sets a subvalue of the specified collection to the initial value, that is 0 0 1 0 for MFRotation, "" for MFString and so on.




 
Remove method, ( Index As Long ).

Removes a subvalue from the specified collection.

Index
An index of the subvalue in the collection (a number from 1 to the value of the collection's Count property).

If the subvalue is a named node, all references to the node will be deleted. If the subvalue contains declarations that have references outside the subvalue, all such references will also be deleted.




 
_NewEnum property, read-only.

References subvalues in the specified collection.

With C++, you can browse a collection to find a particular item by using the _NewEnum or the Item properties. In Visual Basic and VBScript, you do not need to use the _NewEnum property, because it is automatically used in the implementation of For Each ... Next or in For ... in statement in JavaScript.

The following example replaces X and Y coordinates in a field of the MFVec2f type.

Dim Values As MFValue
Dim v As SFVec2f
Set Values = Document("TexCoords")("point").Values
For Each v In Values
  v.Set v.y, v.x
Next





Last updated: Sat, 19 Jul 2008
© 2000-2008 ParallelGraphics. All rights reserved. Terms of use.