-
Posts
4,127 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Posts posted by Canardia
-
-
Ah, I already thought there must be some smart solution like that
-
I think it's more a general programming language convention, where either everything is lowercase, or everything starting with a capital letter (and in the middle also, seperating words). Sometimes there are also lowercase beginning letters, and then capital letters in the middle, but that's very ugly, like in Java and JavaScript.
Normally in C everything is lowercase, and underscore is used as word seperator, but as nobody has a pure C compiler anymore, but a C/C++ compiler, and C has also developed a bit (to C99, which is almost like C++), where I think it's OK to use commands starting with capital letters, just like in C++, where it is the standard.
I would use in LUA the same convention as in the C headers, which means everything starts with capital letters, and has them also as word seperators. It would mean that Vec3.X should be used.
-
When using vec3, the coordinates should be noted with small letters (x,y,z), like GLSL does, and also NASA.
When using Vec3, the coordinates should be noted with capital letters (X,Y,Z), like in the C/C++ headers, or Panda3D (although it's a pure C++ API, so it uses getX() and setX() instead).
I find it a bit confusing, and hard to port code between LUA and C/C++, when LUA uses Vec3.x, and not vec3.x or Vec3.X.
-
For the airplane:
function Initialize() for model,entity in pairs(entitytable) do local target = model:GetTarget(0) if target~=nil then AppLog("TARGET 0 FOUND") pos = model:GetPosition() pos.y = pos.y + 0.02 pos.z = pos.z - 1.67 target:SetPosition(pos) rot = EntityRotation(model) target:SetRotation(rot) CreateJointHinge(model,target,Vec3(-1,0,-1.67),Vec3(0,0,-1.67)) end end end
For the propeller:
function UpdatePhysics(model) local entity,model for model,entity in pairs(entitytable) do if entity.active~=0 then model:AddTorque( Vec3( 0, 0, 100 ) ) end end end
-
I tried to add a propeller to the rear of the airplane, but no matter how I joint it, it always rotates the airplane too, when I turn the propeller (model is the airplane, target is the propeller), and I try to turn the target around its Z axis:
CreateJointHinge(model,target,Vec3(-1,0,-1.67),Vec3(0,0,-1.67))
A similar code works fine in C++, and I can turn the target around its Y axis:
CreateJointHinge(model,target,Vec3(-1,3,0),Vec3(0,3,0))
Btw, a documentation how joints should be used would be also nice, so far I've been only guessing
-
It would be logical to have model:SetRotation() and model:GetRotation(), since there is also model:GetPosition() and model:SetPosition():
pos = model:GetPosition() target:SetPosition(pos) rot = model:GetRotation() target:SetRotation(rot)
-
Yeah, that would be faster.
-
Ah, that was it!
It doesn't really matter in which order the 2 models are spawned, since both need to be loaded first.
I need to make a delayed initialize, so around 5 seconds after the scene is loaded, I need to call my custom Initialize() function for all models:
function Initialize() for model,entity in pairs(entitytable) do local target = model:GetTarget(0) if target~=nil then AppLog("TARGET 0 FOUND") end end end
I don't know if there is somekind of function which would inform me that all models are loaded, or do I really have to wait for a random amount of time before I can call this Initialize for all models.
Actually I have one idea how to make this automatic: I could create a SceneReady model, which I manually place at the end of the sbx file, and it would have an script which sets a global flag that now the whole scene is loaded. Then the UpdatePhysics() function of each Model checks for that flag, and calls the Initialize() function once.
Or I could have a frame counter, which is raised by 1 each time the UpdateWorld() is called. The FrameCounter would be a model too, and only if it has the value 2, then the Initialize function would be called from each Model's UpdatePhysics() function.
-
I think you have multiple physics bodies, if you don't create one with phygen, but create one by code on top of the fixed physics body which Editor creates if you didn't create your own physics body with phygen.
-
When I add this to my Spawn function, it doesn't find the target:
function Spawn(model) local entity=base_Spawn(model) local target = model:GetTarget(0) if target~=nil then AppLog("TARGET 0 FOUND") end end
It's correctly targetted in the sbx file:
Model { path="fuselage.gmf" position=-2.82523990,10.4962835,-4.36183310 rotation=-1.15659511,0.360873282,-0.258110493 scale=1.00000000,1.00000000,1.00000000 id=503696184 target0=503749016 "class"="Model" "collisiontype"="1" "friction"="0.00999999978,0.00999999978" "intensity"="1" "mass"="1.0000000000000000" "name"="fuselage_1" "reloadafterscript"="1" } Model { path="propeller.gmf" position=-2.84715009,9.77161789,-6.75078249 rotation=0.000000000,0.000000000,-0.585468173 scale=1.00000000,1.00000000,1.00000000 id=503749016 "class"="Model" "collisiontype"="1" "friction"="0.500000000,0.500000000" "gravity"="0" "intensity"="1" "mass"="1.0000000000000000" "name"="propeller_2" "reloadafterscript"="1" }
-
You don't need to create a physics body with LUA, just make a phy file with phygen for it.
-
Print("HELLO") didn't work for me, but AppLog("HELLO") works fine.
-
I would build the submarine of seperate components, and then join them together with physics joints.
That way you can have many identical compartments repeating through the submarine, and just add some pipes, desks, shelves and other stuff to each compartment.
That makes you also able to break the submarine apart, or only parts of it.
And when the submarine turns, pitches or rolls, the player would see the angle, even when he is inside the ship.
I think that would bring a great immersion and make it feel more real.
-
Theoretically when you add this code block to the fpscontroller.lua, after the line fw=GetGlobalObject("framewerk"), it should make it runnable from outside Editor, but for some reason it crashes. Maybe Josh could check why?:
if fw==nil then --Register abstract path RegisterAbstractPath("") --Set graphics mode if Graphics(1024,768)==0 then Notify("Failed to set graphics mode.",1) return end --Create framewerk object and set it to a global object so other scripts can access it fw=CreateFramewerk() if fw==nil then Notify("Failed to initialize engine.",1) return end SetGlobalObject("framewerk",fw) fw.main.camera.position.y=20 scene=LoadScene("abstract::tunnels.sbx") end
If you change it to load train.sbx, then it doesn't crash, but the player doesn't collide with the terrain.
I tried scene:SetType(1), but there is no such command.
-
Those lines need to be added to gamelib, so you don't have to write any additional lines in your game code.
-
LE uses OpenGL 2.1 at the moment, that's much better than DX 11 (which only Win7, and no hardware cards yet support), and it runs even on XP (and Mac, Linux, and all other systems).
-
There was a LUA GUI made by TylerH in LE 2.3 Beta 2. It's not included in the final LE 2.3, so I guess it will be published later.
-
Exactly, and if I find it easy to learn new things, you should find it even easierReally ? You must be very old
-
I had computers even before I had the C64 and Amiga. Anyway, just try it in a real game, you'll be surprised how well the human adaption engine worksI have used Computers since the old C64 and Amiga days and never felt naturaly with the WASD keys. It should be optional. (Easy to do for Josh, i think)
-
You get used to it very quickly, like in 5 minutes, and after that WASD feels much easier and more natural than cursor keys. I also used cursor keys for years, but one day I tried WASD keys and I was amazed how much better it is, I could now also access the number keys much faster to switch weapons and cast spells (in WoW). Also the E key for activating things, and F key to pick up things are next to your movement keys now. Some modern laptops, like from ASUS come also with pre-marked WASD keys.Please allow to use the cursor keys for moving in the Editor too. I am not good with the WASD keys. Thank You.
-
Test
in Programming
Test
-
My first test reply!
- 1
object sinks threw terrain?
in Programming
Posted
I think you shouldn't do that, but if you do, you need at least to set EntityType(body1,1). Although I think that command does not exist in LUA. You can't also use physics bodies with smaller than 0.1 dimensions, so your dimension of 0,0,0 will definitely not work.
I use only physics shapes created with phygen, it makes life much easier as then I can control their mass and other settings from the properties dialog.