76
SFML projects / Re: Nero Game Engine
« on: October 14, 2017, 11:10:36 am »
How to use the Engine 03 : Play with Meshes ! | Part 2 : Mesh and Meshed Object Properties !
Hi everyone, how are you doing ! In this second Howto on Meshes we'll talk about some Mesh properties.
Mesh Object and Meshed Object
First of all, I hope that, both words are not confusing you, I don't think that munch before to choose my Classes names, I just took the first ones that come to my mind .
There is a little reminder
Both Objects carry a Mesh and that Mesh can be configured to suit your needs.
On the Left of the Engine, along with the Sprite Tab and Color Tab, you get the Mesh Tab, we gonna play with it. The properties below work the same way on both Objects types, you just have to select them and apply the one you want.
Fixed Rotation
This one is pretty easy, when activated, your Object will never rotate even if it stand on a sloping ground or if it get hit by a projectile.
Is Sensor
This is one of the Coolest feature of Box2D. When talking about Box2D the first thing people see is the "Physics Simulation" Part of the library. But the thing is, if you set all your objects to Sensor mode, you end up with a powerfull "Collision Detection Engine" without any Physic Simulation. This let you free to implement your own Physic Simulation.
Object in Sensor Mode stay affected by Gravity, but that's all, they don't participate to the "Physics Simulation". that's make them great to build your game logic. You can use them to check if your Character has reached a certain area and then trigger a specific event. When i'll build my game prototype, i'll show how you can use Object in sensor mode to do great things.
Allow Sleep
This property is activated by default, and it should stay like that. It will help reduce the computation operated by Box2D.
Density | value : [0 - 100]
What is Density ? in simple words it's a short of relation between an Object Volume and its Weight. For the same volume, the same Object will get a higher weight if its Density get increased. In your game, that will make your objects more stronger.
To check that, create two identical Polygon Meshes, let's call them Left_P and Right_P. Now using the mouse, take Left_P and throw it on Right_P. Right_P will get ejected easly, now increase its density to 100 and throw Left_P on it again, you will see that now Right_P is more resistant or stronger.
Also the Density don't affect the way Gravity affect the Object. Two Ojects with the same volume, and different density (e.g different weight) will be affected the same way by the gravity (in the absence of air resistance to be more accurate). Fo more detail on that go check Newton Laws.
Friction | value : [0 - 10]
What is Friction ? If you don't want your Object to slide on a sloping ground just increase its Friction. If you want your Object to slide on any surface like if it was ice set the Friction to 0. For more technical explication you can Google Friction Force
Internally Box2D use a range value of [0 - 1], In order to avoid using decimal, the Nero Engine use the range value of [0 - 10].
Restitution | value : [0 - 10]
What is Restitution ? Increase Restitution will allow your Object to bounce more easly. For more technical explication you Google Coefficient of restitution
Internally Box2D use a range value of [0 - 1], In order to avoid using decimal, the Nero Engine use the range value of [0 - 10].
Gravity Scale | value : [0 - 10]
If you want to change the way your Objects are affected by gravity, this is the property to configure. Set the value to 0 will allow your Object to float on the air. Increase the value, will make your object fall down more quickly.
The Engine Physics Default settings
When using Box2D the first time, The first thing you notice, is that the physics simulation is slow. According to my experience there are three Settings to configure in order to fix that.
The Nero Engine use a Pixel / Meter Ratio of 30. It means that 30 pixel on your canvas will be equivalent to 1 meter for Box2D. This value is hard coded in the Engine, I may consider make it configurable in the next releases.
The Default Computation Frequency is set to 30 Hertz, you can see it on the Right of the Engine. Fill free to play with this value.
The Engine also use a default Gravity Scale of 3 for all Object. I've tried several values and comes up with this one, it's the most important parameter between the three. the computation Frequency coming in second position.
By adding more and more Dynamic object onto the Canvas, the Physic simulation may become slow, so, remenber to play with those Three parameters in order get the Simulition Speed that suit you.
Hi everyone, how are you doing ! In this second Howto on Meshes we'll talk about some Mesh properties.
Mesh Object and Meshed Object
First of all, I hope that, both words are not confusing you, I don't think that munch before to choose my Classes names, I just took the first ones that come to my mind .
There is a little reminder
- Mesh Object = Mesh
- Meshed Object = Mesh + Sprite
Both Objects carry a Mesh and that Mesh can be configured to suit your needs.
On the Left of the Engine, along with the Sprite Tab and Color Tab, you get the Mesh Tab, we gonna play with it. The properties below work the same way on both Objects types, you just have to select them and apply the one you want.
Fixed Rotation
This one is pretty easy, when activated, your Object will never rotate even if it stand on a sloping ground or if it get hit by a projectile.
Is Sensor
This is one of the Coolest feature of Box2D. When talking about Box2D the first thing people see is the "Physics Simulation" Part of the library. But the thing is, if you set all your objects to Sensor mode, you end up with a powerfull "Collision Detection Engine" without any Physic Simulation. This let you free to implement your own Physic Simulation.
Object in Sensor Mode stay affected by Gravity, but that's all, they don't participate to the "Physics Simulation". that's make them great to build your game logic. You can use them to check if your Character has reached a certain area and then trigger a specific event. When i'll build my game prototype, i'll show how you can use Object in sensor mode to do great things.
Allow Sleep
This property is activated by default, and it should stay like that. It will help reduce the computation operated by Box2D.
Density | value : [0 - 100]
What is Density ? in simple words it's a short of relation between an Object Volume and its Weight. For the same volume, the same Object will get a higher weight if its Density get increased. In your game, that will make your objects more stronger.
To check that, create two identical Polygon Meshes, let's call them Left_P and Right_P. Now using the mouse, take Left_P and throw it on Right_P. Right_P will get ejected easly, now increase its density to 100 and throw Left_P on it again, you will see that now Right_P is more resistant or stronger.
Also the Density don't affect the way Gravity affect the Object. Two Ojects with the same volume, and different density (e.g different weight) will be affected the same way by the gravity (in the absence of air resistance to be more accurate). Fo more detail on that go check Newton Laws.
Friction | value : [0 - 10]
What is Friction ? If you don't want your Object to slide on a sloping ground just increase its Friction. If you want your Object to slide on any surface like if it was ice set the Friction to 0. For more technical explication you can Google Friction Force
Internally Box2D use a range value of [0 - 1], In order to avoid using decimal, the Nero Engine use the range value of [0 - 10].
Restitution | value : [0 - 10]
What is Restitution ? Increase Restitution will allow your Object to bounce more easly. For more technical explication you Google Coefficient of restitution
Internally Box2D use a range value of [0 - 1], In order to avoid using decimal, the Nero Engine use the range value of [0 - 10].
Gravity Scale | value : [0 - 10]
If you want to change the way your Objects are affected by gravity, this is the property to configure. Set the value to 0 will allow your Object to float on the air. Increase the value, will make your object fall down more quickly.
The Engine Physics Default settings
When using Box2D the first time, The first thing you notice, is that the physics simulation is slow. According to my experience there are three Settings to configure in order to fix that.
- The Pixel / Meter Ratio used
- The Box2D World Computation Freqency
- The Box2D Bodies Gravity Scale
The Nero Engine use a Pixel / Meter Ratio of 30. It means that 30 pixel on your canvas will be equivalent to 1 meter for Box2D. This value is hard coded in the Engine, I may consider make it configurable in the next releases.
The Default Computation Frequency is set to 30 Hertz, you can see it on the Right of the Engine. Fill free to play with this value.
The Engine also use a default Gravity Scale of 3 for all Object. I've tried several values and comes up with this one, it's the most important parameter between the three. the computation Frequency coming in second position.
By adding more and more Dynamic object onto the Canvas, the Physic simulation may become slow, so, remenber to play with those Three parameters in order get the Simulition Speed that suit you.