Jump to content

Roland

Members
  • Posts

    2,953
  • Joined

  • Last visited

Posts posted by Roland

  1. Thanks Josh. That changed nothing.

    However I have found that the reason why its working for you is that you are having

    "using namespace Leadwerks;" in your headers. I tested by adding that to my example

     

    Doesn't work

     

    #include "Leadwerks.h"//lua
    class Test
    {
    public:
    Test( Leadwerks::Entity* e);//lua
    };
    

     

    This works

    #include "Leadwerks.h"//lua
    using namespace Leadwerks;
    class Test
    {
    public
    Test(Entity* e);//lua
    };
    

     

    Pgk-file (same in both cases)

    $#include "Leadwerks.h"
    $#include "Test.h"
    
    class Test
    {
    Test(Entity* ent );
    };

     

     

    I don't like to have 'using' in my headers but I'll guess I can live with that for my Lua-exposed classes wink.png so I guess we can say its solved then. Thanks for taking the time.

    • Upvote 2
  2. I mean entity pointers should work just fine with ToLua++.

    Really. Could you give a simple example.

     

    class Test
    {
    public:
    Test( Leadwerks::Entity* e );
    };
    
    

     

    gives an error at runtime saying that argument #2 is a Leadwerks::Model

     

    This works though

     

    class Test
    {
    public:
    Test( void* e );
    };
    
    

     

     

    in LUA

    Script.cpp = nil
    
    function Script:Start()
    cpp = Test:new( self.entity)
    end
    
    

  3. To be picky smile.png

     

    The public method ClearAnimations also have a potential memory leak as it can be called from anywhere and it erases all elements without deleting them.

     

    Easy fixed by moving the delete loop from the destructor to ClearAnimations

     

    
    AnimationManager::~AnimationManager() {
             ClearAnimations();
    }
    
    void AnimationManager::ClearAnimations()
    {
        for (auto it = animations.begin(); it != animations.end(); ++it)
       {
             delete *it;
       }
       animations.clear();
    }
    
    

    • Upvote 1
  4. Tested the C++ version. There's a memory leak here

     
    if (n < maxanim) {
        if (completedanimation->mode == false || completedanimation->endOfSequenceReached == true) {
              animations.erase(animations.begin() + n);
        }
    }
    

     

    should be something like

     

     
    if (n < maxanim) {
        if (completedanimation->mode == false || completedanimation->endOfSequenceReached == true) {
           delete animations[n]; // prevent memory leak   
           animations.erase(animations.begin() + n);
        }
    }
    

    • Upvote 1
  5. You can't pass entity objects from Lua to C++. I recommend setting a UUID field on the Key map for Entities and loop through all entities in World to get the entity in C++.

    Of course you can pass Entitys from LUA to C++. Here is a fictional example on how I do that. Say we have a LUA script containing some Entity, say a Box Shape. Now we want to pass this Script and its entity to a C++ class for some work. I type in this just from my head so there might be some minor errors but you get the idea.

    What was talking about was those void* pointers. That works but it would have been nicer to use Leadwerks::Entity* pointers which they really are.

     

    RotatingBox.lua: LUA Script

    Script.TheBox box = nil --entity "The Box"

    Script.Speed speed = 0.5 --float "Speed"

     

    Script.cppworker = nil

     

    function Script.Start()

    cpp = CppWorker:new( self.entity ) -- passing our self to C++

    end

     

    function Script:Update()

    cpp:rotate( self.box ) -- passing the box entity to C++

    end

     

     

    CppWorker.h: C++ Class Header

    #pragma once

    #include "Leadwerks.h"

     

    class CppWorker

    {

    float _speed;

     

    public:

    // Have to use void* instead of Leadwerks::Entity*

    CppWorker( void* luascript_entity );

     

    // Same here. Have to use void* instead of Leadwerks::Entity*

    void rotate(void* entity);

    };

     

    CppWorker.cpp: C++ Class Source

    #include "CppWorker.h"

     

    CppWorker::CppWorker( void* luascript_entity )

    {

    Leadwerks::Entity* luaentity = reinterpret_cast<Leadwerks::Entity*>(luascript_entity); //Script Entity from LUA

     

    // reading speed from LUA

     

    int stacksize = Leadwerks::Interpreter::GetStackSize();

    luaentity->Push();

    Leadwerks::Interpreter::GetField("script");

    if (Leadwerks::Interpreter::IsTable())

    {

    Leadwerks::Interpreter::GetField("Speed");

    _speed = atof(Leadwerks::Interpreter::GetVariableValue().c_str());

     

    }

    Leadwerks::Interpreter::SetStackSize(stacksize);

    }

     

    void CppWorker::rotate(void* entity)

    {

    Leadwerks::Entity* e = reinterpret_cast<Leadwerks::Entity*>(entity);

    e->Turn( 0, Leadwerks::Time::GetSpeed() * _speed, 0 );

    }

     

    CppWorker: ToLua++ Source

    $#include "Leadwerks.h"

    $#include "CppWorker.h"

     

    class CppWorker

    {

    public:

    CppWorker( void* luascript_entity );

    void rotate(void* entity);

    };

     

    tolua++ -o CppWorker_.cpp -n CppWorker -H CppWorker_.h CppWorker.pkg

     

    Compilation

    Add CppWorker_.h and CppWorker_.cpp to the project and in App.cpp add #include "CppWorker_.h" at the top and then add this line at some convinient place in your App.cpp, something like this

    ...

    tolua_FpsPlayer_open(Leadwerks::Interpreter::L);

    if (!Interpreter::ExecuteFile(scriptpath))

    ...

    ..

     

    Test

    Add the script RotatingBox.lua to some Entity in you scene and if your the

    box will rotate. The CppWorker does the rotation of the Lua Entity 'box'

    using the Lua value 'speed'.

     

     

    PS:

    Oh how I hate this forum editor that removes the tab-indentations in code

  6. It's actually mostly annoying. It works with void* but typeless pointers isn't anything I really like having. And inside the function it's that extra reinterpret_cast<Leadwerks:: Entity*>(pointervalue) to do. Just wondered if anyone had come up with a way to make it cleanly

  7. I have successfully managed to use toLua++ in order to expose my C++ classes to LUA. All works fine and dandy, however I have to use void* pointers in functions where there is a Entity* pointer. Its really no big problem but I would like to now if any one else know something about this. Example:

     

     

    class MyClass
    {
    public:
       MyClass();
       void some_function( Leadwerks::Entity* e );
    }
    

     

    That one causes a crash in LUA when some_function is called

     

    function Script.Start()
       myclass = MyClass:new() -- OK
       myclass:some_function( self.entity ) -- KRASH
    end
    

     

     

    Now if I instead use a void* all works great

     

    class MyClass
    {
    public:
       MyClass();
       void some_function( void* e );
    }
    

     

    This one works in LUA when some_function is called

     

    function Script.Start()
       myclass = MyClass:new() -- OK
       myclass:some_function( self.entity ) -- OK
    end
    

     

    I can understand that toLua++ apparently doesn't handle the Leadwerks::Entity* as expected. Is there anyone that have come across this little problem and if so how to fix it? I couldn't come up with something. Meanwhile I can live with the void* although I don't like it.

  8. 14.04 seems a bit old

     

     

    Release Released End of life

    Ubuntu 16.04 LTS Apr-2016 Apr-2021

    Ubuntu 15.10 Oct-2015 Dec-2015

    Ubuntu 15.04 Apr-2015 Jun-2015

    Ubuntu 14.10 Oct-2014 Dec-2014

    Ubuntu 14.04 LTS Apr-2014 Apr-2019

    Ubuntu 12.04 LTS Apr-2012 Apr-2017

    Ubuntu 10.04 LTS Apr-2010 Apr-2015

     

    • Upvote 1
  9. Ubuntu 16.04 TLS

    CodeBlocks 16.01

    gcc 5.4.0

     

     

    1. Create a new blank project, Test

    2. Open Test/Projects/Linux/Test.cbp in CodeBlocks

    3. Compile

     

    This is what you will get

    -------------------------------------

    ||=== Build: Debug in Test (compiler: GNU GCC Compiler) ===|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Directory.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Stream.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|2|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /home/rstralberg/.steam/steam/steamapps/common/Leadwerks/Include/Classes/Drivers/Graphics/OpenGL2/OpenGL2Texture.h|3|warning: ignoring #pragma warning [-Wunknown-pragmas]|

    /mnt/Store/Leadwerks/Test/Source/main.cpp||In function ‘void DebugErrorHook(char*)’:|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|12|warning: unused variable ‘n’ [-Wunused-variable]|

    /mnt/Store/Leadwerks/Test/Source/main.cpp||In function ‘int main(int, const char**)’:|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|76|warning: comparison between signed and unsigned integer expressions [-Wsign-compare]|

    ../../Source/App.o||In function `App::Start()':|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|16|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|22|undefined reference to `Leadwerks::Interpreter::SetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|25|undefined reference to `Leadwerks::FileSystem::GetFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|28|undefined reference to `Leadwerks::Interpreter::ExecuteFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|30|undefined reference to `Leadwerks::System::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|35|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|38|undefined reference to `Leadwerks::Interpreter::PushString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    ../../Source/App.o||In function `App::Loop()':|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|72|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|77|undefined reference to `Leadwerks::Interpreter::GetGlobal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/App.cpp|80|undefined reference to `Leadwerks::Interpreter::PushString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    ../../Source/main.o||In function `main':|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|35|undefined reference to `Leadwerks::FileSystem::StripAll(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|36|undefined reference to `Leadwerks::String::Right(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|36|undefined reference to `Leadwerks::String::Left(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|37|undefined reference to `Leadwerks::System::AppName[abi:cxx11]'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|38|undefined reference to `Leadwerks::FileSystem::GetAppDataPath[abi:cxx11]()'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|41|undefined reference to `Leadwerks::String::Lower(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|48|undefined reference to `Leadwerks::FileSystem::GetFileType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|48|undefined reference to `Leadwerks::FileSystem::CreateDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|50|undefined reference to `Leadwerks::System::LoadSettings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|53|undefined reference to `Leadwerks::FileSystem::ExtractDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|53|undefined reference to `Leadwerks::System::AppPath[abi:cxx11]'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|59|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|59|undefined reference to `Leadwerks::String::Int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|62|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|65|undefined reference to `Leadwerks::Package::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|73|undefined reference to `Leadwerks::FileSystem::LoadDir(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|79|undefined reference to `Leadwerks::FileSystem::ExtractExt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|79|undefined reference to `Leadwerks::String::Lower(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|82|undefined reference to `Leadwerks::Package::Load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|89|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|93|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|93|undefined reference to `Leadwerks::String::Int(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|94|undefined reference to `Leadwerks::Interpreter::Connect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, int)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|96|undefined reference to `Leadwerks::String[abi:cxx11](int)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|96|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|99|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|100|undefined reference to `Leadwerks::System::GetProperty(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|103|undefined reference to `Leadwerks::Interpreter::LoadBreakpoints(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|105|undefined reference to `Leadwerks::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|148|undefined reference to `Leadwerks::System::SaveSettings(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'|

    /mnt/Store/Leadwerks/Test/Source/main.cpp|148|undefined reference to `Leadwerks::System::Print(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'|

    ||error: ld returned 1 exit status|

    ||=== Build failed: 42 error(s), 18 warning(s) (0 minute(s), 1 second(s)) ===|

     

    Seems all static functions in the Leadwerks library is unresolved.

  10. As Fuse/Mixamo is such a great resource for us small developers it's really a tragedy that it doesn't work in Linux. Again. It's remarkable that this problem has been allowed to exist for more than one year, specially as it's not a problem on another Linux friendly engine. Let's hope this can be solved so I can answer Yes if I get the question "Does Leadwerks work good in Linux"

    • Upvote 2
  11. All characters containing an animation renders out partially on Ubuntu. Here is an example with the Merc-model I bought from Leadwerks, including as much info as I could come up with.

     

    Edit: Later... I can see this is the active drivers report so I guess this was no news. What trouble's me then is that the report dates back to April 2015. As this apparently is still a problem, is there any workaround? As a note I have tested with another engine with same models (except the Merc the) without any problem which leads me to think thats it's a Leadwerks problem more than a driver problem

     

    post-395-0-73648800-1469227002_thumb.png

     

    post-395-0-71850700-1469227014.png

     

    post-395-0-90442100-1469227027.png

     

    post-395-0-87133300-1469227038_thumb.png

     

    log.txt

     

     

    post-395-0-70381300-1469227892.jpg

  12. Okay. I get what you mean. One way to avoid snapping would be to snap the pieces in Blender (or whatever) and export them. That would solve the problem I guess. Will go for that and see how it works.

×
×
  • Create New...