⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 engine.i

📁 使用stl技术,(还没看,是听说的)
💻 I
📖 第 1 页 / 共 2 页
字号:
//This is a swig package for ruby.
//http://www.swig.org
//Author: Gaw (garcia@cs.ttu.edu)

%module Oasis
%{
#include "oasisCommon.h"
#include "oasisVector3.h"
#include "oasisQuaternion.h"
#include "oasisColour.h"
#include "oasisFrameListener.h"
#include "oasisResource.h"
#include "oasisResourceManager.h"
#include "oasisSystem.h"
#include "oasisMovable.h"
#include "oasisSingleton.h"
#include "oasisPool.h"
#include "oasisPoolable.h"
#include "oasisAudible.h"
#include "oasisPhysical.h"
#include "oasisVisible.h"
#include "oasisCameraSystem.h"
#include "oasisFrameListenerSystem.h"
#include "oasisGraphicsSystem.h"
#include "oasisObjectResource.h"
#include "oasisObjectSystem.h"
#include "oasisPhysics.h"
#include "oasisJoint.h"
#include "oasisJoints.h"
#include "oasisProxy.h"
#include "oasisProxies.h"
#include "oasisPhysicsResource.h"
#include "oasisMass.h"
#include "oasisPhysicsSystem.h"
#include "oasisSound.h"
#include "oasisSoundResource.h"
#include "oasisSoundSystem.h"
#include "oasisObject.h"
#include "oasisEntity.h"
%}
%typemap (in) string {
  Check_Type($input, T_STRING);
  $1 = string(STR2CSTR($input));
}

%typemap (out) string {
  if ($1.c_str() == NULL)
    $result = Qnil;
  else
    $result = rb_str_new2($1.c_str());
}



namespace Oasis {
  typedef double real;
  typedef unsigned char uint8;
  typedef char int8;
  typedef unsigned short uint16;
  typedef short int16;
  typedef unsigned long uint32;
  typedef long int32;
  
  typedef time_t timestamp;
  typedef uint32 size;
  
  /// Forward declare our classes
  class audible;
  class ballJoint;
  class boxMass;
  class boxProxy;
  class cameraSystem;
  class ccylinderMass;
  class ccylinderProxy;
  class collisionListener;
  class colour;  
  class consoleSystem;
  class convert;
  class cylinderMass;
  class entity;
  class exception;
  class frameListener;
  class frameListenerSystem;
  class frameListenerSystemBase; 
  class graphicsSystem;
  class hingeJoint;
  class hinge2Joint;
  class inputSystem;
  class inputSystemBase;
  class joint;
  class keyListener;
  class mass;
  class mixer;
  class mouseListener;
  class movable;
  class object;
  class objectResource;
  class objectSystem;
  class physical;
  class physics;
  class physicsResource;
  class physicsSystem;
  class pool;
  class proxy;
  class quaternion;
  class root;
  class scriptResource;
  class scriptSystem; 
  class sliderJoint;
  class sound;
  class soundResource;
  class soundSystem;
  class sphereMass;
  class sphereProxy;
  class universalJoint;
  class vector3;
  class visible;

  %nodefault pool;
  %nodefault audible;
  %nodefault movable;
  %nodefault physical;
  %nodefault objectResource;
  %nodefault proxy;
  %nodefault boxProxy;
  %nodefault sphereProxy;
  %nodefault ccylinderProxy;
  %nodefault physicsResource;
  %nodefault soundResource;

  //oasisVector3
  class vector3 {
  public:
    real x;
    real y;
    real z;
    vector3( real fx, real fy, real fz );
    vector3( );
    vector3 operator + ( const vector3& rkVector );
    vector3 operator - ( const vector3& rkVector );
    vector3 operator * ( const vector3& rkVector );
    vector3 operator * ( real fScalar );
    vector3 operator / ( real fScalar );
    vector3 operator += ( const vector3& rkVector );
    vector3 operator -= ( const vector3& rkVector );
    vector3 operator *= ( real );
    vector3 operator /= ( real );
    vector3 operator - ( );
    vector3 crossProduct( const vector3 &rkVector );
    const real squaredLength( void );
    static const vector3 ZERO;
    static const vector3 UNITX;
    static const vector3 UNITY;
    static const vector3 UNITZ;
    static const vector3 UNITSCALE;
  };

  //oasisQuaternion
  class quaternion {
  public:
    real w;
    real x;
    real y;
    real z;
    quaternion( );
    quaternion( real fw, real fx, real fy, real fz);
    vector3 operator * ( const vector3 &rk );
    quaternion operator * ( const quaternion &rk );
    quaternion operator + ( const quaternion &rk );
    quaternion operator - ( const quaternion &rk );
    quaternion operator * ( real scalar );
    quaternion operator - ( );
    static const quaternion ZERO;
    static const quaternion IDENTITY;

  };

  //oasisFrameListener.h
  class frameListener {
  public:
  };

  //oasisColour.h
  class colour {
  public:
    real red;
    real green;
    real blue;
    real alpha;
    colour( );
    colour( real r, real g, real b, real a );
  };
  
  //oasisMovable.h
  class movable {
  public:
    void setPosition( real x, real y, real z );
    virtual void setPosition( const vector3 &position );
    const vector3 &getPosition( void ) const;

    void move( real x, real y, real z );
    void move( const vector3 &moveVector );
    void moveRelative( real x, real y, real z );
    void moveRelative( const vector3 &moveVector );

    void rotate( real x, real y, real z, real degrees );
    void rotate( const vector3 &axis, real degrees );
    void rotate( const quaternion &rotation );

    virtual void setOrientation( const quaternion &newOrientation );
    const quaternion &getOrientation( void ) const;
    vector3 getDirection( void ) const;    
  };

  //oasisSingleton.h
  template < typename T > class singleton {
  public:
    //TEMPLATE_BIND( T, cameraSystem, frameListenerSystem, graphicsSystem, objectSystem, physicsSystem, soundSystem ) 
    static T &get( );
  };

  //the following does the same as the commented out tolua++ code above.
  /*%define TEMPLATE_WRAP( _TEMPL ) 
    %template( _TEMPL ## singleton ) singleton< _TEMPL >;
  %enddef
  TEMPLATE_WRAP( cameraSystem )
  TEMPLATE_WRAP( frameListenerSystem )
  TEMPLATE_WRAP( objectSystem )
  TEMPLATE_WRAP( physicsSystem )
  TEMPLATE_WRAP( graphicsSystem )
  TEMPLATE_WRAP( soundSystem ) //PENDING: we can do better than this,
                                it creates seperate singleton classes.*/
  
 //todo uint32 uint16... 
  //oasisPool.h
  class pool {
  public:
    void clearPool( void );
    const string getPoolName( void ) const;
    bool setPoolSize( uint16 newSize );
    const uint16 getPoolSize( void ) const;
    const string getNextUniqueName( void );
  };
  
  //oasisAudible.h
  class audible {
  public:
    sound *addSound( const string name, const string templateName );
    void addSound( const string name, sound *soundObject );

    sound *getSound( const string name );
    sound *playSound( const string name );
    sound *stopSound( const string name );
    void stopAllSounds( void );

    void removeAllSounds( void );
    void removeAndDestroyAllSounds( void );

    void removeSound( const string name );
    void removeAndDestroySound( const string name );    
  };
  
  //oasisPhysical.h
  class physical : public movable {
  public:
    void enablePhysics( bool usePhysics );

    void setPhysics( physics *physicsToUse );
    physics *setPhysics( const string templateName );
    physics *getPhysics( void ) const;

    void removePhysics( void );
    void removeAndDestroyPhysics( void );
  };

  //oasisVisible.h
  class visible {
  public:
    void scale( real x, real y, real z );
    void scale( const vector3 &newscale );

    void setScale( real x, real y, real z );
    void setScale( const vector3 &newScale );
    const vector3 &getScale( void ) const;

    entity *setEntity( const string entityToUse );
    void setEntity( entity *entityToUse );
    entity *getEntity( void ) const;

    void removeEntity( void );
    void removeAndDestroyEntity( void );

  };

  //oasisCameraSystem.h
  class cameraSystem : 
                    public movable
                    //public singleton< cameraSystem > 
    {
  public:
   void reset( void );
   void setSoundListener( bool isListener );
   void setDirection( real x, real y, real z );
   void setDirection( const vector3 &newDirection );
   void lookAt( const object *target );
   void lookAt( real x, real y, real z ); 
   void lookAt( const vector3 &target );
   static cameraSystem &get( );
  };
  //%name(getCameraSystem) cameraSystem::get();
  
  //oasisFrameListener.h
  class frameListenerSystem 
                    //public singleton< frameListenerSystem > 
    { 
  public:
    void reset( void ); 
    void setTimeScale( real scale );
    const real getTimeScale( void ) const;
    static frameListenerSystem &get( );
  };
  //%name(getFrameListenerSystem) frameListenerSystem::get(); 
  
  class entity { 
  public:
    void setAllMaterials( const string materialName );
  };

  //oasisGraphicsSystem.h
  class graphicsSystem :
                public pool
                //public singleton< graphicsSystem > 
    {
  public:
                
    enum DetailLevel {
        DL_POINTS       = 0,
        DL_WIREFRAME    = 1,
        DL_SOLID        = 2,
    };

    enum FogMode {
        FM_NONE     = 0,
        FM_EXP      = 1,
        FM_EXP2     = 2,
        FM_LINEAR   = 3,
    };

    void reset( void );
    
    void setSkyBox( bool active,
            const string material,
            real distance = 7000,
            bool drawFirst = true );

    void setFog( FogMode fogMode, 
            const colour &fogColour,
            real  expDensity = 0.001,
            real linearStart = 0,
            real linearEnd = 1 );

    void setBackgroundColour( real r, real g, real b );
    void setBackgroundColour( const colour &newColour );

    void setAmbientLight( real r, real g, real b );
    void setAmbientLight( const colour &newColour );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -