void processBone(BvhBone bone, Joint joint) { joint.Position = new Vector3(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ()); joint.Name = bone.getName(); joint.Kind = JointNameTable.GetJointType(joint.Name); if (joint.Name.StartsWith("Left") || joint.Name.StartsWith("l")) { joint.Side = JointSide.Left; } else if (joint.Name.StartsWith("Right") || joint.Name.StartsWith("r")) { joint.Side = JointSide.Right; } if (bone.hasChildren()) { foreach (BvhBone childBone in bone.getChildren()) { Joint childJoint = new Joint(); processBone(bone, childJoint); if (childJoint.Kind != JointType.Invalid) { joint.Children.Add(childJoint); } } } }
protected void update(BvhBone bone) { //Matrix4 m = new Matrix4(); // //m.Translate(bone.getXposition(), bone.getYposition(), bone.getZposition()); //m.Translate(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ()); // //m.RotateY(bone.getYrotation() * MathUtils.degreesToRadians); //m.RotateX(bone.getXrotation() * MathUtils.degreesToRadians); //m.RotateZ(bone.getZrotation() * MathUtils.degreesToRadians); // //bone.global_matrix = m; // //if (bone.getParent() != null && bone.getParent().global_matrix != null) // m.preApply(bone.getParent().global_matrix); //m.mult(new Vector3(), bone.getAbsPosition()); // //if (bone.getChildren().Count > 0) //{ // foreach (BvhBone child in bone.getChildren()) // { // update(child); // } //} //else //{ // m.translate(bone.getEndOffsetX(), bone.getEndOffsetY(), bone.getEndOffsetZ()); // m.mult(new Vector3(), bone.getAbsEndPosition()); //} }
void processBone(BvhBone bone, Joint joint) { joint.Position = new Vector3(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ()); joint.Name = bone.getName(); joint.Kind = JointNameTable.GetJointType(joint.Name); if (joint.Name.StartsWith("Left") || joint.Name.StartsWith("l")) { joint.Side = JointSide.Left; } else if (joint.Name.StartsWith("Right") || joint.Name.StartsWith("r")) { joint.Side = JointSide.Right; } if (bone.hasChildren()) { foreach (BvhBone childBone in bone.getChildren()) { Joint childJoint = new Joint(); processBone(bone, childJoint); if (childJoint.Kind != JointType.Invalid) joint.Children.Add(childJoint); } } }
private BvhBone _parseBone() { //_currentBone is Parent BvhBone bone = new BvhBone(_currentBone); _bones.Add(bone); bone.setName(_lines[_currentLine]._boneName); //1 // +2 OFFSET _currentLine++; // 2 { _currentLine++; // 3 OFFSET bone.setOffsetX(_lines[_currentLine].getOffsetX()); bone.setOffsetY(_lines[_currentLine].getOffsetY()); bone.setOffsetZ(_lines[_currentLine].getOffsetZ()); // +3 CHANNELS _currentLine++; bone.setnbChannels(_lines[_currentLine].getNbChannels()); bone.setChannels(_lines[_currentLine].getChannelsProps()); // +4 JOINT or End Site or } _currentLine++; while (_currentLine < _lines.Count) { String lineType = _lines[_currentLine].getLineType(); if (BvhLine.BONE.Equals(lineType)) //JOINT or ROOT { BvhBone child = _parseBone(); //generate new BvhBONE child.setParent(bone); bone.getChildren().Add(child); } else if (BvhLine.END_SITE.Equals(lineType)) { _currentLine++; // { _currentLine++; // OFFSET bone.setEndOffsetX(_lines[_currentLine].getOffsetX()); bone.setEndOffsetY(_lines[_currentLine].getOffsetY()); bone.setEndOffsetZ(_lines[_currentLine].getOffsetZ()); _currentLine++; //} _currentLine++; //} return(bone); } else if (BvhLine.BRACE_CLOSED.Equals(lineType)) { return(bone); //} } _currentLine++; } Console.WriteLine("//Something strange"); return(bone); }
public void parse(String[] srces) { String[] linesStr = srces; // liste de BvhLines _lines = new List <BvhLine>(); foreach (String lineStr in linesStr) { _lines.Add(new BvhLine(lineStr)); } _currentLine = 1; _rootBone = _parseBone(); // center locs //_rootBone.offsetX = _rootBone.offsetY = _rootBone.offsetZ = 0; _parseFrames(); }
public Skeleton ReadSkeleton(string fileName) { string[] lines = System.IO.File.ReadAllLines(fileName); BVHParser parser = new BVHParser(); parser.parse(lines); Skeleton skeleton = new Skeleton(); skeleton.Name = System.IO.Path.GetFileNameWithoutExtension(fileName); BvhBone rootBone = parser.getRootBone(); Joint rootJoint = new Joint(); processBone(rootBone, rootJoint); skeleton.Root = rootJoint; return(skeleton); }
private BvhBone _parseBone() { //_currentBone is Parent BvhBone bone = new BvhBone( _currentBone ); _bones.Add(bone); bone.setName( _lines[_currentLine]._boneName ); //1 // +2 OFFSET _currentLine++; // 2 { _currentLine++; // 3 OFFSET bone.setOffsetX( _lines[_currentLine].getOffsetX() ); bone.setOffsetY( _lines[_currentLine].getOffsetY() ); bone.setOffsetZ( _lines[_currentLine].getOffsetZ() ); // +3 CHANNELS _currentLine++; bone.setnbChannels( _lines[_currentLine].getNbChannels() ); bone.setChannels( _lines[_currentLine].getChannelsProps() ); // +4 JOINT or End Site or } _currentLine++; while(_currentLine < _lines.Count) { String lineType = _lines[_currentLine].getLineType(); if ( BvhLine.BONE.Equals( lineType ) ) //JOINT or ROOT { BvhBone child = _parseBone(); //generate new BvhBONE child.setParent( bone ); bone.getChildren().Add(child); } else if( BvhLine.END_SITE.Equals( lineType ) ) { _currentLine++; // { _currentLine++; // OFFSET bone.setEndOffsetX( _lines[_currentLine].getOffsetX() ); bone.setEndOffsetY( _lines[_currentLine].getOffsetY() ); bone.setEndOffsetZ( _lines[_currentLine].getOffsetZ() ); _currentLine++; //} _currentLine++; //} return bone; } else if( BvhLine.BRACE_CLOSED.Equals( lineType ) ) { return bone; //} } _currentLine++; } Console.WriteLine("//Something strange"); return bone; }
protected void update(BvhBone bone ) { //Matrix4 m = new Matrix4(); // //m.Translate(bone.getXposition(), bone.getYposition(), bone.getZposition()); //m.Translate(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ()); // //m.RotateY(bone.getYrotation() * MathUtils.degreesToRadians); //m.RotateX(bone.getXrotation() * MathUtils.degreesToRadians); //m.RotateZ(bone.getZrotation() * MathUtils.degreesToRadians); // //bone.global_matrix = m; // //if (bone.getParent() != null && bone.getParent().global_matrix != null) // m.preApply(bone.getParent().global_matrix); //m.mult(new Vector3(), bone.getAbsPosition()); // //if (bone.getChildren().Count > 0) //{ // foreach (BvhBone child in bone.getChildren()) // { // update(child); // } //} //else //{ // m.translate(bone.getEndOffsetX(), bone.getEndOffsetY(), bone.getEndOffsetZ()); // m.mult(new Vector3(), bone.getAbsEndPosition()); //} }
public void parse(String[] srces) { String[] linesStr = srces; // liste de BvhLines _lines = new List<BvhLine>(); foreach ( String lineStr in linesStr) _lines.Add(new BvhLine(lineStr)); _currentLine = 1; _rootBone = _parseBone(); // center locs //_rootBone.offsetX = _rootBone.offsetY = _rootBone.offsetZ = 0; _parseFrames(); }
public BvhBone() { _parent = null; _channels = new List<String>(); _children = new List<BvhBone>(); }
public BvhBone(BvhBone __parent) { _parent = __parent; _channels = new List<String>(); _children = new List<BvhBone>(); }
public void setParent(BvhBone value) { _parent = value; }
public BvhBone() { _parent = null; _channels = new List <String>(); _children = new List <BvhBone>(); }
public BvhBone(BvhBone __parent) { _parent = __parent; _channels = new List <String>(); _children = new List <BvhBone>(); }