コード例 #1
0
ファイル: file.cpp プロジェクト: nitrologic/mod
/*!
 * \ingroup file
 */
void
lib3ds_file_bounding_box(Lib3dsFile *file, Lib3dsVector min, Lib3dsVector max)
{
    Lib3dsBool init=LIB3DS_FALSE;

    {
        Lib3dsVector lmin, lmax;
        Lib3dsMesh *p=file->meshes;

        if (!init && p) {
            init = LIB3DS_TRUE;
            lib3ds_mesh_bounding_box(p, min, max);
            p = p->next;
        }
        while (p) {
            lib3ds_mesh_bounding_box(p, lmin, lmax);
            lib3ds_vector_min(min, lmin);
            lib3ds_vector_max(max, lmax);
            p=p->next;
        }
    }
    {
        Lib3dsCamera *p=file->cameras;
        if (!init && p) {
            init = LIB3DS_TRUE;
            lib3ds_vector_copy(min, p->position);
            lib3ds_vector_copy(max, p->position);
        }

        while (p) {
            lib3ds_vector_min(min, p->position);
            lib3ds_vector_max(max, p->position);
            lib3ds_vector_min(min, p->target);
            lib3ds_vector_max(max, p->target);
            p=p->next;
        }
    }
    {
        Lib3dsLight *p=file->lights;
        if (!init && p) {
            init = LIB3DS_TRUE;
            lib3ds_vector_copy(min, p->position);
            lib3ds_vector_copy(max, p->position);
        }

        while (p) {
            lib3ds_vector_min(min, p->position);
            lib3ds_vector_max(max, p->position);
            if (p->spot_light) {
                lib3ds_vector_min(min, p->spot);
                lib3ds_vector_max(max, p->spot);
            }
            p=p->next;
        }
    }
}
コード例 #2
0
ファイル: file.c プロジェクト: BackupTheBerlios/engfx3d-svn
/*!
 * Compute the bounding box for Lib3dsFile objects.
 *
 * This function computes the bounding box for all meshes
 * in the Lib3dsFile object.  Cameras and lights are not included.
 *
 * \param file The Lib3dsFile object to be examined.
 * \param min Returned minimum x,y,z values.
 * \param max Returned maximum x,y,z values.
 *
 * \ingroup file
 */
void
lib3ds_object_bounding_box(Lib3dsFile *file, Lib3dsVector min, Lib3dsVector max)
{
  {
    Lib3dsVector lmin, lmax;
    Lib3dsMesh *p=file->meshes;

    if (p) {
      lib3ds_mesh_bounding_box(p, min, max);
      p = p->next;  
    }
    while (p) {
      lib3ds_mesh_bounding_box(p, lmin, lmax);
      lib3ds_vector_min(min, lmin);
      lib3ds_vector_max(max, lmax);
      p=p->next;
    }
  }
}  
コード例 #3
0
ファイル: file.c プロジェクト: NickDaniil/structured
/*!
 * This function computes the bounding box of meshes, cameras and lights 
 * defined in the 3D editor.
 *
 * \param file              The Lib3dsFile object to be examined.
 * \param include_meshes    Include meshes in bounding box calculation.
 * \param include_cameras   Include cameras in bounding box calculation.
 * \param include_lights    Include lights in bounding box calculation.
 * \param bmin              Returned minimum x,y,z values.
 * \param bmax              Returned maximum x,y,z values.
 *
 * \ingroup file
 */
void
lib3ds_file_bounding_box_of_objects(Lib3dsFile *file, Lib3dsBool include_meshes, 
                                    Lib3dsBool include_cameras, Lib3dsBool include_lights, 
                                    Lib3dsVector bmin, Lib3dsVector bmax)
{
  bmin[0] = bmin[1] = bmin[2] = FLT_MAX; 
  bmax[0] = bmax[1] = bmax[2] = FLT_MIN; 

  if (include_meshes) {
    Lib3dsVector lmin, lmax;
    Lib3dsMesh *p=file->meshes;
    while (p) {
      lib3ds_mesh_bounding_box(p, lmin, lmax);
      lib3ds_vector_min(bmin, lmin);
      lib3ds_vector_max(bmax, lmax);
      p=p->next;
    }
  }
  if (include_cameras) {
    Lib3dsCamera *p=file->cameras;
    while (p) {
      lib3ds_vector_min(bmin, p->position);
      lib3ds_vector_max(bmax, p->position);
      lib3ds_vector_min(bmin, p->target);
      lib3ds_vector_max(bmax, p->target);
      p=p->next;
    }
  }
  if (include_lights) {
    Lib3dsLight *p=file->lights;
    while (p) {
      lib3ds_vector_min(bmin, p->position);
      lib3ds_vector_max(bmax, p->position);
      if (p->spot_light) {
        lib3ds_vector_min(bmin, p->spot);
        lib3ds_vector_max(bmax, p->spot);
      }
      p=p->next;
    }
  }
}  
コード例 #4
0
ファイル: lib3ds_file.c プロジェクト: 0871087123/lib3ds
void
lib3ds_file_bounding_box_of_objects(Lib3dsFile *file, int 
                                    include_meshes, int include_cameras, int include_lights,
                                    float bmin[3], float bmax[3]) {
    bmin[0] = bmin[1] = bmin[2] = FLT_MAX;
    bmax[0] = bmax[1] = bmax[2] = -FLT_MAX;

    if (include_meshes) {
        float lmin[3], lmax[3];
        int i;
        for (i = 0; i < file->nmeshes; ++i) {
            lib3ds_mesh_bounding_box(file->meshes[i], lmin, lmax);
            lib3ds_vector_min(bmin, lmin);
            lib3ds_vector_max(bmax, lmax);
        }
    }
    if (include_cameras) {
        int i;
        for (i = 0; i < file->ncameras; ++i) {
            lib3ds_vector_min(bmin, file->cameras[i]->position);
            lib3ds_vector_max(bmax, file->cameras[i]->position);
            lib3ds_vector_min(bmin, file->cameras[i]->target);
            lib3ds_vector_max(bmax, file->cameras[i]->target);
        }
    }
    if (include_lights) {
        int i;
        for (i = 0; i < file->ncameras; ++i) {
            lib3ds_vector_min(bmin, file->lights[i]->position);
            lib3ds_vector_max(bmax, file->lights[i]->position);
            if (file->lights[i]->spot_light) {
                lib3ds_vector_min(bmin, file->lights[i]->target);
                lib3ds_vector_max(bmax, file->lights[i]->target);
            }
        }
    }
}