// 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; } }
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; } }
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; } }
// 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; } }
// 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; } }
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; } }
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; } }
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; } }