Jump to content

Charrua

Developers
  • Posts

    230
  • Joined

  • Last visited

Everything posted by Charrua

  1. Hi, I wrote this script while ago. Create a new blank project, replace the main.lua script with: --[[ Bezier in action Autor: Juan Ignacio Odriozola (aka Charrua) I rewrite a code in lua from an old work on the subject... math is all over the net, here i show a simple example of usage I'm interpolating just 2 axes, is 2d but with simple modifications you can make it 3d (as this is a "challenge month" try your self to make it 3d :) Usage: TAB to change selected point: green one Arrows to move it up/down, left/right (x,y axes) Enjoy! ]]-- spheres = {} controlOnes = {} current = 0 changed = false function App:Start() self.window = Window:Create("beziers",0,0,800,600) self.context = Context:Create(self.window) self.world = World:Create() self.camera = Camera:Create() self.camera:Move(0,0,-10) local light = DirectionalLight:Create() light:SetRotation(35,35,0) for i=0, 99 do spheres[i]=Model:Sphere() spheres[i]:SetScale(0.2) spheres[i]:SetColor(0.0,0.0,1.0) --blue end for i=0, 3 do controlOnes[i]=Model:Sphere() controlOnes[i]:SetPosition(-3+i*2,0,0) controlOnes[i]:SetScale(0.5) controlOnes[i]:SetColor(1.0,0.0,0.0) --red end controlOnes[current]:SetColor(0.0,1.0,0.0) --selected: green reposition() return true end function App:Loop() if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end --TAB to change Current selected Point if self.window:KeyHit(Key.Tab) then controlOnes[current]:SetColor(1.0,0.0,0.0) --left selection, returns to red current = current + 1 if current == 4 then current=0 end controlOnes[current]:SetColor(0.0,1.0,0.0) --selected: green end if self.window:KeyDown(Key.Left) then controlOnes[current]:Translate(-.01, 0, 0) changed=true end if self.window:KeyDown(Key.Right) then controlOnes[current]:Translate( .01, 0, 0) changed=true end if self.window:KeyDown(Key.Up) then controlOnes[current]:Translate( 0, .01, 0) changed=true end if self.window:KeyDown(Key.Down) then controlOnes[current]:Translate( 0, -.01, 0) changed=true end if changed then --time to recalc positions changed = false reposition() end Time:Update() self.world:Update() self.world:Render() self.context:Sync() return true end function reposition() local t=0.0 local step=0.0 local p1Pos=Vec3(0,0,0) p1Pos = controlOnes[0]:GetPosition(true) p2Pos = controlOnes[1]:GetPosition(true) p3Pos = controlOnes[2]:GetPosition(true) p4Pos = controlOnes[3]:GetPosition(true) System:Print(p1Pos.x .. " " .. p1Pos.y .. " " .. p1Pos.z) System:Print(p2Pos.x .. " " .. p2Pos.y .. " " .. p2Pos.z) System:Print(p3Pos.x .. " " .. p3Pos.y .. " " .. p3Pos.z) System:Print(p4Pos.x .. " " .. p4Pos.y .. " " .. p4Pos.z) for i=0, 99 do step = i t = step/100.0 spheres[i]:SetPosition(interpolatePos(t, p1Pos, p2Pos, p3Pos, p4Pos),true) end end function interpolatePos(t, p1, p2, p3, p4) local retVal=Vec3(0,0,0) local t3, t2, t1 t_3 = (1.0-t)^3 t_2 = (1.0-t)^2 t_1 = (1.0-t) t2 = t^2 t3 = t^3 retVal.x = p1.x * t_3 + 3 * p2.x * t_2 * t + 3 * p3.x * t_1 * t2 + p4.x * t3 retVal.y = p1.y * t_3 + 3 * p2.y * t_2 * t + 3 * p3.y * t_1 * t2 + p4.y * t3 retVal.z = p1.z * t_3 + 3 * p2.z * t_2 * t + 3 * p3.z * t_1 * t2 + p4.z * t3 return retVal end TAB to change the selected point (green one) Arrows to move the selected point (2D exmple) Untitled 48.avi App.lua
  2. HI, you can attach a lua script from the editor. If you have the profesional edition and you are using VSxxx and cpp you may interact with world elements created on the editor, call lua functions in the object's script, pass parameters, receive etc. I wrote this some time ago, don't know how much outdated it may be, but perhaps it will be a starting point: Juan
  3. Charrua

    stormy ocean

    when I got older, i would like to be like you!
  4. available on the workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=2490242870
  5. problem solved, is on the workshop for any ho wants to play with. https://steamcommunity.com/sharedfiles/filedetails/?id=2490242870 enjoy Juan
  6. forgot it! I started with the uak sample code, then load a map, etc but the standalone needs this: //Load any zip files in main directory Leadwerks::Directory* dir = Leadwerks::FileSystem::LoadDir("."); if (dir) { for (int i = 0; i < dir->files.size(); i++) { std::string file = dir->files[i]; std::string ext = Leadwerks::String::Lower(Leadwerks::FileSystem::ExtractExt(file)); if (ext == "zip" || ext == "pak") { Leadwerks::Package::Load(file); } } delete dir; } which i forgot! thanks for your help! Juan
  7. Thank´s I did that and found that it can not load the map! bool mapOk = false; mapOk = Map::Load("Maps/start.map"); System::Print(mapOk); so, no entities, no sun, no nothing ir runs ok form vs and leadwerks editor, any ideas?
  8. Hi, much time from my last post I have been testing UAK and Leadwerks, al right from VS running release and debug versions and from Leadwerks editor. I decided to publish a standalone, just for testing and it crashes. I guess that the problem is when I try to call a map entity´s function from cpp. If I place de uak1.debug.exe in the published folder, the last System:Print i saw is: "scanning entities": System::Print("scanning entities ..."); for (auto iter = world->entities.begin(); iter != world->entities.end(); iter++) { Entity* entity = *iter; if (entity->GetKeyValue("name")!="") { System::Print(entity->GetKeyValue("name")); if (hasFunction(entity, "dayNightTest")) { System::Print(" found entity dayNight"); dayNight = entity; //dayNight->CallFunction("dayNightTest"); } } } The function "hasFunction" test if an entity has or not a particular function defined and I guess the problem is there, not shure and do not know why. I commented the line: dayNight->CallFunction("dayNightTest"); because the "dayNightTest" function only has a System:Print on it, for debugging purposes. bool hasFunction(Entity* e, string funcName) { if (e->component == NULL) return false; bool success = false; //Get the component table int stacksize = Interpreter::GetStackSize(); //Get the global error handler function int errorfunctionindex = 0; #ifdef DEBUG Interpreter::GetGlobal("LuaErrorHandler"); errorfunctionindex = Interpreter::GetStackSize(); #endif e->Push(); Interpreter::GetField("script"); //test if entity has a script if (Interpreter::IsTable()) { System::Print(" entity has script"); Interpreter::GetField(funcName); if (Interpreter::IsFunction()) //test if funcName is a function { System::Print(" " + funcName + " defined"); success = true; } else { success = false; System::Print(" " + funcName + " not defined"); } } Interpreter::SetStackSize(stacksize); //keep stack under control return success; } Link the complete project (zip file): https://drive.google.com/file/d/1OWD4I8zAEZsLyKPOAl53VNTACxwyj4yR/view?usp=sharing BTW, it creates slider for the many controls the dayNight prefab has, here a picture of it running: Thanks in advance Juan
  9. Starting to work with UAK and Leadwerks Testing sliders c++ side sending values to lua script "daynignt.lua"
  10. I got it vía kikstarter, I received a beta 4 months ago. It shows on steam (today) but is on "coming soon state", I have received steam and leadwerks key, but I don't have any download link. How do I access the official 1.0 release? Thank's
  11. congrats, yea, joints are very interesting, some time ago, with blitz3d+jv-ode i did some interesting things... some of them i try to re-do in leadwerks: cars, and some transporting bels, forklift etc. guess i upload that some where... utility_cars.zip
  12. congrats it is just two motorized hinges? or some vehicle feature? haven't had time to play with leadwerks new features...
  13. Yes, that's the point. And, here, money do not reach aceptable levels. I mean, yes third world but not the worst country mine, but our army has few resources and this kind of equipment is a must at first training stages. I and my friend did the development with our money, now waiting for burocracy to get some bucks
  14. Well, finally, a job done! This is the press note of the military news youtube channel: On July 26, the "Comandos" day here in my country (Uruguay, I know no one knows what or where it is, so from where I am, but is fine was te official inauguration of a Shoot Simulator I been working on. (Attached a cut, with the part in which the simulator appear, simply a flash ) I made it with the Professional Edition of Leadwerks as a standalone app. on Ubuntu 16.04 The systems uses some not traditional Game/Software hardware, made by me and a couple of people like me, who works in the metalurgical industry. We receive real guns, insert on them sensors and actuators to simulate the real behavior of them. An infrared laser on it, is detected by a couple of special cameras wichs only sees the ir dots of the guns, then with some math, I translate the IR camera coords space to Leadwerks 3D world projected and seen for us. Turn on a laser of one gun, read the coord seen by the cameras (if any) and repeat for each gun is made by a main microcontroller that is in comunication with the microcontrollers on each camera. The main micronontroller also reads the gun´s sensors to know when a shoot is done and if it is ok to simulate a shoot or not, based on it the gun was reloaded etc.. State changes and camera coordinates are transimted to de PC and Leadwerks do the rest Attached some pictures, some commented, with relevant and not so relevant things Juan simuladorDeTiro.mp4
  15. Hi Alien, I'm also somewhat lost.. going back, nice to hear about you.
  16. Yes, so excited to see it almost finished. Guess next month will be installed and working... And perhaps I'll see some money
  17. Not yet, but, if the project continues, it should be a next step or something to take into consideration. A 360 degrees detection system should be possible, but, more complex and expensive
  18. He he, me too! This video is of a couple of years when we build the demonstration prototype. test4.mp4
  19. It's more hardware than software, leadwerks part is to have something to shoot :). Guns have infrared lasers, a camera system detects where the gun is in the screen, then with some maths to translate corrds to leadwerks, a camera pick, and that's it. Simply put. Electronics simulate the gun behavior, and as you will see, I'm not an expert RECORTAR_20190410_105041.mp4 RECORTAR_20190410_104628.mp4
  20. drives were mounted but as ro, did a mount -o remount rw / then nano .xsessionrc delete the "shutdown..." line and voila... all is working again thank you very much
  21. well, now I have another problem, my bad i placed a shutdown line after gedit, to test if the systems shotsdown after gedit, and found that the system start and shutdown (no gedit) is there a way of intercept startup and open a terminal so I can delete the .xsession file? thanks
  22. well, if i place a .xsessionrc file with: then ubuntu starts, exec gedit and gedit open the pj01.sh file located in the above directory but if, instead of gedit i place ./pj01.sh then LE app do not start
  23. Thanks, I'll try it as soon as I get home.
×
×
  • Create New...