⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cvwrite.cpp

📁 Windows上的MUD客户端程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void
QvTransformSeparator::write(ostream &strm)
{
    ANNOUNCE(TransformSeparator);

    // We need to "push" just the transformation stack. We'll
    // accomplish this by just pushing a no-op transformation onto
    // that stack. When we "pop", we'll restore that stack to its
    // previous str.


    indent++;
    for (int i = 0; i < getNumChildren(); i++)
	getChild(i)->write(strm);

    // Now do the "pop"
	END_BRACK;
    indent--;
}

//////////////////////////////////////////////////////////////////////////////
//
// Properties.
//
//////////////////////////////////////////////////////////////////////////////

#define DO_PROPERTY(className, stackIndex, propName)		\
void									      				\
className::write(ostream &strm)					    	\
{															\
	int i;								      				\
    ANNOUNCE(propName);						     			\
    indent++;			

#define DO_TYPED_PROPERTY(className, stackIndex, eltType)	\
void									      				\
className::write(ostream &strm)					      	\
{															\
	int i;								      				\
    ANNOUNCE(eltType);						      			\
    indent++;			

#define END_PROPERTY 										\
    END_BRACK;					      						\
   	indent--;												\
}

DO_PROPERTY(QvBaseColor,			BaseColorIndex, BaseColor)
	MFIELD(rgb, 3);
END_PROPERTY

DO_PROPERTY(QvCoordinate3,		Coordinate3Index, Coordinate3) 
	MFIELD(point, 3);
END_PROPERTY

DO_PROPERTY(QvFontStyle,		FontStyleIndex, FontStyle) 
	FIELD(size);
	ENUMFIELD(family);
	BITMASK(style);
END_PROPERTY


DO_PROPERTY(QvMaterial,			MaterialIndex, Material)
	MFIELD(ambientColor, 3);
	MFIELD(diffuseColor, 3);
	MFIELD(specularColor, 3);
	MFIELD(emissiveColor, 3);
	MFIELD(shininess, 1);
	MFIELD(transparency, 1);
END_PROPERTY

DO_PROPERTY(QvMaterialBinding,		MaterialBindingIndex, MaterialBinding)
	ENUMFIELD(value);
END_PROPERTY

DO_PROPERTY(QvNormal,			NormalIndex, Normal)
	MFIELD(vector, 3);
END_PROPERTY

DO_PROPERTY(QvNormalBinding,		NormalBindingIndex, NormalBinding)
	ENUMFIELD(value);
END_PROPERTY

DO_PROPERTY(QvShapeHints,		ShapeHintsIndex, ShapeHints)
	ENUMFIELD(vertexOrdering);
	ENUMFIELD(shapeType);
	ENUMFIELD(faceType);
	FIELD(creaseAngle);
END_PROPERTY

DO_PROPERTY(QvTextureCoordinate2,	TextureCoordinate2Index, TextureCoordinate2)
	MFIELD(point, 2);
END_PROPERTY

DO_PROPERTY(QvTexture2,			Texture2Index, Texture2)
	STRINGFIELD(filename);
	// This has not been implemented by QvLib yet    TBA
	// IMAGEFIELD(image)
	ENUMFIELD(wrapS);
	ENUMFIELD(wrapT);
END_PROPERTY

DO_PROPERTY(QvTexture2Transform,	Texture2TransformationIndex, Texture2Transformation)
	FIXEDARRAYFIELD(translation, 2);
	FIELD(rotation);
	FIXEDARRAYFIELD(scaleFactor, 2);
	FIXEDARRAYFIELD(center, 2);
END_PROPERTY


DO_TYPED_PROPERTY(QvDirectionalLight,	LightIndex, DirectionalLight)
	BOOLFIELD(on);
	FIELD(intensity);
	FIXEDARRAYFIELD(color, 3);
	FIXEDARRAYFIELD(direction,3);
END_PROPERTY

DO_TYPED_PROPERTY(QvPointLight,		LightIndex, PointLight)
	BOOLFIELD(on);
	FIELD(intensity);
	FIXEDARRAYFIELD(color, 3);
	FIXEDARRAYFIELD(location,3);
END_PROPERTY

DO_TYPED_PROPERTY(QvSpotLight,		LightIndex, SpotLight)
	BOOLFIELD(on);
	FIELD(intensity);
	FIXEDARRAYFIELD(color, 3);
	FIXEDARRAYFIELD(location,3);
	FIXEDARRAYFIELD(direction,3);
	FIELD(dropOffRate);
	FIELD(cutOffAngle);
END_PROPERTY


DO_TYPED_PROPERTY(QvOrthographicCamera,	CameraIndex, OrthographicCamera)
	FIXEDARRAYFIELD(position,3);
	ROTATIONFIELD(orientation);
	FIELD(focalDistance);
	FIELD(height);
END_PROPERTY

DO_TYPED_PROPERTY(QvPerspectiveCamera,	CameraIndex, PerspectiveCamera)
	FIXEDARRAYFIELD(position,3);
	ROTATIONFIELD(orientation);
	FIELD(focalDistance);
	FIELD(heightAngle);
END_PROPERTY


DO_TYPED_PROPERTY(QvTransform,	     TransformationIndex, Transform)
	FIXEDARRAYFIELD(translation,3);
	ROTATIONFIELD(rotation);
	FIXEDARRAYFIELD(scaleFactor,3);
	ROTATIONFIELD(scaleOrientation);
	FIXEDARRAYFIELD(center,3);
END_PROPERTY

DO_TYPED_PROPERTY(QvRotation,	     TransformationIndex, Rotation)
	ROTATIONFIELD(rotation);
END_PROPERTY

DO_TYPED_PROPERTY(QvMatrixTransform, TransformationIndex, MatrixTransform)
	MATRIXFIELD(matrix);
END_PROPERTY

DO_TYPED_PROPERTY(QvTranslation,     TransformationIndex, Translation)
	FIXEDARRAYFIELD(translation,3);
END_PROPERTY

DO_TYPED_PROPERTY(QvScale,	     TransformationIndex, Scale)
	FIXEDARRAYFIELD(scaleFactor,3);
END_PROPERTY


//////////////////////////////////////////////////////////////////////////////
//
// Shapes.
//
//////////////////////////////////////////////////////////////////////////////

#define DO_SHAPE(classNm, name) 			\
void classNm::write(ostream &strm)	\
{											\
	int i;									\
  	ANNOUNCE(name);							\
  	indent++;

#define END_SHAPE							\
	END_BRACK;								\
	indent--;								\
}	
 

DO_SHAPE(QvAsciiText, AsciiText)
 	MSTRINGFIELD(string, 1);
 	MFIELD(width, 1);
	FIELD(spacing);
	FIELD(justification);	
END_SHAPE

DO_SHAPE(QvCube, Cube)
 	FIELD(width);
	FIELD(height);
	FIELD(depth);	
END_SHAPE


DO_SHAPE(QvCone, Cone)
	BITMASK(parts);
	FIELD(bottomRadius);
	FIELD(height);	
 END_SHAPE
	
DO_SHAPE(QvCylinder, Cylinder)
	BITMASK(parts);
	FIELD(radius);	
 	FIELD(height);
 END_SHAPE


DO_SHAPE(QvIndexedFaceSet, IndexedFaceSet)
	MFIELD(coordIndex, 1);
	MFIELD(materialIndex, 1);
	MFIELD(normalIndex, 1);
	MFIELD(textureCoordIndex, 1);
END_SHAPE

DO_SHAPE(QvIndexedLineSet, IndexedLineSet)
	MFIELD(coordIndex, 1);
	MFIELD(materialIndex, 1);
	MFIELD(normalIndex, 1);
	MFIELD(textureCoordIndex, 1);
 END_SHAPE


DO_SHAPE(QvPointSet, PointSet)
	FIELD(startIndex);
	FIELD(numPoints);
 END_SHAPE

DO_SHAPE(QvSphere, Sphere)
	FIELD(radius);
 END_SHAPE

//
// Not really a shape, but this does what it's supposed to.
//
DO_SHAPE(QvInfo, Info)
	STRINGFIELD(string)
END_SHAPE;


//////////////////////////////////////////////////////////////////////////////
//
// WWW-specific nodes.
//
//////////////////////////////////////////////////////////////////////////////

#define DO_WWW(className, propName)		\
void									      				\
className::write(ostream &strm)					    	\
{															\
	int i;								      				\
    ANNOUNCE(propName);						     			\
    indent++;			

#define END_WWW												\
 	if (getNumChildren() > 0)			 					\
		getChild(0)->write(strm); 						\
	END_BRACK												\
	indent--;	 											\
	}

DO_WWW(QvWWWAnchor, WWWAnchor)
  	STRINGFIELD(name)
	ENUMFIELD(map)
END_WWW

DO_WWW(QvWWWInline, WWWInline)
	STRINGFIELD(name)
	FIXEDARRAYFIELD(bboxSize, 3)
	FIXEDARRAYFIELD(bboxCenter, 3)
END_WWW


//////////////////////////////////////////////////////////////////////////////
//
// Default traversal methods. These nodes have no effects during traversal.
//
//////////////////////////////////////////////////////////////////////////////

DEFAULT_write(QvUnknownNode)
DEFAULT_write(QvBackground)
#if defined(_QV_ENVIRONMENT_)
DEFAULT_write(QvEnvironment)
#endif
DEFAULT_write(QvSpin)
DEFAULT_write(QvSpinGroup)
DEFAULT_write(QvOrientationInterpolator)
DEFAULT_write(QvPositionInterpolator)
DEFAULT_write(QvInterpolator)
DEFAULT_write(QvSensor)
DEFAULT_write(QvTimeSensor)
DEFAULT_write(QvRoute)
DEFAULT_write(QvNavigationInfo)

//////////////////////////////////////////////////////////////////////////////

#undef ANNOUNCE
#undef END_BRACK
#undef DEFAULT_write
#undef DO_PROPERTY
#undef DO_SHAPE
#undef DO_TYPED_PROPERTY
#undef DO_WWW
#undef END_SHAPE
#undef END_PROPERTY
#undef END_WWW
#undef FIELD
#undef MFIELD
#undef BITMASK
#undef END_BRACK
#undef MATRIXFIELD

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -