예제 #1
0
object allocByte(int size)
{
    object newObj;

    newObj = allocObject((size + 1) / 2);
    /* negative size fields indicate bit objects */
    sizeField(newObj) = -size;
    return newObj;
}
예제 #2
0
/*!
	@function	BoxV2ToObject
	
	@abstract	Attempt to convert a VRML 2 Box node to a Quesa object.
	
	@param		ioNode		Node to convert.
	
	@result		An object reference, or NULL on failure.
*/
CQ3ObjectRef	BoxV2ToObject( PolyValue& ioNode )
{
	TQ3Vector3D		sizes = {
		2.0f, 2.0f, 2.0f
	};
	
	PolyValue::Dictionary&	theDict( ioNode.GetDictionary() );

	if (IsKeyPresent( theDict, "size" ))
	{
		PolyValue&	sizeField( theDict["size"] );
		
		if ( (sizeField.GetType() == PolyValue::kDataTypeArrayOfFloat) or
			(sizeField.GetType() == PolyValue::kDataTypeArrayOfInt) )
		{
			PolyValue::FloatVec&	theFloats( sizeField.GetFloatVec() );
			if (theFloats.size() == 3)
			{
				sizes.x = theFloats[0];
				sizes.y = theFloats[1];
				sizes.z = theFloats[2];
			}
		}
	}
	
	TQ3BoxData boxData = {
		{ -sizes.x/2, -sizes.y/2, -sizes.z/2 },
		{ 0.0f, sizes.y, 0.0f },
		{ 0.0f, 0.0f, sizes.z },
		{ sizes.x, 0.0f, 0.0f },
		NULL, NULL
	};
	
	CQ3ObjectRef	theObject( Q3Box_New( &boxData ) );
	
	return theObject;
}