-
Posts
219 -
Joined
-
Last visited
Content Type
Blogs
Forums
Store
Gallery
Videos
Downloads
Everything posted by Andy90
-
I like the function that allows you to collapse objects from the model into a single entity. It would be a great feature within the ultra engine to save a parent with its children as a single model, enabling you to collapse, for example, 10 entities into one. Like the "Create Prefab" function.
-
-
Okey thanks i will have a look later.
-
Hello i want ask what is the best way to create a day night cycle with the leadwerks engine. I know it from unity that you create a pivot in the middle of the scene and attach the directionlight (sun) to this. So you can rotate this pivot and the light will turn arround the terrain. But if i do this it works not realy well. I think its because the ambient lightning from the skybox.
-
Yeah i know. Maybe "lookAt" is the wrong name for the function. Is more the Vec3 at the point where the entity (camera) is looking at
-
I collaborated with ChatGPT to create a 'lookat' function. While it's not a direct 'forward' function, I believe it can be helpful to others. function LookAt(position, pitch, yaw, distance) pitch = math.rad(pitch) yaw = math.rad(yaw) local forward = Vec3() forward.x = math.cos(pitch) * math.sin(yaw) forward.y = -math.sin(pitch) forward.z = math.cos(pitch) * math.cos(yaw) local forward_length = math.sqrt(forward.x ^ 2 + forward.y ^ 2 + forward.z ^ 2) forward.x = forward.x / forward_length forward.y = forward.y / forward_length forward.z = forward.z / forward_length forward.x = forward.x * distance + position.x forward.y = forward.y * distance + position.y forward.z = forward.z * distance + position.z return forward end
-
I told within the dev diary that i will create a own holiday camp for the game and there we go, the first building for the camp is done
-
Found it but i got a question. Its not that important but atm the object structure looks like this is there a method to include the collisionhull into the model itself ?
-
Hello, I would like to ask if it's possible to create physics for an entity using Blender, for instance by naming an object "physics" or something similar?
-
I've developed a second iteration of the script, this time utilizing a prefab. This means there are now two scripts in play: the Spawn Manager and the tree itself. 1. Spawn Manager Script.terrain = nil Script.player = nil --Entity "Player" Script.playerDistance = 30 --Float "Player Distance" Script.seed = 123456 --Float "Seed" Script.treeCount = 25 --Int "Trees" Script.minDist = 25 --Float "Min Distance" Script.maxDist = 75 --Float "Max Distance" Script.tree = "" --Path "Model" Script.treeMinHeight = 0.5 --Float "Min height" Script.treeMaxHeight = 1.0 --Float "Max height" Script.aabbCheck = false --Bool "AABB Check" Script.debug = true --Bool "Debug Mode" Script.treeData = {} function Script:Start() self.entity:Hide() --Find the terrain local world = World:GetCurrent() for i = 0, world:CountEntities() - 1 do local entity = world:GetEntity(i) if entity:GetClass() == Object.TerrainClass then self.terrain = tolua.cast(entity, "Terrain") end end local treeData = {} --Creates the tree data for the pivot tree local x = self.entity:GetPosition(true).x local z = self.entity:GetPosition(true).z local y = self.terrain:GetElevation(x, z) local treeInfo = { TreeName = self.entity:GetKeyValue("name") .. "_tree_center", TreeX = x, TreeY = y, TreeZ = z, TreeScale = 1.0, Visible = true, HideTime = 0 } table.insert(treeData, treeInfo) --Place a sphere at the pivot location if self.debug then local spehre = Model:Sphere() spehre:SetColor(1.0, 0.0, 0.0) spehre:SetScale(1.0) spehre:SetPosition(x, y, z) end math.randomseed(self.seed) for i = 0, self.treeCount do --Calculate the angle and the distance for the new tree local deg = 360 / self.treeCount * i local radians = math.rad(deg) local distance = math.random(self.minDist, self.maxDist) local sin = math.sin(radians) local cos = math.cos(radians) --Calculate the x,y,z cords for the tree local x = self.entity:GetPosition(true).x + distance * cos local z = self.entity:GetPosition(true).z + distance * sin local y = self.terrain:GetElevation(x, z) --Calculates the scale for the tree local scale = math.random(self.treeMinHeight * 100, self.treeMaxHeight * 100) / 100 --If AABB Check is enabled check for collision if self.aabbCheck then for _,item in pairs(self.treeData) do if Vec3(item.TreeX, item.TreeY, item.TreeZ):DistanceToPoint(Vec3(x,y,z)) < 0.5 then System:Print("Double Point") goto continue end end for i = 0, world:CountEntities() - 1 do local entity = world:GetEntity(i) if entity:GetClass() == Object.ModelClass and entity:GetParent() == nil then if entity:GetAABB():IntersectsPoint(Vec3(x,y,z), 1) then System:Print("intersect with entity " .. entity:GetKeyValue("name")) goto continue end end end end --Adds the tree info into the table local treeInfo = { TreeName = self.entity:GetKeyValue("name") .. "_tree_" .. i, TreeX = x, TreeY = y, TreeZ = z, TreeScale = scale, Visible = true, HideTime = 0 } table.insert(treeData, treeInfo) ::continue:: end self.treeData = treeData; end function Script:UpdateWorld() --Enables the trees when the player is nearby local distance = self.entity:GetDistance(self.player) if distance > self.playerDistance + self.maxDist and not self.entity:Hidden() then self.entity:Hide() self:HideTrees() elseif distance < self.playerDistance + self.maxDist and self.entity:Hidden() then self.entity:Show() self:ShowTrees() end -- System:Print(self.entity:GetKeyValue("name") .. " Children " .. self.entity:CountChildren() .. " / " .. #self.treeData) end function Script:ShowTrees() System:Print("Show Trees!") for _, item in pairs(self.treeData) do local tree = Prefab:Load(self.tree) tree.script.treeData = item tree:SetPosition(item.TreeX, item.TreeY, item.TreeZ) tree:SetScale(item.TreeScale) tree:SetKeyValue("name", item.TreeName) tree:SetParent(self.entity) if not item.Visible then tree:Hide() end end end function Script:HideTrees() local t = self.entity:CountChildren() for i = 0, self.entity:CountChildren() -1 do local child = self.entity:GetChild(i) child:Release() end end 2. Tree Script Script.treeData = nil Script.respawn = 10 * 60000 function Script:UpdateWorld() if self.entity:Hidden() then local now = Time:GetCurrent() if now > self.treeData.HideTime + self.respawn then self.treeData.Visible = true self.entity:Show() end end end function Script:Collision(entity, position, normal, speed) if entity:GetKeyValue("name") == "player" then if Window:GetCurrent():KeyDown(Key.E) then self.entity:Hide() self.treeData.Visible = false self.treeData.HideTime = Time:GetCurrent() end end end As you can see, the trees are no longer created within the Start function. They are dynamically generated when the player is nearby and released when the player moves away. This enhancement greatly improves performance. For example, if you have 10 spawners each with 50 trees, the old script would add 500 entities to the scene. With the new script, you only add the 10 pivot points, and create the entities for the trees only when the player is nearby. I hope this will help anyone within the future
-
Ah okey this sounds very nice. I finished my script for a tree spawning based on a pivot Script.terrain = nil Script.player = nil --Entity "Player" Script.playerDistance = 30 --Float "Player Distance" Script.seed = 123456 --Float "Seed" Script.treeCount = 25 --Int "Trees" Script.minDist = 25 --Float "Min Distance" Script.maxDist = 75 --Float "Max Distance" Script.tree = "" --Path "Model" Script.treeMinHeight = 0.5 --Float "Min height" Script.treeMaxHeight = 1.0 --Float "Max height" Script.debug = true --Bool "Debug Mode" function Script:Start() --Find the terrain local world = World:GetCurrent() for i = 0, world:CountEntities() - 1 do local entity = world:GetEntity(i) if entity:GetClass() == Object.TerrainClass then self.terrain = tolua.cast(entity, "Terrain") end end --Sets a tree at the pivot location local x = self.entity:GetPosition(true).x local z = self.entity:GetPosition(true).z local y = self.terrain:GetElevation(x, z) local tree = Model:Load(self.tree) tree:SetPosition(x, y, z) tree:SetParent(self.entity) --Place a sphere at the pivot location if self.debug then local spehre = Model:Sphere() spehre:SetColor(1.0, 0.0, 0.0) spehre:SetScale(1.0) spehre:SetPosition(x, y, z) end math.randomseed(self.seed) for i = 0, self.treeCount do --Calculate the angle and the distance for the new tree local deg = 360 / self.treeCount * i local radians = math.rad(deg) local distance = math.random(self.minDist, self.maxDist) local sin = math.sin(radians) local cos = math.cos(radians) --Calculate the x,y,z cords for the tree local x = self.entity:GetPosition(true).x + distance * cos local z = self.entity:GetPosition(true).z + distance * sin local y = self.terrain:GetElevation(x, z) --Calculates the scale for the tree local scale = math.random(self.treeMinHeight * 100, self.treeMaxHeight * 100) / 100 --Creates the tree within the scene local tree = Model:Load(self.tree) tree:SetPosition(x, y, z) tree:SetScale(scale) tree:SetParent(self.entity) --Creates a debug sphere at the tree location if self.debug then local spehre = Model:Sphere() spehre:SetColor(1.0, 1.0, 0.0) spehre:SetScale(1.0) spehre:SetPosition(x, y, z) end end end function Script:UpdateWorld() --Enables the trees when the player is nearby local distance = self.entity:GetDistance(self.player) if distance > self.playerDistance then self.entity:Hide() else self.entity:Show() end end
-
Ah, okay. Thanks anyway. I'll give it a shot with C++. If that doesn't work, I'll have to explore alternative methods to add wood to the player's inventory. Perhaps by incorporating additional prefab trees placed around a pivot, similar to the suggestion by @Alienhead. ---- For example, will it be possible to access individual vegetation objects in the Ultra Engine?
-
ok, so there is no way to get the position from the trees? I found within the article linked from @klepto2 something like this AABB aabb = world->aabb; std::vector<Mat4> instances; layer->GetInstancesInAABB(aabb, instances);
-
Is there a documentation about the terrain class in lua?
-
The new dev diary is online i also found a name for the project "Nuclear Frontiers" i think the name fits well. Here is the logo for it an you can watch the new dev diary here:
-
-
First Real House will included into the game today It as not easy to create because i was need to create some own materials for substance
-
Im not sure anymore tbh. But i think it was the editor.