コード例 #1
0
ファイル: TF3D_Body.java プロジェクト: jeffedlund/JF3d
  // -----------------------------------------------------------------------
  public void AssignMesh(int id) {
    if (id >= 0) {
      this.mesh_id = id;
      this.BBOX.CalcFromMesh(this.mesh_id);
      F3D.Log.info("TF3D_Body", "Assigned mesh = '" + F3D.Meshes.Get(this.mesh_id).name + "'");
      this.ReadAssignedSurfaces();

    } else {
      F3D.Log.error(
          "TF3D_Body",
          "AssignMesh() : index of assigned MeshName is -1 (Mesh name doesn't exist.)");
    }
  }
コード例 #2
0
ファイル: TF3D_Body.java プロジェクト: jeffedlund/JF3d
  // -----------------------------------------------------------------------
  public void AssignMesh(String meshname) {
    int id = F3D.Meshes.FindByName(meshname);

    if (id >= 0) {
      this.mesh_id = id;
      this.BBOX.CalcFromMesh(this.mesh_id);
      F3D.Log.info("TF3D_Body", "Assigned mesh = '" + name + "'");

      this.ReadAssignedSurfaces();
    } else {
      F3D.Log.error(
          "TF3D_Body",
          "AssignMesh() : index of assigned MeshName is -1 (Mesh '"
              + meshname
              + "' doesn't exist.)");
    }
  }
コード例 #3
0
ファイル: TF3D_Body.java プロジェクト: jeffedlund/JF3d
  private void ReadAssignedSurfaces() {
    this.surfaces = new ArrayList<TF3D_SurfaceSubstItem>();

    TF3D_Mesh mesh = F3D.Meshes.items.get(this.mesh_id);

    for (int i = 0; i < mesh.IndicesGroup.items.size(); i++) {
      String name = mesh.IndicesGroup.items.get(i).material_name;
      int id = mesh.IndicesGroup.items.get(i).material_id;

      TF3D_SurfaceSubstItem sitem = new TF3D_SurfaceSubstItem(name, id);
      this.surfaces.add(sitem);

      F3D.Log.info("TF3D_Body", "Assigned surface = '" + name + "'");
    }
  }
コード例 #4
0
ファイル: TF3D_Body.java プロジェクト: jeffedlund/JF3d
  // -----------------------------------------------------------------------
  public void CreateRigidBody(int shapemode, float mass) {

    this.start_position = (Vector3f) this.GetPosition().clone();
    this.start_rotation = (Vector3f) this.GetRotation().clone();

    if (!F3D.Config.use_physics) {
      F3D.Log.error(
          "TF3D_Body",
          "You can't create rigidbody when Bullet physics is disabled in Config.use_physics !\n Note: Use TF3D_Model instead TF3D_Body, when you don't use Bullet physics on Model.");
    }

    this.PhysicObject = new TF3D_PhysicObject();

    Vector3f rescaled = new Vector3f();
    rescaled.x = this.BBOX.size.x * this.GetScale().x;
    rescaled.y = this.BBOX.size.y * this.GetScale().y;
    rescaled.z = this.BBOX.size.z * this.GetScale().z;

    this.BBOX.size.set(rescaled);

    if ((shapemode == F3D.BULLET_SHAPE_CONVEXHULL) | (shapemode == F3D.BULLET_SHAPE_TRIMESH)) {
      if (this.collision_mesh_id > 0) {
        this.PhysicObject.Create(
            shapemode,
            mass,
            this.GetPosition(),
            this.GetRotation(),
            rescaled,
            F3D.Meshes.items.get(this.collision_mesh_id));
      } else {
        this.PhysicObject.Create(
            shapemode,
            mass,
            this.GetPosition(),
            this.GetRotation(),
            rescaled,
            F3D.Meshes.items.get(this.mesh_id));
      }
    } else {
      this.PhysicObject.Create(shapemode, mass, this.GetPosition(), this.GetRotation(), rescaled);
    }

    this.PhysicObject.RigidBody.setUserPointer((Object) this);
  }