function initNodes(Id) {
  var m = mat4();

  switch (Id) {
    case torsoId:
      m = translate(moveinXaxis, 5 + moveinYaxis, 0);
      m = rotate(theta[torsoId], 0, 1, 0);
      figure[torsoId] = createNode(m, torso, baseId, headId);
      break;

    case headId:
    case head1Id:
    case head2Id:
      m = translate(0.0, torsoHeight + 0.5 * headHeight, 0.0);
      m = mult(m, rotate(theta[head1Id], 1, 0, 0));
      m = mult(m, rotate(theta[head2Id], 0, 1, 0));
      m = mult(m, translate(0.0, -0.5 * headHeight, 0.0));
      figure[headId] = createNode(m, head, leftUpperArmId, null);
      break;

    case leftUpperArmId:
      m = translate(-(torsoWidth + upperArmWidth), 0.9 * torsoHeight, 0.0);
      m = mult(m, rotate(theta[leftUpperArmId], 1, 0, 0));
      figure[leftUpperArmId] = createNode(
        m,
        leftUpperArm,
        rightUpperArmId,
        leftLowerArmId
      );
      break;

    case rightUpperArmId:
      m = translate(torsoWidth + upperArmWidth, 0.9 * torsoHeight, 0.0);
      m = mult(m, rotate(theta[rightUpperArmId], 1, 0, 0));
      figure[rightUpperArmId] = createNode(
        m,
        rightUpperArm,
        leftUpperLegId,
        rightLowerArmId
      );
      break;

    case leftUpperLegId:
      m = translate(-(torsoWidth + upperLegWidth), 0.1 * upperLegHeight, 0.0);
      m = mult(m, rotate(theta[leftUpperLegId], 1, 0, 0));
      figure[leftUpperLegId] = createNode(
        m,
        leftUpperLeg,
        rightUpperLegId,
        leftLowerLegId
      );
      break;

    case rightUpperLegId:
      m = translate(torsoWidth + upperLegWidth, 0.1 * upperLegHeight, 0.0);
      m = mult(m, rotate(theta[rightUpperLegId], 1, 0, 0));
      figure[rightUpperLegId] = createNode(
        m,
        rightUpperLeg,
        null,
        rightLowerLegId
      );
      break;

    case leftLowerArmId:
      m = translate(0.0, upperArmHeight, 0.0);
      m = mult(m, rotate(theta[leftLowerArmId], 1, 0, 0));
      figure[leftLowerArmId] = createNode(m, leftLowerArm, null, null);
      break;

    case rightLowerArmId:
      m = translate(0.0, upperArmHeight, 0.0);
      m = mult(m, rotate(theta[rightLowerArmId], 1, 0, 0));
      figure[rightLowerArmId] = createNode(m, rightLowerArm, null, null);
      break;

    case leftLowerLegId:
      m = translate(0.0, upperLegHeight, 0.0);
      m = mult(m, rotate(theta[leftLowerLegId], 1, 0, 0));
      figure[leftLowerLegId] = createNode(m, leftLowerLeg, null, null);
      break;

    case rightLowerLegId:
      m = translate(0.0, upperLegHeight, 0.0);
      m = mult(m, rotate(theta[rightLowerLegId], 1, 0, 0));
      figure[rightLowerLegId] = createNode(m, rightLowerLeg, null, null);
      break;

    case baseId:
      m = translate(1, -6.5, 2);
      m = mult(m, rotate(theta[baseId], 1, 0, 0));
      figure[baseId] = createNode(m, baseGround, null, null);
      break;
  }
}
//adding the elements of the object like nodes and connecting them like child parent
adding the elements of the object like nodes and connecting them like child parent
adding the elements of the object like nodes and connecting them like child parent
function initNodes(Id) {
  var m = mat4();
  switch (Id) {
    case torsoId:
      m = translate(moveinXaxis, 5 + moveinYaxis, 0);
      m = rotate(theta[torsoId], 0, 1, 0);
      figure[torsoId] = createNode(m, torso, baseId, headId);
      break;
    case headId:
    case head1Id:
    case head2Id:
      m = translate(0.0, torsoHeight + 0.5 * headHeight, 0.0);
      m = mult(m, rotate(theta[head1Id], 1, 0, 0));
      m = mult(m, rotate(theta[head2Id], 0, 1, 0));
      m = mult(m, translate(0.0, -0.5 * headHeight, 0.0));
      figure[headId] = createNode(m, head, leftUpperArmId, null);
      break;
    case leftUpperArmId:
      m = translate(-(torsoWidth + upperArmWidth), 0.9 * torsoHeight, 0.0);
      m = mult(m, rotate(theta[leftUpperArmId], 1, 0, 0));
      figure[leftUpperArmId] = createNode(
        m,
        leftUpperArm,
        rightUpperArmId,
        leftLowerArmId
      );
      break;
    case rightUpperArmId:
      m = translate(torsoWidth + upperArmWidth, 0.9 * torsoHeight, 0.0);
      m = mult(m, rotate(theta[rightUpperArmId], 1, 0, 0));
      figure[rightUpperArmId] = createNode(
        m,
        rightUpperArm,
        leftUpperLegId,
        rightLowerArmId
      );
      break;
    case leftUpperLegId:
      m = translate(-(torsoWidth + upperLegWidth), 0.1 * upperLegHeight, 0.0);
      m = mult(m, rotate(theta[leftUpperLegId], 1, 0, 0));
      figure[leftUpperLegId] = createNode(
        m,
        leftUpperLeg,
        rightUpperLegId,
        leftLowerLegId
      );
      break;
    case rightUpperLegId:
      m = translate(torsoWidth + upperLegWidth, 0.1 * upperLegHeight, 0.0);
      m = mult(m, rotate(theta[rightUpperLegId], 1, 0, 0));
      figure[rightUpperLegId] = createNode(
        m,
        rightUpperLeg,
        null,
        rightLowerLegId
      );
      break;
    case leftLowerArmId:
      m = translate(0.0, upperArmHeight, 0.0);
      m = mult(m, rotate(theta[leftLowerArmId], 1, 0, 0));
      figure[leftLowerArmId] = createNode(m, leftLowerArm, null, null);
      break;
    case rightLowerArmId:
      m = translate(0.0, upperArmHeight, 0.0);
      m = mult(m, rotate(theta[rightLowerArmId], 1, 0, 0));
      figure[rightLowerArmId] = createNode(m, rightLowerArm, null, null);
      break;
    case leftLowerLegId:
      m = translate(0.0, upperLegHeight, 0.0);
      m = mult(m, rotate(theta[leftLowerLegId], 1, 0, 0));
      figure[leftLowerLegId] = createNode(m, leftLowerLeg, null, null);
      break;
    case rightLowerLegId:
      m = translate(0.0, upperLegHeight, 0.0);
      m = mult(m, rotate(theta[rightLowerLegId], 1, 0, 0));
      figure[rightLowerLegId] = createNode(m, rightLowerLeg, null, null);
      break;
    case baseId:
      m = translate(1, -6.5, 2);
      m = mult(m, rotate(theta[baseId], 1, 0, 0));
      figure[baseId] = createNode(m, baseGround, null, null);
      break;
  }
}
function initNodes ( Id ) { var m = mat4 ( ) ; switch ( Id ) { case torsoId : m = translate ( moveinXaxis , 5 + moveinYaxis , 0 ) ; m = rotate ( theta [ torsoId ] , 0 , 1 , 0 ) ; figure [ torsoId ] = createNode ( m , torso , baseId , headId ) ; break ; case headId : case head1Id : case head2Id : m = translate ( 0.0 , torsoHeight + 0.5 * headHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ head1Id ] , 1 , 0 , 0 ) ) ; m = mult ( m , rotate ( theta [ head2Id ] , 0 , 1 , 0 ) ) ; m = mult ( m , translate ( 0.0 , - 0.5 * headHeight , 0.0 ) ) ; figure [ headId ] = createNode ( m , head , leftUpperArmId , null ) ; break ; case leftUpperArmId : m = translate ( - ( torsoWidth + upperArmWidth ) , 0.9 * torsoHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ leftUpperArmId ] , 1 , 0 , 0 ) ) ; figure [ leftUpperArmId ] = createNode ( m , leftUpperArm , rightUpperArmId , leftLowerArmId ) ; break ; case rightUpperArmId : m = translate ( torsoWidth + upperArmWidth , 0.9 * torsoHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ rightUpperArmId ] , 1 , 0 , 0 ) ) ; figure [ rightUpperArmId ] = createNode ( m , rightUpperArm , leftUpperLegId , rightLowerArmId ) ; break ; case leftUpperLegId : m = translate ( - ( torsoWidth + upperLegWidth ) , 0.1 * upperLegHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ leftUpperLegId ] , 1 , 0 , 0 ) ) ; figure [ leftUpperLegId ] = createNode ( m , leftUpperLeg , rightUpperLegId , leftLowerLegId ) ; break ; case rightUpperLegId : m = translate ( torsoWidth + upperLegWidth , 0.1 * upperLegHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ rightUpperLegId ] , 1 , 0 , 0 ) ) ; figure [ rightUpperLegId ] = createNode ( m , rightUpperLeg , null , rightLowerLegId ) ; break ; case leftLowerArmId : m = translate ( 0.0 , upperArmHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ leftLowerArmId ] , 1 , 0 , 0 ) ) ; figure [ leftLowerArmId ] = createNode ( m , leftLowerArm , null , null ) ; break ; case rightLowerArmId : m = translate ( 0.0 , upperArmHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ rightLowerArmId ] , 1 , 0 , 0 ) ) ; figure [ rightLowerArmId ] = createNode ( m , rightLowerArm , null , null ) ; break ; case leftLowerLegId : m = translate ( 0.0 , upperLegHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ leftLowerLegId ] , 1 , 0 , 0 ) ) ; figure [ leftLowerLegId ] = createNode ( m , leftLowerLeg , null , null ) ; break ; case rightLowerLegId : m = translate ( 0.0 , upperLegHeight , 0.0 ) ; m = mult ( m , rotate ( theta [ rightLowerLegId ] , 1 , 0 , 0 ) ) ; figure [ rightLowerLegId ] = createNode ( m , rightLowerLeg , null , null ) ; break ; case baseId : m = translate ( 1 , - 6.5 , 2 ) ; m = mult ( m , rotate ( theta [ baseId ] , 1 , 0 , 0 ) ) ; figure [ baseId ] = createNode ( m , baseGround , null , null ) ; break ; } }
adding the elements of the object like nodes and connecting them like child parent
adding the elements of the object like nodes and connecting them like child parent