topical media & game development

talk show tell print

#mobile-ar-8-13.txt / txt



  // Put fetched transform related parameters for each POI into an associative
  // array. The returned values are assigned to poi[transform].
  //
  // Arguments:
  // poi ; The POI handler.
  // db ; The database connection handler.
  // Returns:
  // array ; An array of received transform related parameters for this POI.
  //
  
  function Gettransform( poi, db ) {
          // A new table called “TRANSFORM_Table” is created to store transform related
          // parameters, namely “rel”, “angle” and “scale
          // “poiID” which shows the POI id that this transform belongs to.
          // The SQL statement returns transform which has the same poiID as the
          // id of poi (poi[‘id’]).
          
          sql_transform = db->prepare( “ SELECT rel, angle, scale FROM TRANSFORM_Table WHERE poiID = :id LIMIT 0,1 “ );
  
          // Binds the named parameter markers “:id” to the specified parameter
          // values “poi[‘id’]”.
          sql_transform->bindParam( ‘:id’, poi[‘id’], PDO::PARAM_INT );
  
          // Use PDO::execute() to execute the prepared statement sql_transform.
          sql_transform->execute();
  
          // Fetch the poi transform.
          transform = sql_transform->fetchAll( PDO::FETCH_ASSOC );
  
          /* Process the transform result */
          // if transform array is empty, return NULL.
          if ( empty( transform ) ) {
                  poi[“transform”] = null;
          }//if
          else {
                  // Since each POI only has one transform. Logically, only one transform should
                  // be returned. Assign the first transform in the array to poi[“transform”]
                  poi[“transform”] = transform[0];
                  // Change the value of “rel” into boolean value,if the value is NULL
                  // return NULL.
                  poi[“transform”][“rel”] = ChangetoBool( poi[“transform”][“rel”] );
                  // Change the values of “angle” and “scale” to demical.
                  poi[“transform”][“angle”] = ChangetoFloat( poi[“transform”][“angle”] );
                  poi[“transform”][“scale”] = ChangetoFloat( poi[“transform”][“scale”] );
          }//else
          return poi[“transform”];
  }//Gettransform


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.