Esempio n. 1
0
Bool LoadObject(int object_id,char *class_name)
{
   class_node *c;

   c = GetClassByName(class_name);
   if (c == NULL) 
   {
      eprintf("LoadObject can't find class name %s\n",class_name);
      return False;
   }

   if (AllocateObject(c->class_id) != object_id)
   {
      eprintf("LoadObject didn't make object id %i\n",object_id);
      return False;
   }

   /* set self = prop 0 */
   objects[object_id].p[0].id = 0;
   objects[object_id].p[0].val.v.tag = TAG_OBJECT; 
   objects[object_id].p[0].val.v.data = object_id;

   /* if no kod changed, then setting the properties shouldn't be
    * necessary.  however, who knows.
    */
   SetObjectProperties(object_id,c);

   return True;
}
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Name: OnMovementTimer()
// Desc: Periodically updates the position of the object 
//-----------------------------------------------------------------------------
VOID OnMovementTimer( HWND hDlg ) 
{
    FLOAT fXScale;
    FLOAT fYScale;

    if( !g_bAllowMovementTimer )
        return;

    HWND hHorzSlider = GetDlgItem( hDlg, IDC_HORIZONTAL_SLIDER );
    HWND hVertSlider = GetDlgItem( hDlg, IDC_VERTICAL_SLIDER );

    fXScale = SendMessage( hHorzSlider, TBM_GETPOS, 0, 0 ) / 100.0f;
    fYScale = SendMessage( hVertSlider, TBM_GETPOS, 0, 0 ) / 100.0f;
    FLOAT t = timeGetTime()/1000.0f;

    // Move the sound object around the listener. The maximum radius of the
    // orbit is 27.5 units.
    D3DVECTOR vPosition;
    vPosition.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t);
    vPosition.y = 0.0f;
    vPosition.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t);

    D3DVECTOR vVelocity;
    vVelocity.x = ORBIT_MAX_RADIUS * fXScale * (FLOAT)sin(t+0.05f);
    vVelocity.y = 0.0f;
    vVelocity.z = ORBIT_MAX_RADIUS * fYScale * (FLOAT)cos(t+0.05f);

    // Show the object's position on the dialog's grid control
    UpdateGrid( hDlg, vPosition.x, vPosition.z );

    // Set the sound buffer velocity and position
    SetObjectProperties( &vPosition, &vVelocity );
}
Esempio n. 3
0
int CreateObject(int class_id,int num_parms,parm_node parms[])
{
   int new_object_id;
   class_node *c;

   new_object_id = AllocateObject(class_id);

   if (new_object_id == INVALID_OBJECT)
      return INVALID_OBJECT;
   
   /* set self = prop 0 */
   objects[new_object_id].p[0].id = 0; 
   objects[new_object_id].p[0].val.v.tag = TAG_OBJECT; 
   objects[new_object_id].p[0].val.v.data = new_object_id;

   c = GetClassByID(class_id);
   if (c == NULL) /* can't ever be, because AllocateObject checks */
   {
      eprintf("CreateObject can't find class id %i\n",class_id);
      return INVALID_OBJECT;
   }

   SetObjectProperties(new_object_id,c);

   /* might not be top level message, since can be called from blakod.  If it
      really IS a top level message, then it better not post anything, since
      post messages won't be handled */
   if (IsInterpreting())
      SendBlakodMessage(new_object_id,CONSTRUCTOR_MSG,num_parms,parms);
   else
      SendTopLevelBlakodMessage(new_object_id,CONSTRUCTOR_MSG,num_parms,parms);

   if (ConfigBool(DEBUG_UNINITIALIZED))
   {
      int i;
      for (i = 0; i < (1+c->num_properties); i++)
	 if (objects[new_object_id].p[i].val.v.tag == TAG_INVALID)
	    eprintf("Uninitialized properties after constructor, class %s\n",
	       c->class_name);
   }

   return new_object_id;
}
Esempio n. 4
0
void SetObjectProperties(int object_id,class_node *c)
{
   int i;

   if (c->super_ptr != NULL)
      SetObjectProperties(object_id,c->super_ptr);

   for (i=0;i<c->num_prop_defaults;i++)
   {
      if (c->prop_default[i].id >= objects[object_id].num_props)
      {
	 eprintf("SetObjectProperties can't set invalid property %i of "
		 "OBJECT %i CLASS %s (%i)\n",c->prop_default[i].id,object_id,c->class_name,c->class_id);
      }
      else
      {
	 objects[object_id].p[c->prop_default[i].id].id = c->prop_default[i].id;
	 objects[object_id].p[c->prop_default[i].id].val.int_val =
	    c->prop_default[i].val.int_val;
      }
   }
}