Jump to content

Rick

Members
  • Posts

    7,936
  • Joined

  • Last visited

Everything posted by Rick

  1. Wouldn't you need to set your character controller position to make sure it starts at the right spot in the new scene? If you are stuck underneath the new scene, call a SetPosition() once on the controller to a point where you will be above the scene and when you fall you land on the ground or something in your scene. If you are below your scene you should be falling and any movement would probably look like you aren't moving at all.
  2. I think I'll give your number 2 a shot. Seems easier. "Use a static body you move around, and connect the dynamic body to it with a fixed joint." I never played around with physics joints. Is the Vec3 in CreateJointFixed() a relative position from the parent or is it a global position? Also, if I make the parent body the one I move around, I assume the joint moves with it? So in my moving platform I would make a body that I move with SetPosition(), and another body positioned above my first body. Then create a joint where the first body is the parent and the second body is the child?
  3. Very cool Kevin. Welcome aboard!
  4. Finally a character artists You might be able to make some money here! I'll tell you what. If you don't use that character you posted, I'd be interested in it. I'm making a 3D platform "side scroller" if you will and he would be perfect.
  5. Code only? Are you crazy. Look how easy that is for people to use. If you don't want to do the Thingoid give me what you have and I'll maintain it. This is a must Thingoid. It's so easy to use this way.
  6. Are you sure you aren't clinically insane? j/k, it's just you say the darndest things sometimes. I think most everyone would rather use a little bit of memory than cluttering their hard drive up with all these sbx files. Which is why it's done the way it is.
  7. Damn. So I assume I have to give it a mass and apply equal force on all sides to make it float? Then I guess I adjust the force on a given side to move it a certain direction? Essentially I want to be able to move this cube to pivots that I place.
  8. These cubes will always have a mass of 0 and will never twist or turn, just move forward/backward/left/right/up/down. So I assume I only need to mess around with the force value then if applied directly to the center of the physics body as I assume that shouldn't cause any sort of twisting of the object? I should have probably listened in physics class.
  9. Is there any way to basically set the position of a physics object continuously and still have it's physics work? We all know using SetPosition() on a body stops physics from working. So how can I simulate a set position on a body? I want to be able to set the position of a cube I have a physics body attached to and still have that physics body react to physics (ie, if a character jumps on it, the character won't fall through it. I don't have a mass on this physics body so it's like a floating cube in the world that I want to alter it's position yet still have the character controller able to stand on it)
  10. That's a good idea. I'll give that a try and see what happens.
  11. Yeah I found this Process Monitor - Sysinternals, that basically traces everything a process is doing, but I can't see to find the reason as to why the editor crashes.
  12. Well I just figured that since my custom dll is the one that is loading the engine.dll that the engine.dll would need to be in the directory as my custom dll and not the main program that called my custom dll. That's not that far fetched of thinking. Since my custom dll is the one that is using engine.dll and not the lua interpreter.
  13. I wonder if I can tell, when it's running, where it's looking for the engine.dll.
  14. I would assume that would work. I still want to figure this out. I'm 99% sure that the dll will be able to allocate objects IF we can call Graphics(). Of course that would create a separate window, but that can be hidden. It's not idea, but really the graphics system just needs to be created and no window. Once that's up passing in the world and maybe some buffers should allow every command to be done on anything you pass in. We already know by passing in the pointer to the object the dll has access to it, which is why commands that manipulate objects works. The reason you can't create a texture in the dll is because Graphics() wasn't called. If we can get Graphics() called in the dll, then you will be able to make a texture object and apply it to an object. This is essentially like having 2 LE graphics systems running at the same time, and they have access to each others data because we are passing around pointers. I think the really cool thing with this is that this combined with coroutines could basically treat it like a separate thread. You pass your lua object to the dll and then in a coroutine from lua you call a function in your dll that does all the playing of the data. Because it's a coroutine the rest of the lua program continues to work, while the coroutine stays in the dll running it's own loop. Or lua also has threads that we might be able to take advantage of.
  15. I see that it's not Graphics() fault. Initialize() is failing to load engine.dll. I think I need to figure out where engine.dll needs to be for this to work.
  16. hmm, interesting. I needed to have the engine.dll where my lua script was saved to, NOT where Rick.dll was saved to.
  17. Has anyone ever tried calling Graphics() from a dll? It seems to crash my program when I have a dll that has a function that calls Graphics() and I load that dll from a simple lua script: assert(package.loadlib("C:\\Program Files\\Leadwerks Engine SDK\\Models\\Entities\\Pi\\Pi-Cube\\Rick.dll", "luaopen_test"))() Rick.Init() That's the entire lua script. I'm running it stand alone just like that. Init() ends up running: void CreateGraphics() { MessageBoxA(0, "Before Graphics()", "dll", 0); int ret = Graphics(800, 600); if(ret == 0) MessageBoxA(0, "Failed to load graphics", "dll", 0); MessageBoxA(0, "After Graphics()", "dll", 0); } static int Init(lua_State* L) { Initialize(); CreateGraphics(); return 0; } Yet SciTE bombs and I never get a message box after "Before Graphics()". SciTE's debug window says "engine.dll failed to load." I'm not sure why that would be though. There is no other details. The engine.dll is in the same directory as my custom dll. So not sure why it would fail to load it. I mean dll's can use other dlls right?
  18. Will give this a try tonight. Very cool!
  19. I like the feel of that. Very scary On a side note I'm guessing that the candle is like that even when in editor mode. Which obviously is a pain. This is why I make a global string value that I set in the main lua file that tells me if I'm in editor mode or game mode. That way when editing the object doesn't get in the way.
  20. ?? That's what I've been doing all along. Show us your entire candle lua file.
  21. So why would Graphics(800,600) fail when called from a dll? I assume Graphics() creates it's own window to work in? [EDIT] So that's step one to solve. Can you get the Graphics() call to work in a dll?
  22. If the dll can use a TEntity, does that mean that if the dll inits a new instance of the engine we could pass the world and buffers and then be able to allocate materials and paint them? Niosop, when you tried to create a material and assign it, did you do the whole Graphics() and other initing LE commands first? Maybe put that stuff in the Init() method. I'd guess that would work. I have to work now but will give that stuff a try when I get home.
  23. Rick

    collisions

    I'm hoping that with this new found dll stuff I can get around this. I might be able to pass my physics body and world to the dll and be able get it to call a function in C++ that I can map back to lua. I'll play around with the idea.
  24. So with all this cool stuff of videos and website on cubes I thought, this stuff needs to get into lua. Yet these are using C++ libraries. So how can this work? Well, I figured out, with the help of Josh & the guy who created the lua implementation, although I was really close and just needed a nudge in the right direction...anyway The Goal ======== Create a cube in lua Create a dll in C++ that will rotate the lua cube inside the editor The idea is that if I can do this, I can pass any object created in lua from the editor to your own dll and run LE functions on it. This can help make things like having videos and webpages on models as easy as setting a property for that object in the editor. Or AI stuff being done in C++ code instead of lua to help speed things up. This is still pretty rough around the edges. Not every detail has been worked out, but just getting it to work was pretty cool What you need: ============== Lua Library Leadwerks (obviously) C++ Compiler (VS is preferred by me) Patience 1. Create a C++ dll. a. File->New Project b. Visual C++->Win32->Win32 Console Application c. Next in the wizard->DLL->Empty Project d. Add your main.cpp file & LE's engine.cpp e. Project->Properties->Configuration Properties->C/C++->General, add include directories to LE's CPP and Lua's Include folder f. Project->Properties->Configuration Properties->Linker->Input, add the 2 lua .lib files here. Be sure to put in "'s Copy the below code for your main code: #define LUA_API_EXP __declspec(dllexport) #include "engine.h" #include <string> using namespace std; extern "C" { #include "lua.h" #include "lualib.h" #include "lauxlib.h" // prevents the function name from being mangled LUA_API_EXP int luaopen_test(lua_State *L); } static int RickRotate(lua_State* L) { // returns a pointer to the pointer char** TEntity entity = *(TEntity*)lua_touserdata(L, 1); TurnEntity(entity, Vec3(0, 1, 0)); return 0; } static int Init(lua_State* L) { ::Initialize(); return 0; } static const luaL_reg testlib[] = { {"Init", Init}, {"RickRotate", RickRotate}, {NULL, NULL} }; LUA_API_EXP int luaopen_test(lua_State *L) { luaL_openlib(L, "Rick", testlib, 0); return 1; } Compile the DLL in release mode. Copy this DLL, the engine.dll, lua5.1.dll, lua51.dll and maybe newton.dll and JointLibrary.dll to one of the lua models that you want to run this test on. Inside whatever lua model you want to run, open the lua file for it. In the CreateObject() method copy this line in, replacing the directory path of your dll to where ever you placed it: assert(package.loadlib("C:\\Program Files\\Leadwerks Engine SDK\\Models\\Entities\\Pi\\Pi-Cube\\Rick.dll", "luaopen_test"))() Rick.Init() This will load your dll so it can be used in lua and call the luaopen_test method right away. This creates the Rick object for lua. Then it calls the Init() function of the Rick object, which inits the LE DLL for use. Then in your lua models Update() method call: Rick.RickRotate(object.model) This assume you assigned the model passed to CreateObject, to a variable object.model. If everything worked out correctly you should see your model rotating in the editor. If not, feel free to post the error and I'll try to help. I'm hoping that this starts opening up many doors for lua.
  25. Rick

    CreateCube()

    I have question in with Josh, but thought I'd also ask here. Does anyone know what CreateCube() when called from lua is really returning? Is it a TEntity or is it something else?
×
×
  • Create New...