-
Posts
230 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Charrua
-
-
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
- 2
-
problem solved, is on the workshop for any ho wants to play with.
https://steamcommunity.com/sharedfiles/filedetails/?id=2490242870
enjoy
Juan
-
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
- 1
-
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?
-
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
- 1
-
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
-
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
- 7
-
Hi Alien, I'm also somewhat lost.. going back, nice to hear about you.
- 1
-
Yes, so excited to see it almost finished.
Guess next month will be installed and working... And perhaps I'll see some money
-
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
- 1
-
He he, me too!
This video is of a couple of years when we build the demonstration prototype.
- 2
-
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
- 1
-
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
-
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
-
well, if i place a .xsessionrc file with:
Quote/home/juan/Documents/Leadwerks/Projects/pj01
gedit "pj01.sh" &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
-
Thanks, I'll try it as soon as I get home.
-
the thing now is how or from where I execute this script, because if i launch it from .config/autostart it start the leadwerks app, but do not shutdown the system
my idea was that turning on the PC the app autostart and when quitting it, the system shutdown
Is there other way to autostart an app?
-
-
Ah, ok!
yes, now, it shutdown if i run it from a terminal
not if I use the .desktop shortcut
Quotecd /home/juan/Documents/Leadwerks/Projects/pj01
export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}"
./pj01 "$@"
shutdown -h nowthis is the pj01.sh now
-
thanks, but nope
if i open a terminal and execute the pj01.sh script, the leadwerks app starts ok, and after it, simply the terminal again
last line of leadwerks throws :
AL lib: (EE) alc_cleanup: 1 device not closed
then, the propmt.(and, no other command on the script seems to be executed)
-
i placed a "ls" instead a shotdown, but nothing is executed after the leadwerks app
-
thanks for answer
i have this file in .config/autostart
Quote[Desktop Entry]
Encoding=UTF-8
Name=Simulador1
Comment=Launch DirSyncPro
Exec=gnome-terminal -e /home/juan/Documents/Leadwerks/Projects/pj01/pj01.sh
Icon=/usr/share/icons/HighContrast/32x32/apps/gnomine.png
Type=Applicationalso works with:
Quote[Desktop Entry]
Encoding=UTF-8
Name=Simulador2
Comment=Launch DirSyncPro
Exec=/home/juan/Documents/Leadwerks/Projects/pj01/pj01.sh
Icon=/usr/share/icons/HighContrast/32x32/apps/gnomine.png
Type=Applicationand the pj01.sh is:
Quotecd /home/juan/Documents/Leadwerks/Projects/pj01
export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}"
exec "./pj01" "$@"i write the line
Quoteshutdown -h now
after exec, but after pj01 ends, system do not shoot down
if I open a terminal, shutdown -h now, works ok
i try other combinations but, due to my lack of knowledge on the subject... i somewhat lost
Quotecd /home/juan/Documents/Leadwerks/Projects/pj01
export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}"
exec "./pj01" "$@"shutdown -h now
and with the !bin/bash
Quote#!/bin/bash
cd /home/juan/Documents/Leadwerks/Projects/pj01
export LD_LIBRARY_PATH=".:${LD_LIBRARY_PATH}"
exec "./pj01" "$@"shutdown -h now
Juan
-
Hi, it's been a long time from my last post here
I'm finishing a Leadwerks program on ubuntu 16.04, not a game, is a 3d graphical interface for a "Shoot simulator" with real (modified) guns.
I'm so novice with linux, so after some reading i got the application run at startup.
This application is the only one which will run on this pc, so it should start at startup and the system should shootdown when quitting from the application.
(after try and pray many times... )
Basically i end placing a .desktop file in .config\autostart directory with a exec command to the leadwerks script to run the project file, so simple once one get to know how
I guess that, i can place a shootdown command on the launch script, but I did not find the way, all my readings point to: shootdown -h now
(edit: i mean.. shutdown not shootdown)
but, i guess i'm not doing, writting, placing it in the correct way.
Some linux expert here?
Thank's in advance
Juan
-
you may also have to change th working directory... sooner or later
Juan
- 1
How to create a 2 point Bezier Curve? (Node Graph)
in Programming
Posted
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)
App.lua