Jump to content

Blogs

Adding LOD to the Model Class

The Model class is being slightly restructured to add support for built-in LOD without the need for separate entities. Previously, a list of surfaces was included in the Model class itself: class Model { std::vector<shared_ptr<Surface> > surfaces; }; This is being replaced with a new LOD class, which allows multiple lists of surfaces containing less detail to be stored in the same model: class LOD { std::vector<shared_ptr<Surface> > surfaces; }; class Model { std::vector<LOD> lods; }; To iterate through all surfaces in the first LOD, you do this: for (int i = 0; i < model->lods[0].surfaces.size(); ++i) { auto surf = lods[0].surfaces[i]; } To iterate through all LODs and all surfaces, you do this: for (int n = 0; n < model->lods.size(); ++n) { for (int i = 0; i < model->lods[n].surfaces.size(); ++i) { auto surf = lods[n].surfaces[i]; } } In the future editor, I plan to add a feature to automatically reduce the detail of a mesh, adding the simplified mesh as an additional LOD level so you can automatically generate these. How this will work with our super-efficient batching system, I am not sure of yet.

Josh

Josh

Bladequest – The First Chapter Conclusion

Hi guys, First of all check out the newest episode of DevTalk, showing some progress of the development of Bladequest: Chapter Two! Bladequest – The First Chapter is available since about one and a half month now and so far and has totally exceeded my expectations with about 2000 downloads in total. It was a very interesting project for me, and I got a lot of positive feedback and you definitely want to see more from Bladequest. I think the foundation is there, to create a really cool game. The First Chapter can be considered as finished now. As far as no major error/bug appears it will not recieve any updates and I will focus on Chapter Two, to be able to deliver much better quality and more content, as seen in The First Chapter. I recognized that the idea behind Bladequest does not get 100% clear when reading the description, or playing the game. It can easily be misunderstood as an episodic game, were in fact it is not. I definitely plan to work on this in the future and also have a cool idea how to very easily show what I have in mind with Bladequest. I am also very exciting to tell you more about the final game concept, as The First Chapter really just is a sneak peek (like a pre-alpha) of what is to come. So to be able to leave Bladequest – The First Chapter with a clear conscience, I gave the website some final touches and released Patch 1.5.0, so I can now focus on Chapter Two. The last exciting thing happening with The First Chapter is the upcoming Steam release. I am really looking forward to this and can’t wait to see how it is going. Thanks for all your support and feedback so far. I am so excited to create Chapter Two you won’t believe it :D, just have to overcome my currently bad health situation :(, to be able to work 24/7 again haha :D. Markus from Phodex Games! Give Feeback for Bladequest!
My Youtube Channel!
Your Games Wishlist so I can craft a game to your needs!

Phodex Games

Phodex Games

The project Falling in Love with Leadwerks engine

I always stress that I am not a programmer, that I use tools that make me believe that I am a programmer is something else, but Leadwerks is wonderful, everything is very easy when you understand the concept of design and development of prototypes in the engine. Something I could never assimilate with video game engines like Torque, Unity, Cry Engine, Neoaxis and UDK, all of them, a pain in the *** at the right time, documentation in English, heavy engines for my hardware power. Anyway, but as I'm a user of the old Blitz3D and BlitzMax, when you switch to leadwerks, you see that productivity is greatly accelerated, you don't worry about shadows, or graphic effects, everything is done, so the most difficult thing is already built and only the rest remains, which in some ways is also very difficult, make a video game, but work that is facilitated with tools like Leadwerks engine.  Now, what to do, the knowledge acquired continues to arrive, always something to learn, and to date very excited with the vehicle system that is done in Leadwerks 4.5 or higher through the sliding joints, balls and hinges.  To date the project was to create a video game, however this has been canceled, because I'm busy learning and understanding certain concepts that come up along the way, and with the wheels done, I have a vague, but very deep idea of how to create the forklift mechanism for handling boxes, However, as the holidays are over, I have to go back to my studies and this is a secondary task, but I am always grateful to those who teach me something, and possibly one day I will make a video game but it will not be at this moment, I will continue to learn, in the end the hobby is that a crossword puzzle to solve problems again and agai Translated with www.DeepL.com/Translator


Yue

Yue

Umbra Sucks. Check out our Easy No-Bake Occlusion Culling

With the help of @martyj I was able to test out occlusion culling in the new engine. This was a great chance to revisit an existing feature and see how it can be improved. The first thing I found is that determining visibility based on whether a single pixel is visible isn't necessarily a good idea. If small cracks are present in the scene one single pixel peeking through can cause a lot of unnecessary drawing without improving the visual quality. I changed the occlusion culling more to record the number of pixels drawn, instead just using a yes/no boolean value: glBeginQuery(GL_SAMPLES_PASSED, glquery); In OpenGL 4.3, a less accurate but faster GL_ANY_SAMPLES_PASSED_CONSERVATIVE (i.e. it might produce false positives) option was added, but this is a step in the wrong direction, in my opinion. Because our new clustered forward renderer uses a depth pre-pass I was able to implement a wireframe rendering more that works with occlusion culling. Depth data is rendered in the prepass, and the a color wireframe is drawn on top. This allowed me to easily view the occlusion culling results and fine-tune the algorithm to make it perfect. Here are the results: As you can see, we have pixel-perfect occlusion culling that is completely dynamic and basically zero-cost, because the entire process is performed on the GPU. Awesome!

Josh

Josh

Constanta entry

Entry for tournament is on 😎 Check game information on link below and tell me this is not an odd game haha. I had  a limited amount of time for this because i go in holiday.Now its done was pretty painful even if i kept things simple , especially the debugging. Has multiplayer , and one way to capture territories. I will continue with this after tournament.   Future plans: Ai clients.
Adding more ways to capture territories. Alerts to players so they know they losing teritories.
Host a single master server for everyone to play.
Add end game and reset server data or increase the worlds count , ive not decided yet. Code cleanup     Cheers

aiaf

aiaf

Workshop car for LE4.5 - ready to drive

I worked today on publishing a version of the drivable car workshop item for Leadwerks 4.5 https://steamcommunity.com/sharedfiles/filedetails/?id=1440937059 free to use, works with the FPS player controller. Here is a demo:   enjoy!  

Marcousik

Marcousik

Accidental Masterpieces

Lighting is nearly complete. and it is ridiculously fast! There are still some visual glitches to work out, mostly with lights intersecting the camera near plane, but it's nearly perfect. I turned the voxel tree back on to see what the speed was, and to check if it was still working, and I saw this image of the level partially voxelized. The direct lighting shader I am using in the rest of the scene will be used to calculate lighting for each voxel on the GPU, and then bounces will be performed to quickly calculate approximate global illumination. This is fun stuff!

Josh

Josh

Introducing new and awesome features!

Check out my latest DevTalk video. I am showing some awesome new features coming to Bladquest – Chapter Two! I really took your feedback serious to develop some cool stuff. So check it out! Give Feeback for Bladequest!
My Youtube Channel!
Your Games Wishlist so I can craft a game to your needs!

Smoothed car drive - Leadwerks 4.5

I'm just happy to get this work  here is a demo: This is actually better than driving in 4.3 because cars are now  able to jump or crash without experimenting crazy rotations or whatever  👍     Here is the script to make this:   > Here the values I used:       > And here what changed: Is written in dark: ------------------------------------- function Script:Start() -- [...........] -- Construit les amortisseurs: / suspensions
local n
local pos
    for n=0,3 do
        pos=self.entity:GetPosition(true)
        self.Axes[n]:SetMass(self.TireMass)
        self.Amortisseurs[n]=Joint:Slider(pos.x, pos.y, pos.z, 0,1,0, self.Axes[n], self.entity)         self.Amortisseurs[n]:EnableLimits()
        self.Amortisseurs[n]:SetLimits(-0.25/2,0.25/2)         self.Amortisseurs[n]:SetTargetAngle(-self.Amort)    --at the middle if 0
        self.Amortisseurs[n]:SetMotorSpeed(10000)    ------------- vitesse de la pompe/ suspensions speed
        self.Amortisseurs[n]:SetStrength(self.Force)    --defatul is 1000
        self.Amortisseurs[n]:EnableMotor()    

    end -- [...........]        -----  I removed the backward suspensions with 2* forces because this only depends on the positions of the suspensions on the chassis. ----- Making them symmetrical is ok to solve this.   ----------------------------------------
function Script:UpdatePhysics()
if self.MyCar==1 and InCar>0 then     
-- Traite la direction:    
local turning=0
    local direction=self.Volants[0]:GetAngle()     if window:KeyDown(Key.Left) then
        direction=direction-5 turning=-1
    elseif window:KeyDown(Key.Right) then
        direction=direction+5 turning=1
    elseif window:KeyDown(Key.Left)==false and window:KeyDown(Key.Right)== false then 
        if Math:Round(direction)>0 then direction=direction-5
        elseif Math:Round(direction)<0 then direction=direction+5
        end
    end
    self.Volants[0]:SetAngle(direction)
    self.Volants[1]:SetAngle(direction) -- Traite l'acceleration: local Gas=0
        if window:KeyDown(Key.Up) then
            Gas=1
            self.currspeed = self.currspeed + 10
            if self.currspeed>self.SpeedMax then
                self.currspeed=self.SpeedMax
            end
        
        elseif window:KeyDown(Key.Down) then
            Gas=-1
            self.currspeed = self.currspeed - 10
            if self.currspeed<-self.SpeedMax then
                self.currspeed=-self.SpeedMax
            end
        end         if Gas==0 then  self.currspeed=0
            for n=0,3 do
            self.Rouages[n]:DisableMotor()
            end
        else
            for n=0,3 do
            if self.Rouages[n]:MotorEnabled()==false then self.Rouages[n]:EnableMotor() end
            self.Rouages[n]:SetTargetAngle(self.Rouages[n]:GetAngle()+1000)             self.Rouages[n]:SetMotorSpeed(self.currspeed)
            self.Tires[n]:SetOmega(self.Tires[n]:GetOmega()*Vec3(5,5,5))   ---------  make the car go faster
            end
        end --Smoothing: if turning==0 then
    self.entity:SetOmega(self.entity:GetOmega()*Vec3(-1,-1,-1))
else self.entity:SetOmega(0,turning*Gas,0) end     self.Axes[0]:SetOmega(self.Axes[0]:GetOmega()*Vec3(-1,-1,-1))
    self.Axes[1]:SetOmega(self.Axes[1]:GetOmega()*Vec3(-1,-1,-1))
    self.Axes[2]:SetOmega(self.Axes[2]:GetOmega()*Vec3(-1,-1,-1))
    self.Axes[3]:SetOmega(self.Axes[3]:GetOmega()*Vec3(-1,-1,-1))     self.Axes[0]:SetVelocity(self.Axes[0]:GetVelocity()*Vec3(1,0.5,1))
    self.Axes[1]:SetVelocity(self.Axes[1]:GetVelocity()*Vec3(1,0.5,1))
    self.Axes[2]:SetVelocity(self.Axes[2]:GetVelocity()*Vec3(1,0.5,1))
    self.Axes[3]:SetVelocity(self.Axes[3]:GetVelocity()*Vec3(1,0.5,1))
-- fake wheels update:
    
        self.Wheels[0]:SetMatrix(self.Tires[0]:GetMatrix())
        self.Wheels[1]:SetMatrix(self.Tires[1]:GetMatrix())
        self.Wheels[2]:SetMatrix(self.Tires[2]:GetMatrix())
        self.Wheels[3]:SetMatrix(self.Tires[3]:GetMatrix())         self.Wheels[0]:SetPosition(self.PosWheels[0]+Vec3(0,self.Amortisseurs[0]:GetAngle()/6,0))
        self.Wheels[1]:SetPosition(self.PosWheels[1]+Vec3(0,self.Amortisseurs[1]:GetAngle()/6,0))
        self.Wheels[2]:SetPosition(self.PosWheels[2]+Vec3(0,self.Amortisseurs[2]:GetAngle()/6,0))
        self.Wheels[3]:SetPosition(self.PosWheels[3]+Vec3(0,self.Amortisseurs[3]:GetAngle()/6,0))
end  

Marcousik

Marcousik

Map Viewer available to subscribers

A map viewer application is now available for beta subscribers. This program will load any Leadwerks map and let you fly around in it, so you can see the performance difference the new renderer makes. I will be curious to hear what kind of results you see with this: Program is not tested with all hardware yet, and functionality is limited.

Josh

Josh

View Your Sales in Leadwerks Marketplace

You can now view detailed sales records of your game assets in Leadwerks Marketplace. First, log into your Leadwerks account and navigate to the Leadwerks Marketplace main page. In the bottom-right, below the categories, a link to your paid files will appear. Here you can see a list of all your paid items: When you click on an item, you can see a list of people who have purchased it, along with sales dates. If you wish to give a free license to any member for any reason, you can do so by clicking the "Generate Purchase" button. A window will pop up where you can type in the member's name and add the item to their account for free. These tools give you more control over your game assets and better information on sales.

Josh

Josh

Map Loading, Materials, Shaders, and other Details

I have map loading working now. The LoadMap() function has three overloads you can use:: shared_ptr<Map> LoadMap(shared_ptr<World> world, const std::string filename); shared_ptr<Map> LoadMap(shared_ptr<World> world, const std::wstring filename); shared_ptr<Map> LoadMap(shared_ptr<World> world, shared_ptr<Stream> stream); Instead of returning a boolean to indicate success or failure, the LoadMap() function returns a Map object. The Map object gives you a handle to hang onto all the loaded entities so they don't get instantly deleted. When you want to clear the map, you can just set this variable to nullptr/NULL: auto map = LoadMap(world,"Maps/start.map"); map = nullptr; //BOOM!!! The "entities" member of the map object gives you a list of all entities loaded in the map: auto map = LoadMap(world,"Maps/start.map"); for (auto entity : map->entities) { //do something to entity } If you want to clear a map but retain one of the loaded entities, you just set it to a new variable like this. Notice we grab the camera, clear the map, but we still can use the camera: auto map = LoadMap(world,"Maps/start.map"); shared_ptr<Camera> cam; for (auto entity : map->entities) { cam = dynamic_pointer_cast<Camera>(entity); if (cam) break; } map = nullptr; //BOOM!!! cam->SetPosition(1,2,3); //everything is fine Materials and shader assignment has gotten simpler. If no material is assigned, a blank one will be auto-generated in the rendering thread. If a material has no shader assigned, the rendering thread will choose one automatically based on what textures are present. For example, if texture slots one and two are filled then the rendering thread will choose a shader with diffuse and normal maps. In most cases, you don't even need to bother assigning a shader to materials. I might even add separate animation and static shader slots, in which case materials could work for animated or non-animated models, and you wouldn't normally even need to specify the shader. Shaders now support include directives. By using a pragma statement we can indicate to the engine which file to load in, and the syntax won't trigger an error in Visual Studio Code's syntax highlighter: #pragma include Lighting.glsl Shader includes allow us to create many different shaders, while only storing the complicated lighting code in one file that all other shaders include. The #line directive is automatically inserted into the shader source at every line, so that the engine can correctly detect which file and line number any errors originated from. With this all working, I can now load maps side by side in Leadwerks 4 and in the new renderer and get actual performance benchmarks. Here's the first one, showing the example map "02-FPS Controller.map" from the First-Person Shooter game template. In Leadwerks 4, with Intel HD 4000 graphics, we get 71 FPS. (Yes, vertical sync is disabled). And with the new forward renderer we get a massive 400%+ increase in performance: I expect the results will vary a little bit across different hardware, but we can see already that on the low-end hardware the new renderer is a massive improvement. I plan to get a new build of the beta up soon so that you can try your own maps out and test the difference. Physics and scripts are presently disabled, as these systems need additional work to be usable. Oh, and look how much cleaner those shadow edges are!

Josh

Josh

Fun driving in Leadwerks 4.5

Little demo I made about driving in Leadwerks 4.5 with "self-made" vehicle (well the model is not from me) How to make ? -> https://www.leadwerks.com/community/blogs/entry/2216-simple-car-improved/  enjoy!    

Marcousik

Marcousik

Simple Car Improved

Now, I wrote a single script that creates suspension, steer and traction You have to create the chassis, 4 wheels, set this script to each one of the wheels and then paly with the configurable parameters. Enjoy: --[[ Autor Juan Ignacio Odriozola (charrua) Purpose: A script that facilitates the making of a simple car all you need is a chassis and 4 wheels assing this scrip to each wheel and set the object chassis then adjust some of the configurable parameters Parent: chassis entity : wheel 3 joints and 2 auxiliary entities are created the chain is: Parent Slider Pivot Hinge Pivot Hinge chassis -suspensionJoint- suspensionPivot -steerJoint- steerPivot -wheelJoint- wheel suspension uses pin 010 (Y axis) steer uses pin 010 (Y axis) wheel pin (must be set depends of wheel orientation) up/down keys are defaults for forward and backward left/right keys are defaults for steer left/right space key is default for brakes steer velocity and start/end angle must be set suspension lenght must be set wheel friction must be set steerAngle set both limits to +/- steerAngle/2 if no key (left/right) is pressed then, target angle is 0 : straight suspensionLenght set both limits to +/- suspensionLength/2 and target distance is set to 0 suspension strength defaults to 1000 which is too much strenght for a light weight car (20 of mass) and not to much for a 200 car of mass each joint is created with a mass of 1, which should be taking into accoung (so for a 4 wheels car, you have a mass of 8 on the 8 joints). there are so many other parameters that may be adjusted: Spring, Strength, Stiffness ... not too much documented :) ]]-- Script.currspeed = 0 Script.chassis = nil--Entity "chassis" Script.pin = Vec3(0,0,1) --Vec3 "wheel Pin" Script.motorspeed=500--float "max motor speed" Script.velcontrolled=false--bool "velControl" Script.suspensionLength=0.2--float "suspension" Script.steerAngle=90--float "steer angle" Script.steerSpeed=100--float "steer velocity" Script.friction=1--float "wheel friction" Script.steerPivot=nil Script.suspensionPivot=nil Script.steerJoint=nil Script.suspensionJoint=nil Script.wheelJoint=nil function Script:Start() local pos = self.entity:GetPosition(false) --true for global if self.chassis ~= nil then self.suspensionPivot = Pivot:Create() self.suspensionPivot:SetPosition(pos) self.suspensionPivot:SetMass(1) self.suspensionPivot:SetCollisionType(Collision.None) self.steerPivot = Pivot:Create() self.steerPivot:SetPosition(pos) self.steerPivot:SetMass(1) self.steerPivot:SetCollisionType(Collision.None) --joints creation self.suspensionJoint = Joint:Slider(pos.x, pos.y, pos.z, 0, 1, 0, self.chassis, self.suspensionPivot) self.steerJoint = Joint:Hinge(pos.x, pos.y, pos.z, 0, -1, 0, self.suspensionPivot, self.steerPivot) self.wheelJoint = Joint:Hinge(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.steerPivot, self.entity) --suspension self.suspensionJoint:EnableLimits() self.suspensionJoint:SetLimits(-self.suspensionLength/2,self.suspensionLength/2) --steerAngle=0 means no steer self.suspensionJoint:SetTargetAngle(0) --at the middle self.suspensionJoint:SetMotorSpeed(1) -- 1 m/s self.suspensionJoint:SetStrength(100) --defatul is 1000 self.suspensionJoint:EnableMotor() --steer self.steerJoint:EnableLimits() self.steerJoint:SetLimits(-self.steerAngle/2,self.steerAngle/2) --steerAngle=0 means no steer self.steerJoint:SetMotorSpeed(self.steerSpeed) self.steerJoint:EnableMotor() --wheel self.entity:SetFriction(self.friction, self.friction) else Debug:Error("no chassis assigned") end end function Script:setMotorSpeed(speed) if self.velcontrolled then --System:Print("setMotorSpeed: "..speed) self.currspeed = speed if speed~=0 then self.wheelJoint:EnableMotor() end self.wheelJoint:SetMotorSpeed(self.currspeed) end end function Script:UpdateWorld() if self.motorspeed>0 then self.wheelJoint:SetAngle(self.wheelJoint:GetAngle()+100) else self.wheelJoint:SetAngle(self.wheelJoint:GetAngle()-100) end if App.window:KeyDown(Key.Space) then self:setMotorSpeed(0) end if self.velcontrolled then if App.window:KeyDown(Key.Up) then self.currspeed = self.currspeed + 10 if self.currspeed>self.motorspeed then self.currspeed=self.motorspeed end if self.currspeed == 10 then self.wheelJoint:EnableMotor() end self.wheelJoint:SetMotorSpeed(self.currspeed) end if App.window:KeyDown(Key.Down) then self.currspeed = self.currspeed - 10 if self.currspeed<-self.motorspeed then self.currspeed=-self.motorspeed end self.wheelJoint:SetMotorSpeed(self.currspeed) end end if self.steerAngle>0 then local direction=0 if App.window:KeyDown(Key.Left) then direction=-self.steerAngle/2 end if App.window:KeyDown(Key.Right) then direction=self.steerAngle/2 end self.steerJoint:SetAngle(direction) else self.steerJoint:SetAngle(0) end end   In the other maps i was using a box as a floor to which I set the desired friction, testing this new script i use a terrain and have to figure it out how to set the friction to the terrain... Did some searches and ended with: local n for n=0,self.world:CountEntities()-1 do local entity = self.world:GetEntity(n) if entity:GetClassName()=="Terrain" then terrain = entity System:Print("terrain found!") terrain:SetFriction(10,10) break end end insert this in the app.lua (after load map) and then you can play with terrain friction, the video shows how the car behaves with the defaul terrain friction and then whit a friction of 10,10 Always learning something new    A word about some parameters: If you are using a hinge, when you specity speed (SetMotorSpeed) the number means degrees per second. So if you use 3600 as max speed you get 10 revoluions per second. If your tire has, 64cm then d*pi aprox 2 meters per revolution, 10 revolutions per secon aprox 20 meters per second... and if you are lucky 72Km/h If you are using a slider, then speed is un meters per second.  Other parameter which is very important is the hinge/slider "pin" which is a vector that tells the direction of movement of the slider or over which plane de hinges open/close For a common door, we need to use the Y axis, so the pin is 0,1,0 I use this pin for the suspension and for the steer but for this script, you must tell the traction pin, which sould be 1,0,0 or 0,0,1 depending on the orientation of your tires If your tires are not facing X nor Z axis, then you have to do some math to get the proper x,z component of the pin In the script I use a Strenght of 100, instead of the 1000 which is default, my car is light weight : 5 + 4*3 = 17 of Mass chassis has 5, each wheel has 1 and the 2 auxiliary pivots has 1 each one whith a friction of 10 on each tire and with a friction of 10 on the terrain looks ok for me (better than I spected at first).  Juan

Charrua

Charrua

On how to loose half day

I had a window popping up every time i was closing the game.Error below: Debug Assertion Failed! Expression: __acrt_first_block == header At first i thought is something related to me not deleting all pointers or closing the app the wrong way.So i fix that up same error.
More investigating i figure it up that somehow is related to poco libs that i use to connect over tcp.If game exit code was before calling poco there was no exception. More wtf and curses for not being able to work on game and debug this. Finally solution was to rebuild poco with /MTd option, default built was with /MD and was causing incompatibilities seems. Glad i got over this , back to entry development

aiaf

aiaf

Joints

Recently i posted a simple car made with joints without too much explanations... so What is a joint? This video shows joints in action. At the end, the stand alone executable and the complete project.   The following text and figure is from the "ode-latest-userguide", figures are also form the JV-ODE documentation: In real life a joint is something like a hinge, that is used to connect two objects. It is a relationship that is enforced between two bodies so that they can only have certain positions and orientations relative to each other. This relationship is called a constraint,  the words joint and constraint are often used interchangeably. The figure shows three different constraint types. The first is a ball and socket joint that constraints the “ball” of one body to be in the same location as the “socket” of another body.  The second is a hinge joint that constraints the two parts of the hinge to be in the same location and to line up along the hinge axle.  The third is a slider joint that constraints the “piston” and “socket” to line up, and additionally constraints the two bodies to have the same orientation. Each time the integrator takes a step all the joints are allowed to apply constraint forces to the bodies they affect. These forces are calculated such that the bodies move in such a way to preserve all the joint relationships. Each joint has a number of parameters controlling its geometry. An example is the position of the balland- socket point for a ball-and-socket joint. The functions to set joint parameters all take global coordinates, not body-relative coordinates. A consequence of this is that the rigid bodies that a joint connects must be positioned correctly before the joint is attached. Figure: types of joints   The "Integrator step" is the part of the physics engine that does all the calculations.
Based on the current state, force applied, constrain parameters, collisions etc... recalculates the next position and rotation of every affected physical obejct.
Leadwerks then, does the render of the objects acordingly to it's new positions, or that is what is supposed to do... (Josh should correct me if I'm wrong). A joint normally is placed between two objects, one is called Parent and the other Child. The child should be NULL, and in this case
the joint is between one body and the world or scene. In the case of a door, you need a Door and a Frame, the Frame should be the Parent body, the Door the child body.
In real life you have to decide where the Hinge (or more than one) will be placed and use some screws to attach both parts of the hinge to the frame and the door. In software, things are practically the same In other words, we have to have 3 things clear:
    Who is the parent and where it should be positioned and oriented.
    Who is the child and where it should be poitioned and oriented.
    Which type of joint you need, where it should be positioned and oriented. Normally we create and place the two bodies first and then, at joint creation we say where the joint will be and how it should be oriented, who the parent is and who child is, if any. After that, joints normally has some other properties that should be adjusted, used, controlled, limited, enabled... etc, depending on the joint type. Joints have two "limits": If the joint is a Hinge, the limits are the Start Angle and End Angle "the door should turn".
If the joint is a Slider, the limits are the Start Position and End Position the piston should extend.
If the joint is a Ball, the limits are the cone angle and twist or torsion... keep reading Joints (hinge and slider) should have a "motor" if not, as a normal door, we need external forces to "open the door", if we place a door on a frame attached with hinges and the door has no lock at all, then
the wind should open/close it, or some body that collides with the door should move it. As we use a hinge, the door do not fall, do not take an upward motion, the motion is well known and 
constrainded tho the clasic movement we all know.
But if, for instance we have a "motorized door" then the open/close operation is started in some way (press of a button?) and a motor does the job. Normally it stops automatically, because there are end-run switches or the like installed and working for us.
A sofware motorized joint is exactly that, we set where we want the joint go (setTargetAngle), and start a motor (enableMotor). Ball Joint A ball is used when we need a "cone" movement freedom, think that you have a rope attached at the roof of your room and you hang a box on it.
If the rope is made of a rigid material, the box should made a pendulum movement not so large and probably the box orientations should not change too much.
How much we let the rope to move is dictated by the first limit and how much the object attached should change orientation (twist/torsion) is dictated by the second limit. A rope is a nice looking example, all you have to do is place N cubes (shape is not important) and place ball joints in the middle of each pair.
You may have the first box joined to the world (attached to a fixed 3d position) and then a link of bodies and ball joints:
    Joint N has body N as parent and body N+1 as child Leadwerks came with a simple ball.lua script: function Script:Start()     local pos = self.entity:GetPosition(true)     self.joint = Joint:Ball(pos.x, pos.y, pos.z, self.entity, self.entity:GetParent())     self.joint:SetFriction(10)     self.entity:SetDamping(0,0) end If you have a chain of parented objetcts, then you  may set this script and you have a rope build with a few clicks of your mouse on the editor.
Procedure:
    Create some boxes, set prop collision and a mass not zero (1 perhaps), place then in a vertical row somewhat separated.
    In the editor drag the second box to the first, the third to the second building a hierachy (parent/child relationship)
    Select all (one by one with ctrl click on each box) and then apply the ball script. Voila! You have a rope with no limits: cone angle is the maximum the engine lets you to be and the same for torsion.
    Collide the rope with some object or, place the boxes horizontally (instead of vetically) and let gravity do it's job.
    
I made another ball script: ballEnhaced: Script.parent = nil--Entity "Parent" Script.child = nil--Entity "Child" Script.useLimits=false--bool "Use limits" Script.coneAngle = 45--Float "Cone Angle" Script.torsion = 45--Float "Torsion" Script.hide = true--bool "Hide entity" function Script:Start()     local pos = self.entity:GetPosition(true)     if self.parent~=nil then         self.joint = Joint:Ball(pos.x, pos.y, pos.z, self.parent, self.child)         self.joint:SetLimits(self.coneAngle, self.torsion)         if self.useLimits then             self.joint:EnableLimits()             System:Print("limits:"..self.coneAngle..", "..self.torsion)         end         if self.hide then             self.entity:Hide()         end     end end if using this script, you have to create a pivot or box (collision type: none, and no mass) and tell the script ho the parent is and ho the child is, if no child, then the parent body
will be attached to the environement, fixed at this 3d point. In the map included in this blog there are two ropes, one made with the leadwerks ball.lua and one with the ballEnhaced.lua script, in this script you may tell how to constrain 
the ball cone anlgle and trosion. Look the video, and you will see the difference on how the cubes behave when hitted by the car. A rope suspension bridge should be made with both ends attached to the world and a double chain of joints... doing two unions between each part of the brige.
It's nice so see the car passing over it! The attached video shows at first the car passing over the bridge... the mass of the car is very little, if not, the joints get broken.. as always there are some other things to consider. Hinje Joint
As I used a hinge for some explanation, i guess there is not to much to say here, I use some hinges for doors in the map attached and also used them for the steer and wheels of the car.
One door have a motor and the other not, so the second one moves as the car collides it.  I wrote two scripts: hingeEnhaced.lua Script.parent = nil --entity "parent" Script.child = nil --entity "hild" Script.hide = true--bool "Hide entity" Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin" Script.limitsenabled=false--bool "Enable limits" Script.limits = Vec2(-45,45) --Vec2 "Limits" Script.friction = 0--float "Friction" function Script:Start()     local pos = self.entity:GetPosition(true)     if self.parent~=nil then         self.joint = Joint:Hinge(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.parent, self.child)         if self.limitsenabled then self.joint:EnableLimits() end         self.joint:SetLimits(self.limits.x,self.limits.y)         self.joint:SetFriction(self.friction)         self.entity:SetDamping(0,0)         if self.hide then             self.entity:Hide()         end     end end As in the case of a ball joint, with this script you may set parent, child and limits hingeMotorized.lua Script.parent = nil --entity "parent" Script.child = nil --entity "hild" Script.hide = true--bool "Hide entity" Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin" Script.limitsenabled=false--bool "Enable limits" Script.limits = Vec2(-45,45) --Vec2 "Limits" Script.tOpenClose = 15 --Int "Open/Close time" Script.movespeed = 60 --Int "Speed" Script.startTime = 0 Script.action = 1    --1 open, 0 close function Script:Start()     local pos = self.entity:GetPosition(true)     if self.parent~=nil then         self.joint = Joint:Hinge(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.parent, self.child)         if self.limitsenabled then self.joint:EnableLimits() end         self.joint:SetLimits(self.limits.x,self.limits.y)         self.joint:SetTargetAngle(self.limits.x)         self.joint:EnableMotor()         self.startTime = Time:GetCurrent()         self.joint:SetMotorSpeed(self.movespeed)         if self.hide then             self.entity:Hide()         end     end end function Script:UpdatePhysics()     local time_ = Time:GetCurrent()     if time_ - self.startTime > self.tOpenClose*1000 then                  self.action = 1-self.action    --toggle action         if self.action == 1 then             self.joint:SetTargetAngle(self.limits.x)         else             self.joint:SetTargetAngle(self.limits.y)         end         self.startTime = Time:GetCurrent()     end end This scripts creates the joint, then set a target angle, enables the motor and apply a velocity, so the "door" starts going to the first limit.
After the tOpenClose time, the variable action is toggled and based on it the TargetAngle will be first limit or second limit, in this way, the door continously open and then close
after tOpenClose time
Slider Joint
For a slider joint, in this map i wrote one script: sliderMotorized.lua Script.child = nil --entity "hild" Script.hide = true--bool "Hide entity" Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin" ScrScript.parent = nil --entity "parent" ipt.limitsenabled=false--bool "Enable limits" Script.limits = Vec2(-45,45) --Vec2 "Limits" Script.tOpenClose = 15 --Int "Open/Close time" Script.movespeed = 60 --Int "Speed" Script.startTime = 0 Script.action = 1    --1 open, 0 close function Script:Start()     local pos = self.entity:GetPosition(true)     if self.parent~=nil then         self.joint = Joint:Slider(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.parent, self.child)         if self.limitsenabled then self.joint:EnableLimits() end         self.joint:SetLimits(self.limits.x,self.limits.y)         self.joint:SetTargetAngle(self.limits.x)         self.joint:EnableMotor()         self.startTime = Time:GetCurrent()         self.joint:SetMotorSpeed(self.movespeed)         if self.hide then             self.entity:Hide()         end     end end function Script:UpdatePhysics()     local time_ = Time:GetCurrent()     if time_ - self.startTime > self.tOpenClose*1000 then                  self.action = 1-self.action    --toggle action         if self.action == 1 then             self.joint:SetTargetAngle(self.limits.x)         else             self.joint:SetTargetAngle(self.limits.y)         end         self.startTime = Time:GetCurrent()     end end This script is 99% the same as the hingeMotorized.lua, the only difference is that a slider joint is created instead of a hinge joint.
Note that the limis are not angles, they are offsets from the initial position of the plataform. Stand alone executable: jointsworldDistro.zip Project: jointsworldProject.zip Enjoy Juan

Charrua

Charrua

This is what YOUR feedback reveals!

Hi guys! Just wanted to share the first video of the DevTalk series with you, where I keep you up to date about the development, upcoming features etc. It also is a very cool way to communicate with you, so make sure to subscribe and comment to tell me your ideas. I am working very, very hard and there is a lot of awesome stuff coming soon, so stay tuned! Markus from Phodex Games! Give Feeback for Bladequest!
My Youtube Channel!
Your Games Wishlist so I can craft a game to your needs!

Simple Car

Here there is a way of making a simple car based on hinges This is not a tutorial, is just simply a stating point for the ones that want/like to play arround physics and hinges... I included the entire project and the distribution executable to test the scripts so, you have as I say a starting point and just that, hpe it helps someone This is the editor view and the initial placement of the parts needed Basically I made 3 scripts physicsProperties.lua wheel.lua steer.lua First you have to create and place the car body or chassis, 4 wheels and 6 auxiliary pivots/ or any brush you like (a cube is fine) for the hinges 4 of the auxiliary entities are for the wheels hinges and 2 for the wheels steer. Place the wheel hinge and steer centered with the wheel. After that you may set some script parameters: Wheel scritp: Basically, the position of the entity script holder is used to create a hinge between the "parent" and the "child" you choose (in the picture above: between the auxiliary entity SteerFL and the WheelFL) If vel control is checked then, a motor is enabled for that hinge and keys Up/Down are used to increase/decrease speed If vel control is not cheched, no motor is enabled and the wheel is free to run Be carefull whit the Hinge Pin, which dictates the axis over which the wheel will rotate, in this case I used X axis, but if you use other pieces direction/alignement you should adjust this values.   Steer script: The steer hinge is used to turn the wheel to handle car heading, so the pin is the Y axis Limits and Motor are needed to control the steer Limits is for how much the steer will turn right/left using the default keys left/right arrow When you press left or ritght key, the right limit will be set as the hinge angle and the hinge will try to reach this angle at the "steer speed", the same, but whit the left limit happen if you press the left key.   physicsProperties just let you adjust the friction of the wheels and or the floor Script.sfrict=0--float "static friction" Script.kfrict=0--float "kinetic friction" function Script:Start() System:Print("phy properties start") self.entity:SetFriction(self.sfrict, self.kfrict) end so simple, and in the editor it looks: Here is a hand drawing of how scripts, objects, parent/child are connected       Here is the wheel script Script.currspeed = 0 Script.parent = nil--Entity "Parent" Script.child = nil--Entity "Child" Script.pin = Vec3(0,0,1) --Vec3 "Hinge Pin" Script.motorspeed=500--float "Motor speed" Script.velcontrolled=false--bool "velControl" function Script:Start() System:Print("wheel start") self.entity:Hide() local pos = self.entity:GetPosition(false) --true for global if self.child ~= nil then if self.parent ~= nil then self.joint = Joint:Hinge(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.child, self.parent) else Debug:Error("no parent assigned") end else Debug:Error("no child assigned") end end function Script:setMotorSpeed(speed) if self.velcontrolled then System:Print("setMotorSpeed: "..speed) self.currspeed = speed if speed~=0 then self.joint:EnableMotor() end self.joint:SetMotorSpeed(self.currspeed) end end function Script:UpdateWorld() if self.motorspeed>0 then self.joint:SetAngle(self.joint:GetAngle()+100) else self.joint:SetAngle(self.joint:GetAngle()-100) end if App.window:KeyDown(Key.Space) then self:setMotorSpeed(0) end if self.velcontrolled then if App.window:KeyDown(Key.Up) then self.currspeed = self.currspeed + 10 if self.currspeed>self.motorspeed then self.currspeed=self.motorspeed end if self.currspeed == 10 then self.joint:EnableMotor() end self.joint:SetMotorSpeed(self.currspeed) end if App.window:KeyDown(Key.Down) then self.currspeed = self.currspeed - 10 if self.currspeed<-self.motorspeed then self.currspeed=-self.motorspeed end self.joint:SetMotorSpeed(self.currspeed) end end end Here is the steer scritp Script.parent = nil--Entity "Parent" Script.child = nil--Entity "Child" Script.pin = Vec3(0,1,0) --Vec3 "Hinge Pin" Script.useLimits=false--bool "use limits" Script.limits = Vec2(-45,45) --Vec2 "Limits" Script.useMotor=flase--bool "use motor" Script.motorspeed=50--float "Steer speed" function Script:Start() System:Print("steer start") if self.child == nil then Debug:Error("No child assigned.") end if self.parent == nil then Debug:Error("No parent assigned.") end self.entity:Hide() local pos = self.entity:GetPosition() self.joint = Joint:Hinge(pos.x, pos.y, pos.z, self.pin.x, self.pin.y, self.pin.z, self.child, self.parent) if self.useLimits then self.joint:EnableLimits() self.joint:SetLimits(self.limits.x,self.limits.y) end if self.useMotor then self.joint:SetMotorSpeed(self.motorspeed) self.joint:EnableMotor() end end function Script:UpdateWorld() local direction=0 if App.window:KeyDown(Key.Left) then direction=self.limits.x end if App.window:KeyDown(Key.Right) then direction=self.limits.y end self.joint:SetAngle(direction) end   here the distro: simpleCarDistro.zip here the project: simpleCar.zip and here a video...   enjoy   Juan

Charrua

Charrua

Clustered Forward Rendering - Fun with Light Types

By modifying the spotlight cone attenuation equation I created an area light, with shadow. And here is a working box light The difference here is the box light uses orthographic projection and doesn't have any fading on the edges, since these are only meant to shine into windows. If I scale the box light up and place it up in the sky, it kind of looks like a directional light. And it kind of is, expect a directional light would either use 3-4 different box lights set at radiating distances from the camera position (cascaded shadow maps) or maybe something different. We have a system now that can handle a large number of different lights so I can really arrange a bunch of box lights in any way I want to cover the ground and give good usage of the available texels. Here I have created three box lights which are lighting the entire courtyard with good resolution. My idea is to create something like the image on the right. It may not look more efficient, but in reality the majority of pixels in cascaded shadow maps are wasted space because the FOV is typically between 70-90 degrees and the stages have to be square. This would also allow the directional light to act more like a point or spot light. Only areas of the scene that move have to be updated instead of drawing the whole scene three extra times every frame. This would also allow the engine to skip areas that don't have any shadow casters in them, like a big empty terrain (when terrain shadows are disabled at least). Spot, and area lights are just the same basic formula of a 2D shadowmap rendered from a point in space with some direction. I am trying to make a generic texture coordinate calculation by multiplying the global pixel position by the shadow map projection matrix times the inverse light matrix, but so far everything I have tried is failing. If I can get that working, then the light calculation in the shader will only have two possible light types, one for pointlights which use a cube shadowmap lookup, and another branch for lights that use a 2D shadowmap.

Josh

Josh

How to Request a Payout from Leadwerks Marketplace

Some of you are earning money selling your game assets in Leadwerks Marketplace. This quick article will show you how to request a payout from the store for money you have earned. First, you need to be signed into your Leadwerks account. Click the drop-down user menu in the upper right corner of the website header and click on the link that says "Account Balance". On the next page you can see your account balance. As long as it is $20 or more you can withdraw the balance into your PayPal account by hitting the "Withdraw Funds" button. Now just enter your PayPal email address and press the "Withdraw" button. After that the withdrawal will be deducted from your balance and the withdrawal request will show in your account history. Shortly after that you will receive the funds in your PayPal account. You can sell your game assets in Leadwerks Marketplace and earn a 70% commission on each transaction.

Josh

Josh

Clustered Forward Rendering - Multiple Light Types

I added spotlights to the forward clustered renderer. It's nothing too special, but it does demonstrate multiple light types working within a single pass. I've got all the cluster data and the light index list packed into one texture buffer now. GPU data needs to be aligned to 16 bytes because everything is built around vec4 data. Consequently, some of the code that handles this stuff is really complicated. Here's a sample of some of the code that packs all this data into an array. for (auto it = occupiedcells.begin(); it != occupiedcells.end(); it++) { pos = it->first; visibilityset->lightgrid[pos.z + pos.y * visibilityset->lightgridsize.x + pos.x * visibilityset->lightgridsize.y * visibilityset->lightgridsize.x] = visibilityset->lightgrid.size() / 4 + 1; Assert((visibilityset->lightgrid.size() % 4) == 0); for (int n = 0; n < 4; ++n) { visibilityset->lightgrid.push_back(it->second.lights[n].size()); } for (int n = 0; n < 4; ++n) { if (!it->second.lights[n].empty()) { visibilityset->lightgrid.insert(visibilityset->lightgrid.end(), it->second.lights[n].begin(), it->second.lights[n].end()); //Add padding to make data aligned to 16 bytes int remainder = 4 - (it->second.lights[n].size() % 4); for (int i = 0; i < remainder; ++i) { visibilityset->lightgrid.push_back(0); } Assert((visibilityset->lightgrid.size() % 4) == 0); } } } And the shader is just as tricky: //------------------------------------------------------------------------------------------ // Point Lights //------------------------------------------------------------------------------------------ countlights = lightcount[0]; int lightgroups = countlights / 4; if (lightgroups * 4 < countlights) lightgroups++; int renderedlights = 0; for (n = 0; n < lightgroups; ++n) { lightindices = texelFetch(texture11, lightlistpos + n); for (i = 0; i < 4; ++i) { if (renderedlights == countlights) break; renderedlights++; lightindex = lightindices[n]; ... I plan to add boxlights next. These use orthographic projection (unlike spotlights, which us perspective) and they have a boundary defined by a bounding box, with no edge softening. They have one purpose, and one purpose only. You can place them over windows for indoor scenes, so you can have light coming in a straight line, without using an expensive directional light. (The developer who made the screenshot below used spotlights, which is why the sunlight is spreading out slightly.) I am considering doing away with cascaded shadow maps entirely and using an array of box lights that automatically rearrange around the camera, or a combination of static and per-object shadows. I hope to find another breakthrough with the directional lights and do something really special. For some reason I keep thinking about the outdoor scenery in the game RAGE and while I don't think id's M-M-MEGATEXTURES!!! are the answer, CSM seem like an incredibly inefficient way to distribute texels and I hope to come up with something better. Other stuff I am considering Colored shadows (that are easy to use). Volumetric lights either using a light mesh, similar to the way lights work in the deferred renderer, or maybe a full-screen post-processing effect that traces a ray out per pixel and calculates lighting at each step. Area lights (easy to add, but there are a lot of possibilities to decide on). These might be totally unnecessary if the GI system is able to do this, so I'm not sure. IES lighting profiles. I really want to find a way to render realistic light refraction, but I can't think of any way to do it other than ray-tracing: It is possible the voxel GI system might be able to handle something of this nature, but I think the resolution will be pretty low. We'll see. So I think what I will do is add the boxlights, shader includes, diffuse and normal maps, bug test everything, make sure map loading works, and then upload a new build so that subscribers can try out their own maps in the beta and see what the speed difference is.

Josh

Josh

×