Exemple #1
0
// ParticleCloud_ChangeID():
void ParticleCloud_ChangeID( LWInstance _inst, const LWItemID *ids ) {
  ParticleCloud_Instance *inst = (ParticleCloud_Instance *)_inst;

  int i, j;
  for( j=0; j != (int)LWITEM_NULL; j++ ) {
    for( i=0; i != (int)LWITEM_NULL; i+=2 ) {
      if( ids[i] == inst->GetItems()[i] ) {
        inst->GetItems()[i] = ids[i];
        break;
      }
    }
  }
}
Exemple #2
0
// ParticleCloud_UseItems():
const LWItemID * ParticleCloud_UseItems( LWInstance _inst ) {
  ParticleCloud_Instance *inst = (ParticleCloud_Instance *)_inst;
  return inst->GetItems();
}
Exemple #3
0
// ParticleCloud_Evaluate():
void ParticleCloud_Evaluate( LWInstance _inst, const LWCustomObjAccess *access ) {
  ParticleCloud_Instance *inst = (ParticleCloud_Instance *)_inst;

  LWObjectInfo *object_info = (LWObjectInfo *)inst->global( LWOBJECTINFO_GLOBAL, GFUSE_TRANSIENT );
  LWItemInfo   *item_info   = (LWItemInfo   *)inst->global( LWITEMINFO_GLOBAL,   GFUSE_TRANSIENT );

  LWMeshInfoID mesh = object_info->meshInfo( inst->GetItems()[0], (inst->GetUseFrozen() ? 1 : 0) );
  ParticleCloud_Point::mesh = mesh;

  // Get the point positions
  DynArray< ParticleCloud_Point * > points;
  mesh->scanPoints( mesh, PointScan_GetPositions, &points );

  // Get the item's transformation matrix
  LWDVector item_position, item_right, item_up, item_forward;
  LWFMatrix4 M;

  item_info->param( inst->GetItems()[0], LWIP_POSITION, inst->GetTime(), item_position );
  item_info->param( inst->GetItems()[0], LWIP_RIGHT,    inst->GetTime(), item_right );
  item_info->param( inst->GetItems()[0], LWIP_UP,       inst->GetTime(), item_up );
  item_info->param( inst->GetItems()[0], LWIP_FORWARD,  inst->GetTime(), item_forward );

  unsigned long i;
  for ( i = 0; i < 3; i++ ) {
    M[ 0 ][ i ] = ( float ) item_right[ i ];
    M[ 1 ][ i ] = ( float ) item_up[ i ];
    M[ 2 ][ i ] = ( float ) item_forward[ i ];
    M[ 3 ][ i ] = ( float ) item_position[ i ];
    M[ i ][ 3 ] = 0.0f;
  }
  M[ 3 ][ 3 ] = 1.0f;

  // Display each point
  LWFVector local, world;
  double position[3];
  char   buffer[10];

  float color[4] = { 0.75, 1.0, 0.75, 1.0 };
  access->setColor( access->dispData, color );

  for( i=0; i < points.NumElements(); i++ ) {
    // Convert from local to world space
    local[0] = points[i]->position[0];
    local[1] = points[i]->position[1];
    local[2] = points[i]->position[2];
    LWVecMath::transformp( local, M, world );

    // Convert to doubles
    position[0] = world[0];
    position[1] = world[1];
    position[2] = world[2];

    // Draw the point
    access->point( access->dispData, position, LWCSYS_WORLD );

    // Draw the point index
    if( inst->GetShowIndices() ) {
      sprintf( buffer, "%d", i );
      access->text( access->dispData, position, buffer, 0, LWCSYS_WORLD );
    }
  }
}