Jump to content

DaDonik

Members
  • Posts

    376
  • Joined

  • Last visited

Posts posted by DaDonik

  1. You could also use the callback functions.

    The UpdateCallback will be called once per loop and even delivers you the entity for which the callback is called. I use this approach and have no problems so far.

    Due to the fact that the game loop does not know anything about the game entities, you have

    to send informaton via messages, but that works fine.

  2. Some of you don't use the entity's user data unsure.gif

     

    It's such an awesome feature!!

     

     

    Maybe this example will help you wink.gif

    It's an example i pasted together from my code, so don't expect it to work

    via copy&paste.

    In the ProccessScene function you can call

    CPlayer* NewPlayer = new CPlayer (_Entity, _RootEntity);

    assuming that _Entity is the currently processed entity and _RootEntity is some

    global entity for message handling.

    After executing that line, the player has a pointer to it's own CPlayer class instance

    as it's entity user data. It can access that user data (CPlayer class) on every callback.

     

    Actually this is why i love Leadwerks biggrin.gif

     

     

    /////////////////////////////////////////////////////////////////////////////
    /// This class represents the user data (UD) of the player.
    /////////////////////////////////////////////////////////////////////////////
    class CPlayer
    {
    public:
    /////////////////////////////////////////////////////////////////////////
    /// Do everything needed to get the entity ready.
    /// 
    /// \param _Entity The entity the user data corresponds to
    /// \param _RootEntity The main entity of the game
    /////////////////////////////////////////////////////////////////////////
    CPlayer (TEntity _Entity, TEntity _RootEntity)
    {
     this->Init ();
    
     // Remember the entity, this class belongs to
     this->m_Entity = _Entity; 
    
     // Remember the game global root entity
     this->m_RootEntity = _RootEntity;
    
     // Set this class as the user data of the entity
     SetEntityUserData (this->m_Entity, (byte*)this);
    
     // Enable callbacks, which will further control the entity and it's 
     // behaviour. ENTITYCALLBACK_FREE should always be used, to free
     // dynamically allocated memory. Just comment out he ones not needed, or
     // leave them as they are.
    
     // Called when the entity is freed for some reason.
     SetEntityCallback (this->m_Entity,
       (byte*)GECPlayer::CBFree, ENTITYCALLBACK_FREE);
    
     // Called once per frame.
     SetEntityCallback (this->m_Entity, 
       (byte*)GECPlayer::CBUpdate, ENTITYCALLBACK_UPDATE);
    
     // Called whenever the entity moves or rotates.
     SetEntityCallback (this->m_Entity,
       (byte*)GECPlayer::CBUpdateMatrix, ENTITYCALLBACK_UPDATEMATRIX);
    
     // Called 60 times per second, independent of the framerate.
     SetEntityCallback (this->m_Entity,
      (byte*)GECPlayer::CBUpdatePhysics, ENTITYCALLBACK_UPDATEPHYSICS);
    
     // Called whenever a collision occurs. 
     SetEntityCallback (this->m_Entity, 
       (byte*)GECPlayer::CBCollision, ENTITYCALLBACK_COLLISION);
    
     // Called when the entity Receives a message.
     SetEntityCallback (this->m_Entity,
     (byte*)GECPlayer::CBMessageReceive, ENTITYCALLBACK_MESSAGERECEIVE);
    
     // Do whatever needed to initialize
    }
    
    
    /////////////////////////////////////////////////////////////////////////
    /// Standard destructor.
    /////////////////////////////////////////////////////////////////////////
    ~CPlayer ();
    
    private:
    /////////////////////////////////////////////////////////////////////////
    /// Called when the entity is freed for some reason.
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBFree (TEntity entity)
    {
     GECPlayer* pUD = (GECPlayer*)GetEntityUserData (entity);
    
     if (NULL != pUD)
     {
      delete pUD;
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Called once per frame.
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBUpdate (TEntity entity)
    { 
     CPlayer* pUD = (CPlayer*)GetEntityUserData (entity);
    
     if (NULL != pUD)
     {
    
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Called whenever the entity moves or rotates.
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBUpdateMatrix (TEntity entity)
    {
     CPlayer* pUD = (CPlayer*)GetEntityUserData (entity);
    
     if (NULL != pUD)
     {
    
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Called 60 times per second, independent of the framerate.
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBUpdatePhysics (TEntity entity)
    {
     CPlayer* pUD = (CPlayer*)GetEntityUserData (entity);
    
     if (NULL != pUD)
     {
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Called whenever a colision occurs. 
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBCollision ( TEntity entity0,
             TEntity entity1, 
             byte* position, 
             byte* normal, 
             byte* force, 
             flt speed )
    {
     CPlayer* pUD = (CPlayer*)GetEntityUserData (entity0);
    
     if (NULL != pUD)
     {
      TVec3 VecPosition; memcpy (&VecPosition, position, sizeof (TVec3));
      TVec3 VecForce;  memcpy (&VecForce, force, sizeof (TVec3));
      TVec3 VecNormal; memcpy (&VecNormal, normal, sizeof (TVec3));
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Called when the entity Receives a message.
    /////////////////////////////////////////////////////////////////////////
    static void _stdcall CBMessageReceive ( TEntity entity, 
               char* message,
               byte* extra)
    {
     CPlayer* pUD = (CPlayer*)GetEntityUserData (entity);
    
     if (NULL != pUD)
     {
    
     }
    }
    
    /////////////////////////////////////////////////////////////////////////
    /// Initializes all member variables with default values.
    /////////////////////////////////////////////////////////////////////////
    void Init ();
    
    /// The entity this user data class belongs to.
    TEntity m_Entity;
    
    /// The game global root entity.
    TEntity m_RootEntity;
    }; 
    
    
    
    

  3. For the speed...you may need to try it, depends on what you are doing i assume.

    AFAIK Lua will be the slowest, as it is an interpreter.

     

    In general C/C++ will be the fastest, but as LE is programmed in BlitzMax, i don't

    know if BlitzMax would be faster.

     

    Do you have any programming experience?

  4. Josh has just asked us the question what exactly we want

    DisableNewton (true);

    to do. Like he pointed out, disabling Newton would affect some

    parts of the engine.

    From my point of view he is in no way acting as if we are dumb unsure.gif

    Maybe you should read in between the lines, Tyler wink.gif

     

     

    My 50 Cents to physX in LE:

    I'm neither a hate, nor a fanboy of any physics engine. I just see,

    that this "DisableNewton ()" command would cost Josh another

    week in which he can't fix bugs or add any documentation or new stuff.

    Masterxilo already implemented physX and shows us it works. IMO there

    i no need for a DisableNewton () command , anyone using physX will

    have a little overhead, but it will work.

     

    When your game is nearly finished and you need every bit of performance

    for the release, than pay him a few bucks to disable newton for you.

    That way everyone is happy and Josh can go on, careing for the more

    important things smile.gif

  5. In your video you can see the 3 shadow stages of the directional light. (these circles of popping up shadows).

    Try changing the light's range to something higher, like Marley suggested. If that doesn't work for you,

    you can set the distance for every shadow stage. Look up SetShadowDistance.

  6. It's working with Framewerk

    smile.gif

     

    All i had to add to my project was:

    SetGlobalObject ("world_main", g_FW.GetMain ().GetWorld ());

    SetGlobalObject ("world_transparency", g_FW.GetTransparency ().GetWorld ());

    SetGlobalObject ("world_background", g_FW.GetBackground ().GetWorld ());

    SetGlobalObject ("camera_main", g_FW.GetMain ().GetCamera ());

    SetGlobalObject ("camera_transparency", g_FW.GetTransparency ().GetCamera ());

    SetGlobalObject ("camera_background", g_FW.GetBackground ().GetCamera ());

    g_FW is an instance of the Framewerk...obviously laugh.gif

     

     

    Josh, you told us that LUA runs along with C++ with NO code changes...thats just not true!

    I need the 6 lines above!! tongue.gif

     

     

×
×
  • Create New...