void CVRMLFieldData::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();

	CX3DParser::printIndent(indent);
	fprintf(fp, "[%s]", CVRMLFieldData::getFieldTypeName(getFieldType()));

	switch (getFieldType())
	{
	case BOOLEAN_DATA:
		{
			CVRMLBooleanData *boolData = (CVRMLBooleanData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%s\n", boolData->getValue() ? "TRUE" : "FALSE");
		}
		break;

	case INT_DATA:
		{
			CVRMLIntData *intData = (CVRMLIntData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%d\n", intData->getValue());
		}
		break;

	case FLOAT_DATA:
		{
			CVRMLFloatData *floatData = (CVRMLFloatData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%f\n", floatData->getValue());
		}
		break;

	case DOUBLE_DATA:
		{
			CVRMLDoubleData *doubleData = (CVRMLDoubleData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%f\n", doubleData->getValue());
		}
		break;

	case STRING_DATA:
		{
			CVRMLStringData *stringData = (CVRMLStringData *)this;

			fprintf(fp, "\n");
			CX3DParser::printIndent(indent);
			fprintf(fp, "%s\n", stringData->getValue());
		}
		break;

	case NODE_DATA:
		{
			CVRMLNodeData *nodeData = (CVRMLNodeData *)this;

			fprintf(fp, "\n");

			jobject vrmlNode = ((CVRMLNodeData *)nodeData)->getValue();
			CX3DNode *node = CX3DNodeFactory::createNode(vrmlNode);
			if (node)
			{
				node->print(indent+1);
				delete node;
			}
			else
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "NULL\n");
			}
		}
		break;

	case BOOLEAN_ARRAY_DATA:
		{
			CVRMLBooleanArrayData *boolArrayData = (CVRMLBooleanArrayData *)this;

			int n = boolArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %s\n", i, boolArrayData->getValue(i) ? "TRUE" : "FALSE");
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case INT_ARRAY_DATA:
		{
			CVRMLIntArrayData *intArrayData = (CVRMLIntArrayData *)this;

			int n = intArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %d\n", i, intArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case FLOAT_ARRAY_DATA:
		{
			CVRMLFloatArrayData *floatArrayData = (CVRMLFloatArrayData *)this;

			int n = floatArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %f\n", i, floatArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case DOUBLE_ARRAY_DATA:
		{
			CVRMLDoubleArrayData *doubleArrayData = (CVRMLDoubleArrayData *)this;

			int n = doubleArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %f\n", i, doubleArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case STRING_ARRAY_DATA:
		{
			CVRMLStringArrayData *stringArrayData = (CVRMLStringArrayData *)this;

			int n = stringArrayData->count();
			fprintf(fp, " (n=%d)\n", n);

			int nMax = CX3DParser::getMaxPrintElemsForMFField();
			bool bPartialPrint = false;
			if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }

			for (int i=0; i<n; i++)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "[%d] %s\n", i, stringArrayData->getValue(i));
			}

			if (bPartialPrint)
			{
				CX3DParser::printIndent(indent);
				fprintf(fp, "...\n");
			}
		}
		break;

	case NODE_ARRAY_DATA:
		{
			CVRMLNodeArrayData *nodeArrayData = (CVRMLNodeArrayData *)this;

			int n = nodeArrayData->count();
			fprintf(fp, " (n=%d)\n", n);
			
			for (int i=0; i<nodeArrayData->count(); i++)
			{
				jobject vrmlNode = nodeArrayData->getValue(i);
				CX3DNode *node = CX3DNodeFactory::createNode(vrmlNode);
				if (node)
				{
					node->print(indent+1);
					delete node;
				}
				else
				{
					CX3DParser::printIndent(indent+1);
					fprintf(fp, "NULL\n");
				}
			}
		}
		break;
	}
}
void CX3DOpenHRPSegmentNode::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();
	int nMax = CX3DParser::getMaxPrintElemsForMFField();
	bool bPartialPrint = false;

	char *nodeName = getNodeName();
	if (nodeName)
	{
		float x, y, z;
		MFNode *nodes;
		int i, n;

		CX3DParser::printIndent(indent);
		fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType()));

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "children\n");
		nodes = getChildren();
		n = nodes->count();
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "name (%s)\n", m_name.getValue());

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "coord\n");
		CX3DNode *pCoord = getCoord()->getNode();
		if (pCoord) pCoord->print(indent+2);

		CX3DParser::printIndent(indent+1);
		getCenterOfMass()->getValue(x, y, z);
		fprintf(fp, "centerOfMass : (%f %f %f)\n", x, y, z);

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "displacers\n");
		nodes = getDisplacers();
		n = nodes->count();
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "mass (%f)\n", getMass()->getValue());

		CX3DParser::printIndent(indent+1);
		n = m_momentsOfInertia.count();
		fprintf(fp, "momentsOfInertia [%d]\n", n);
		if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }
		else { bPartialPrint = false; }
		CX3DParser::printIndent(indent+2);
		fprintf(fp, "(");
		for (i=0; i<n; i++)
		{
			fprintf(fp, "%f ", m_momentsOfInertia.getValue(i));
		}
		if (bPartialPrint) fprintf(fp, "...");
		fprintf(fp, ")\n");
	}
}
void CX3DOpenHRPHumanoidNode::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();
	int nMax = CX3DParser::getMaxPrintElemsForMFField();
	bool bPartialPrint = false;

	char *nodeName = getNodeName();
	if (nodeName)
	{
		float x, y, z, rot;
		MFNode *nodes;
		int i, n;

		CX3DParser::printIndent(indent);
		fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType()));

		CX3DParser::printIndent(indent+1);
		getCenter()->getValue(x, y, z);
		fprintf(fp, "center : (%f %f %f)\n", x, y, z);

		CX3DParser::printIndent(indent+1);
		getRotation()->getValue(x, y, z, rot);
		fprintf(fp, "rotation : (%f %f %f)(%f)\n", x, y, z, rot);

		CX3DParser::printIndent(indent+1);
		getScale()->getValue(x, y, z);
		fprintf(fp, "scale : (%f %f %f)\n", x, y, z);

		CX3DParser::printIndent(indent+1);
		getScaleOrientation()->getValue(x, y, z, rot);
		fprintf(fp, "scaleOrientation : (%f %f %f)(%f)\n", x, y, z, rot);

		CX3DParser::printIndent(indent+1);
		getTranslation()->getValue(x, y, z);
		fprintf(fp, "translation : (%f %f %f)\n", x, y, z);

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "name (%s)\n", m_name.getValue());

		CX3DParser::printIndent(indent+1);
		n = m_info.count();
		fprintf(fp, "info [%d]\n", n);
		if ((nMax > 0) && (n > nMax)) { n = nMax; bPartialPrint = true; }
		else { bPartialPrint = false; }
		for (i=0; i<n; i++)
		{
			CX3DParser::printIndent(indent+2);
			fprintf(fp, "%s\n", m_info.getValue(i));
		}
		if (bPartialPrint)
		{
			CX3DParser::printIndent(indent+2);
			fprintf(fp, "...\n");
		}

		CX3DParser::printIndent(indent+1);
		nodes = getJoints();
		n = nodes->count();
		fprintf(fp, "joints [%d]\n", n);
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}

		CX3DParser::printIndent(indent+1);
		nodes = getSegments();
		n = nodes->count();
		fprintf(fp, "segments [%d]\n", n);
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}

		CX3DParser::printIndent(indent+1);
		nodes = getSites();
		n = nodes->count();
		fprintf(fp, "sites [%d]\n", n);
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}

		CX3DParser::printIndent(indent+1);
		nodes = getHumanoidBody();
		n = nodes->count();
		fprintf(fp, "humanoidBody [%d]\n", n);
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}


		CX3DParser::printIndent(indent+1);
		fprintf(fp, "version (%s)\n", m_version.getValue());

		CX3DParser::printIndent(indent+1);
		nodes = getViewpoints();
		n = nodes->count();
		fprintf(fp, "viewpoints [%d]\n", n);
		for (i=0; i<n; i++)
		{
			CX3DNode *child = nodes->getNode(i);
			if (child)
			{
				child->print(indent+2);
			}
		}
	}
}