/[hegemonie]/hegemonie/Model/MdlModel.m
ViewVC logotype

Diff of /hegemonie/Model/MdlModel.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by c-leo, Mon Aug 18 14:43:30 2003 UTC revision 1.16 by ano, Tue Aug 19 15:28:10 2003 UTC
# Line 25  Line 25 
25  #include <Foundation/NSDictionary.h>  #include <Foundation/NSDictionary.h>
26  #include <Foundation/NSString.h>  #include <Foundation/NSString.h>
27  #include <Foundation/NSValue.h>  #include <Foundation/NSValue.h>
28    #include <Foundation/NSData.h>
29    
30  #include <GL/glut.h>  #include <GL/glut.h>
31  #include <math.h>  #include <math.h>
# Line 96  Line 97 
97    free(_texturesCoord);    free(_texturesCoord);
98    free(_normales);    free(_normales);
99    
100      RELEASE(_verticeIndicesData);
101      RELEASE(_verticesData);
102      RELEASE(_texturesCoordData);
103      RELEASE(_normalesData);
104    RELEASE(_data);    RELEASE(_data);
105    RELEASE(_animations);    RELEASE(_animations);
106    RELEASE(_textures);    RELEASE(_textures);
# Line 239  Line 244 
244  - (void) _calcModelVerticeIndices  - (void) _calcModelVerticeIndices
245  {  {
246    int noMesh;    int noMesh;
247      _verticeIndicesData = [[NSMutableData alloc]
248    if ( !(_verticeIndices = malloc (_nbElements * sizeof (int32_t))) )                            initWithLength:
249      {                              (_nbElements * sizeof (u_int32_t))];
250        perror ("Failled allocation verticeIndices");    
251        abort ();    _verticeIndices = (u_int32_t*)[_verticeIndicesData bytes];
252      }    
253      
254     //  if ( !(_verticeIndices = malloc (_nbElements * sizeof (int32_t))) )
255    //     {
256    //       perror ("Failled allocation verticeIndices");
257    //       abort ();
258    //     }
259    
260    int cpt = 0;    int cpt = 0;
261    int meshOffset = 0;    int meshOffset = 0;
# Line 270  Line 281 
281   */   */
282  - (void) _calcVertices  - (void) _calcVertices
283  {  {
284    if ( !(_vertices = malloc (_nbVertices * [_data nbFrames]    _verticesData = [[NSMutableData alloc]
285                               * sizeof (coord_t))) )                      initWithLength:
286      {                        (_nbVertices * [_data nbFrames]
287        perror ("Failed allocation vertices array");                         * sizeof (coord_t))];
288        abort ();    _vertices = (coord_t*)[_verticesData bytes];
289      }  //   if ( !(_vertices = malloc (_nbVertices * [_data nbFrames]
290    //                           * sizeof (coord_t))) )
291    //     {
292    //       perror ("Failed allocation vertices array");
293    //       abort ();
294    //     }
295        
296    int noFrame;    int noFrame;
297    for (noFrame = 0; noFrame < [_data nbFrames]; noFrame++)    for (noFrame = 0; noFrame < [_data nbFrames]; noFrame++)
# Line 308  Line 324 
324  - (void) _calcTextures  - (void) _calcTextures
325  {  {
326    
327    if ( !(_texturesCoord = malloc (_nbVertices * sizeof (tex_coord_t))) )    _texturesCoordData = [[NSMutableData alloc]
328      {                           initWithLength:
329        perror ("Failed allocation textures array");                             (_nbVertices * sizeof (tex_coord_t))];
330        abort ();    
331      }    _texturesCoord =  (tex_coord_t *)[_texturesCoordData bytes];
332      
333     //  if ( !(_texturesCoord = malloc (_nbVertices * sizeof (tex_coord_t))) )
334    //     {
335    //       perror ("Failed allocation textures array");
336    //       abort ();
337    //     }
338            
339    int meshOffset = 0;    int meshOffset = 0;
340    int noMesh;    int noMesh;
# Line 338  Line 360 
360   */   */
361  - (void) _calcNormales  - (void) _calcNormales
362  {  {
363      _normalesData = [[NSMutableData alloc]
364    if ( !(_normales = malloc (_nbVertices * [_data nbFrames]                      initWithLength:
365                               * sizeof (coord_t))) )                        (_nbVertices * [_data nbFrames]
366      {                         * sizeof (coord_t))];
367        perror ("Failed allocation _normales array");    _normales = (coord_t*)[_normalesData bytes];
368        abort ();      
369      }   //  if ( !(_normales = malloc (_nbVertices * [_data nbFrames]
370    //                           * sizeof (coord_t))) )
371    //     {
372    //       perror ("Failed allocation _normales array");
373    //       abort ();
374    //     }
375    
376    int noFrame;    int noFrame;
377    for (noFrame = 0; noFrame < [_data nbFrames]; noFrame++)    for (noFrame = 0; noFrame < [_data nbFrames]; noFrame++)
# Line 424  Line 451 
451      + [animation startFrame];      + [animation startFrame];
452    
453    /* we test the visibility of the object */    /* we test the visibility of the object */
454    if (frustum)  
     {  
455                
456        coord_t currentMinBBox = [_data boneFrameMins: frame];        coord_t currentMinBBox = [_data boneFrameMins: frame];
457        coord_t nextMinBBox = [_data boneFrameMins: nextFrame];        coord_t nextMinBBox = [_data boneFrameMins: nextFrame];
458        coord_t currentMaxBBox = [_data boneFrameMaxs: frame];        coord_t currentMaxBBox = [_data boneFrameMaxs: frame];
459        coord_t nextMaxBBox = [_data boneFrameMaxs: nextFrame];        coord_t nextMaxBBox = [_data boneFrameMaxs: nextFrame];
460    
461      if (frustum)
462        {
463        if (![self isVisibleInFrustum: frustum        if (![self isVisibleInFrustum: frustum
464                   withBoundingBox: InterpolateCoord (currentMinBBox,                   withBoundingBox: InterpolateCoord (currentMinBBox,
465                                                      nextMinBBox, time)                                                      nextMinBBox, time)
# Line 478  Line 507 
507  //       NSParameterAssert (coord.z >= minBBox.z);  //       NSParameterAssert (coord.z >= minBBox.z);
508  //       NSParameterAssert (coord.z <= maxBBox.z);  //       NSParameterAssert (coord.z <= maxBBox.z);
509    
510  //  coord_t minBBox = InterpolateCoord (currentMinBBox, nextMinBBox, time);      //   coord_t minBBox = InterpolateCoord (currentMinBBox, nextMinBBox, time);
511  //      coord_t maxBBox = InterpolateCoord (currentMaxBBox, nextMaxBBox, time);  //       coord_t maxBBox = InterpolateCoord (currentMaxBBox, nextMaxBBox, time);
512  //       NSParameterAssert (coord.x >= minBBox.x);  //       NSParameterAssert (coord.x >= minBBox.x);
513  //       NSParameterAssert (coord.x <= maxBBox.x);  //       NSParameterAssert (coord.x <= maxBBox.x);
514  //       NSParameterAssert (coord.y >= minBBox.y);  //       NSParameterAssert (coord.y >= minBBox.y);

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26