Jump to content

Slastraf

Members
  • Posts

    710
  • Joined

  • Last visited

Everything posted by Slastraf

  1. Have you set your object collision type to debris ? It collides with scene and props, but not with itself. Here you can find a quick example but you should try out Collision.Debris or find the index for it https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetCollisionType
  2. lerp = Math::Lerp(2, 0, 0.5); will always make the player height zero lerp = Math::Lerp(camera->GetPosition().y, (playerheight*cdown ), 0.5); does this make sense to you ? camera->GetPosition().y, may be wrong but you need to get the y part of the vector of getposition also you need to remove (makes no sense): while (true) { // remove this line camera->GetPosition();
  3. //might not work but is pseudo code // Vec3 ccamerapos = ccamera->GetPosition(); // ccamera->SetPosition(0, Math::Lerp(1, ccamerapos->GetY(), (crouchedBool*(characterheight)+crouchHeight 0);
  4. you need this to be a function with a tick and for every tick your camera moves a tiny bit more towards the target position. You could use Lerp in that function : https://www.leadwerks.com/learn?page=API-Reference_Object_Math_Lerp
  5. About the turn, I haven't used it as I needed to "snap" rotation in my case. Alternatively, have you tried adding a simple box collision to the bone, that dont ollide with each other, make the bones a joint of some sort, and then apply gravity to make it a ragdoll ?
  6. This is a really hard thing to do and unfortunately it only ever works with upright bone models. I made spider legs but modeled them like this place bone, do not rotate scale etc extrude it to the top Then it is possible to rotate them, but also only tested with setrotation()
  7. Personally I would use leadwerks stream and make my own parser and file system depending on what I need for example names.data foo bar then loop trough all the lines and read all the data into an array
  8. First you need some kind of noise funciton in lua. https://github.com/Auburn/FastNoiseLite/releases/download/v1.0.3/FastNoiseLiteGUI-Win64.exe this is an example program to make differnent kinds of noises (-> https://github.com/Auburn/FastNoise_CSharp) This is perlin lua noise : https://gist.github.com/kymckay/25758d37f8e3872e1636d90ad41fe2ed Here an explaination. http://adrianb.io/2014/08/09/perlinnoise.html I have already implemented a noise generator in c++. This is the most important part : int roundedPosX = std::round(playerPos.x/tileSize)-offset; int roundedPosY = std::round(playerPos.z/tileSize)-offset; // skip calculations if player moved in the same chunk if(lastUpdatedPlayerPos.x==roundedPosX&&lastUpdatedPlayerPos.y==roundedPosY) return; else lastUpdatedPlayerPos = Vec2(roundedPosX, roundedPosY); const siv::PerlinNoise perlin(seed); // new chunk generation for(int x = roundedPosX; x<roundedPosX+chunkRows; x++) { for(int y = roundedPosY; y<roundedPosY+chunkRows; y++) { /**code skipped here */ for(int i = 0; i<surface->CountVertices(); i++) { Vec3 xy = surface->GetVertexPosition(i); float xPos = (x+(xy.x*.5)); //the vertex position ranges from float yPos = (y+(xy.z*.5)); float height = 0.5*perlin.accumulatedOctaveNoise2D(xPos/(frequency), yPos/(frequency), octaves); height += 0.25*perlin.accumulatedOctaveNoise2D(xPos/(frequency)*2, yPos/(frequency)*2, octaves); surface->SetVertexPosition(i, xy+Vec3(0,height,0)); } surface->Update(); // enable physics //c->chunkModel->SetShape(Shape::PolyMesh(surface)); c->chunkModel->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); activeChunks.insert({Vec2(x, y), c}); } } It takes the player position , converts it to chunk coordinates and spawns chunks around the player. For each vertice of a flat plane base we put the height of the vertice at the height of the perlin noise function. Thats it. All other things, e.g. chunks, loading, unloading is up to you because you wanted to make a third person game so you want to load bigger chunks with more vertices so you can look further. Honestly if I could go back I would do more reasearch for leadwerks plugins and write these things to the leadwerks internal terrain. You look for each point on xz, the noise function returns for example -1 to 1. So if above 0.9 then generate road . //edit
  9. Well for one, have an engine that allows you to walk more than 10 minutes into one direction with my character controller without despawning the camera. __________ (alternative answer) __________ There is a huge difference between random generation and procedural because the latter adds many rules to your liking. Procedural noise such as Perlin allows you to make height maps. The more "octaves" you add ( 0.5*perlin(frequency)+0.25*perlin(frequency)+) essentially (for i<n do (i/2)*perlin(frequency) + (i/2*n)*perlin(frequency) ). Octaves = detail This looks something like this: If you wanted to add roads for instance you can generate a ridged fractal and you see where this is going. You would check for the "whiteness" and if it is above a threshold, generate a road texture. Alternatively, use line detection algorithms. Same thing for the textures, but this is a whole different topic.Blender has good content on procedural textures e.g. Eevee procedural textures. This looks pretty persistent to me, and if scaled up on a map you have roads and detail. Maybe you can think of rules to generate villages ? It would require there to be a "straight" road patch, then make a origin in the center of that road, then generate some houses / npc's along the road and perhaps generate smaller "alleys" from the dot or orthogonal vector of the road.
  10. I have gone from 15 fps to 130 fps by optimizing my code about terrain generation and procedural textures. Chances are if it runs at 15 fps in LE 4 it will also run at 15 fps in LE 5 There are many things that cannot be done in LE 4 without many workarounds such as transparency shaders, geometry shaders etc. Once the first run-able instance of the new engine is out I will start to write my own plugins for procedural stuff and do the things that right now are hard.
  11. You should add AI to the game that follows you really fast and shoots guns and stuff at you and you will be able to get revenge by upgrading your car + weapons
  12. I see, but I talked about actual roads to drive on, that can be placed in the terrain.
  13. Hey that looks really good. Do you want to collaborate on a procedural road decal ?
  14. I also had trouble in the beginning with the default project settings
  15. I had this happen so often to me over years on random applications and feels like this has bugging me ever since.
  16. can we "crossfade" models into the terrain as found in unreal engine ?
  17. Theres always risks not running everything correctly in the browsers. Opera offers anti tracking, free unlimited vpn and addons and built in whatsapp twitter etc.
  18. It seems to be very small at 4000 aswell. In this scene I put the size to 4000 in the editor and did the same thing from before but the player still disappeared. This is a major issue to the game I want to develop, and even still this should not be the limit to this engine. 2021-05-22 19-06-11.mp4
  19. this is enough for collision but to maek your actual wayve more interesting you could add smaller noises at higher frequency than the big wave. https://www.shadertoy.com/view/MtsXzl
  20. I see. You don't need a displacement map. This can easily be calculated this is basically a cos function in the range of [0, 8*pi] pixel(x,y) = cos((y/height)*3.1415926*8) Just to give you a headstart. To get the color information you would use the function from above like this disp = (pixel(x,y)*0.5+1)/255 because cos goes from -1 to 1 and if we add one it goes from 0 to 2, then multiply by 0.5 to get from 0 to 1 and divide by 255 to get the color intensity.
  21. The shader still calculates the height of the wave trough a function. It must contain sin / cos. If you copy that function to lua with the same parameters, it will have mathematically the same result. Which parameters would need to be converted from leadwerks global space to whatever space the shader operates.
  22. Slastraf

    Introduction

    This looks very exciting. Every finished game should have some sort of combination of post effect shaders, because these add just something to the game. Really looking forward for 52 shaders !
  23. You would need to get the surface of the model. Not tested here I will give you a tip: local model = Model:Load("Models/Grass/grass01.mdl") local surface = model:GetSurface(0) local smallest = nil for v=0,surface:CountVertices()-1 do local position = surface:GetVertexPosition(v) --multiply by scale (you mentioned 1500) local vertDistance = self.entity:GetDistance(model:GetPosition()+(surface:GetVertexPosition(v)* 1500)) if smallest == nil or vertDistance < currDistance then currDistance = vertDistance smallest = v end end local posOfNearestVert = model:GetPosition()+(surface:GetVertexPosition(smallest)* 1500) This probably wont work on the first try, but is an example on how to approach this. Also you cannot directly get the vertex, but the position as presented
×
×
  • Create New...