コード例 #1
0
// vrmlNodeからSphereオブジェクトを作る
CX3DSphereNode::CX3DSphereNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);
	
	// テンポラリノード(フィールド探査用)
	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "Sphere")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "solid") == 0)
						{
							m_solid.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "radius") == 0)
						{
							m_radius.setValue(data);
						}

						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #2
0
ファイル: Test_BoxNode.cpp プロジェクト: Aharobot/Client
void Test_printFieldsOfBoxNode(CX3DParser& parser, char *vrmlFile)
{
	// ---------------------------------------------
	// ---------------------------------------------
	if (!parser.parse(vrmlFile))
	{
		fprintf(stderr, "%s parse failed\n", vrmlFile);
		return;
	}

	CX3DParser::printLog("**** Fields of BoxNode ****\n");

	// ---------------------------------------------
	// ---------------------------------------------
	MFNode *pShapeNodes = parser.searchNodesFromAllChildrenOfRoot("Shape");
	if (pShapeNodes)
	{
		for (int i=0; i<pShapeNodes->count(); i++)
		{
			CX3DShapeNode *pShape = (CX3DShapeNode *)(pShapeNodes->getNode(i));

			if (pShape)
			{
				// --------------------------------------------------------
				//
				// --------------------------------------------------------
				SFNode *geometry = pShape->getGeometry();
				CX3DNode *pNode = geometry->getNode();

				// ---------------------------------------------
				// ---------------------------------------------
				if (pNode && pNode->getNodeType() == BOX_NODE)
				{
					CX3DBoxNode *pBoxNode = (CX3DBoxNode *)pNode;

					// ---------------------------------------------
					// ---------------------------------------------

					SFVec3f *sz = pBoxNode->getSize();
					printf("size : (%f, %f, %f)\n", sz->x(), sz->y(), sz->z());

					// solid
					SFBool *solid = pBoxNode->getSolid();
					printf("solid : %s\n", solid->getValue() ? "TRUE" : "FALSE");
				}
			}
		}

		delete pShapeNodes;
		pShapeNodes = NULL;
	}
}
コード例 #3
0
ファイル: CX3DHAnimSiteNode.cpp プロジェクト: Aharobot/Client
void CX3DHAnimSiteNode::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();

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

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

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "children\n");
		MFNode *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);
		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());
	}
}
コード例 #4
0
void Test_printChildrenOfRoot(CX3DParser& parser, char *vrmlFile)
{
	// ---------------------------------------------
	//  VRMLファイルをパースする
	// ---------------------------------------------
	if (!parser.parse(vrmlFile))
	{
		fprintf(stderr, "%s parse failed\n", vrmlFile);
		return;
	}

	CX3DParser::printLog("**** Children of Root Node ****\n");

	// ---------------------------------------------
	//  ルート直下のノードを得る
	// ---------------------------------------------
	MFNode *nodes = parser.getChildrenOfRootNode();

	if (nodes)
	{
		// ---------------------------------------------
		//  ノード名のみ表示
		// ---------------------------------------------
		for (int i=0; i<nodes->count(); i++)
		{
			CX3DNode *node = nodes->getNode(i);

			if (node)
			{
				printf("%s\n", node->getNodeName());
			}
		}

		// ---------------------------------------------
		//  後始末
		// ---------------------------------------------
		delete nodes;
		nodes = NULL;
	}
}
コード例 #5
0
ファイル: Test_GetDefNode.cpp プロジェクト: Aharobot/Client
void Test_printDefNode(CX3DParser& parser, char *vrmlFile, char *defName)
{
	// ---------------------------------------------
	// ---------------------------------------------
	if (!parser.parse(vrmlFile))
	{
		fprintf(stderr, "%s parse failed\n", vrmlFile);
		return;
	}

	CX3DParser::printLog("**** Node contents of defName(%s) ****\n", defName);

	// ---------------------------------------------
	// ---------------------------------------------
	CX3DNode *node = parser.getDefNode(defName);
	if (node)
	{
		node->print();

		delete node;
		node = NULL;
	}
}
コード例 #6
0
ファイル: Test_GetNodeName.cpp プロジェクト: Aharobot/Client
void Test_printNodeName(CX3DParser& parser, char *vrmlFile)
{
	// ---------------------------------------------
	// ---------------------------------------------
	if (!parser.parse(vrmlFile))
	{
		fprintf(stderr, "%s parse failed\n", vrmlFile);
		return;
	}

	CX3DParser::printLog("**** Node names of (%s) ****\n", vrmlFile);

	// ---------------------------------------------
	// ---------------------------------------------
	MFNode *nodes = parser.getChildrenOfRootNode();

	if (nodes)
	{
		// ---------------------------------------------
		// ---------------------------------------------
		for (int i=0; i<nodes->count(); i++)
		{
			CX3DNode *node = nodes->getNode(i);

			if (node)
			{
				printf("%s\n", node->getNodeName());
			}
		}

		// ---------------------------------------------
		// ---------------------------------------------
		delete nodes;
		nodes = NULL;
	}
}
コード例 #7
0
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");
	}
}
コード例 #8
0
// vrmlNodeからOpenHRPSegmentオブジェクトを作る
CX3DOpenHRPSegmentNode::CX3DOpenHRPSegmentNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);

	// テンポラリノード(フィールド探査用)
	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "Segment")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "children") == 0)
						{
							m_children.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "name") == 0)
						{
							m_name.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "coord") == 0)
						{
							m_coord.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "centerOfMass") == 0)
						{
							m_centerOfMass.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "displacers") == 0)
						{
							m_displacers.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "mass") == 0)
						{
							m_mass.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "momentsOfInertia") == 0)
						{
							m_momentsOfInertia.setValue(data);
						}

						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #9
0
ファイル: CVRMLFieldData.cpp プロジェクト: Aharobot/SIGServer
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;
	}
}
コード例 #10
0
// vrmlNodeからPointLightオブジェクトを作る
CX3DPointLightNode::CX3DPointLightNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);
	
	// テンポラリノード(フィールド探査用)
	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "PointLight")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "ambientIntensity") == 0)
						{
							m_ambientIntensity.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "color") == 0)
						{
							m_color.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "intensity") == 0)
						{
							m_intensity.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "location") == 0)
						{
							m_location.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "radius") == 0)
						{
							m_radius.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "attenuation") == 0)
						{
							m_attenuation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "on") == 0)
						{
							m_on.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "global") == 0)
						{
							m_global.setValue(data);
						}

						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #11
0
CX3DTextureTransformNode::CX3DTextureTransformNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);
	
	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "TextureTransform")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "center") == 0)
						{
							m_center.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "rotation") == 0)
						{
							m_rotation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "scale") == 0)
						{
							m_scale.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "translation") == 0)
						{
							m_translation.setValue(data);
						}

						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #12
0
ファイル: CX3DViewpointNode.cpp プロジェクト: Aharobot/Client
CX3DViewpointNode::CX3DViewpointNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);
	
	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "Viewpoint")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "fieldOfView") == 0)
						{
							m_fieldOfView.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "jump") == 0)
						{
							m_jump.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "retainUserOffsets") == 0)
						{
							m_retainUserOffsets.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "orientation") == 0)
						{
							m_orientation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "position") == 0)
						{
							m_position.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "centerOfRotation") == 0)
						{
							m_centerOfRotation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "description") == 0)
						{
							m_description.setValue(data);
						}

						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #13
0
CX3DOpenHRPHumanoidNode::CX3DOpenHRPHumanoidNode(jobject vrmlNode)
{
	if (!vrmlNode)
	{
		m_vrmlNode = NULL;
		return;
	}

	CJNIUtil *ju = CJNIUtil::getUtil();

	if (!ju->isInstanceOfVRMLNode(vrmlNode))
	{
		fprintf(stderr, "vrmlNode is not instance of VRMLNode [%s:%d]\n", __FILE__, __LINE__);
		exit(1);
	}

	m_vrmlNode = ju->env()->NewGlobalRef(vrmlNode);

	CX3DNode *tmpNode = new CX3DNode(vrmlNode);
	if (tmpNode)
	{
		char *nodeName = tmpNode->getNodeName();

		if (nodeName && strcmp(nodeName, "Humanoid")==0)
		{
			int n = tmpNode->countFields();
			for (int i=0; i<n; i++)
			{
				char *pFieldName = tmpNode->getFieldName(i);
				if (pFieldName)
				{
					std::string fieldName = pFieldName;

					CVRMLFieldData *data = tmpNode->createFieldValue((char *)(fieldName.c_str()));
					if (data)
					{
						if (strcmp(fieldName.c_str(), "center") == 0)
						{
							m_center.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "rotation") == 0)
						{
							m_rotation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "scale") == 0)
						{
							m_scale.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "scaleOrientation") == 0)
						{
							m_scaleOrientation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "translation") == 0)
						{
							m_translation.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "name") == 0)
						{
							m_name.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "info") == 0)
						{
							m_info.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "joints") == 0)
						{
							m_joints.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "segments") == 0)
						{
							m_segments.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "sites") == 0)
						{
							m_sites.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "version") == 0)
						{
							m_version.setValue(data);
						}
						else if (strcmp(fieldName.c_str(), "viewpoints") == 0)
						{
							m_viewpoints.setValue(data);
						}

						else if (strcmp(fieldName.c_str(), "humanoidBody") == 0)
						{
							m_humanoidBody.setValue(data);
						}
						delete data;
					}
				}
			}
		}
		delete tmpNode;
	}
}
コード例 #14
0
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);
			}
		}
	}
}