Jump to content

reepblue

Developers
  • Posts

    2,509
  • Joined

  • Last visited

Everything posted by reepblue

  1. Unlike CollisionTrigger, VolumeTrigger does it's work by it's entity's aabb radius being called on the UpdatePhysics thread. VolumeTrigger also keeps track of what objects are in the volume, and entities with swept collision can enter the volume because it doesn't use shapes for triggering. --[[ This script will make any entity act as a volume trigger. Having a trigger be AABB tests rather than collision has it's perks as it's easier to keep track of what entities are in the volume. Also, objects with swept collision can now activate triggers! ----NOTES---- filter <entity> = Use this feild if you wish to have a specific entity trigger outputs. enabled <bool> = Toggle the trigger on and off onlyonce <bool> = When true, the trigger deactivate forever when triggered the first time. sizetest <bool> = When true, the overlap test will preform a aabb radius on both the trigger and entity in question. If false, only the entity's position will be tested. Make this true if you want a true collision like trigger. allowcharacters <bool> = Toggles if characters can activate. allowprops <bool> = Toggles if props can activate. allowdebri <bool> = Toggles if debris can activate. allowprojectiles <bool> = Toggles if projectiles can activate. ]]-- import "Scripts/Functions/IsAABBOverlap.lua" Script.filter=nil--entity "Filter" Script.enabled=true--bool "Enabled" Script.onlyonce=false --bool "Only Once" Script.sizetest=false --bool "Size Test" -- These values will get ignored if there is no filter. Script.allowcharacters=true --bool "Allow Characters" Script.allowprops=true --bool "Allow Props" Script.allowdebris=true --bool "Allow Debris" Script.allowprojectiles=true --bool "Allow Projectiles" function TriggerForEachEntityInAABBDoCallback(entity,extra) local volumeent = extra local filterent = volumeent.script.filter -- Always skip these! if entity == volumeent then return end if entity:GetClass() == Object.PivotClass then return end if entity:GetClass() == Object.BoneClass then return end if entity:GetClass() == Object.DirectionalLightClass then return end if entity:GetClass() == Object.SpotLightClass then return end if entity:GetClass() == Object.PointLightClass then return end if entity:GetClass() == Object.ListenerClass then return end if entity:GetClass() == Object.ProbeClass then return end -- Don't count static brushes! if entity:GetCollisionType() == Collision.Scene then if entity:GetMass() <= 0 then return end end -- If we're not looking for a specific entity, filter by collision types. if filterent == nil then if entity:GetCollisionType() == Collision.None then return end if entity:GetCollisionType() == Collision.Character and not volumeent.script.allowcharacters then return end if entity:GetCollisionType() == Collision.Prop and not volumeent.script.allowprops then return end if entity:GetCollisionType() == Collision.Debris and not volumeent.script.allowdebris then return end if entity:GetCollisionType() == Collision.Projectile and not volumeent.script.allowprojectiles then return end if IsAABBOverlap(volumeent,entity,volumeent.script.sizetest) == true then volumeent.script:onstartTouch(entity) end elseif entity == filterent then if IsAABBOverlap(volumeent,filterent,volumeent.script.sizetest) == true then volumeent.script:onstartTouch(entity) end end end function Script:SearchForEntites() self.entity.world:ForEachEntityInAABBDo(self.entity:GetAABB(Entity.GlobalAABB),"TriggerForEachEntityInAABBDoCallback",self.entity) end function Script:IsAlreadyTouching(entity) local key,value for key,value in pairs(self.touchingents) do if value == entity then return true end end return false end function Script:Start() self.touchingents={} self.triggered=false -- Disable Shadows self.entity:SetShadowMode(0) -- Ignore all picking. self.entity:SetPickMode(0) -- Automaticly fix the Physics self.entity:SetCollisionType(Collision.None) self.entity:SetMass(0) self.entity:SetKeyValue("type", "trigger") self.entity:SetViewRange(Entity.NearViewRange) end function Script:UpdatePhysics() if not self.enabled then return end if onlyonce and self.triggered then return end self:SearchForEntites() if table.getn(self.touchingents) > 0 then local key,value for key,value in pairs(self.touchingents) do local zentity = value if zentity ~= nil then if IsAABBOverlap(self.entity,zentity,self.sizetest) == false then self:onendTouch(key, zentity) break end end end end end function Script:onstartTouch(entity) if self:IsAlreadyTouching(entity) == false then if table.getn(self.touchingents) == 0 then -- If it's the first item, call a special function. self.component:CallOutputs("onstartTouchAll") self.component:CallOutputs("onstartTouch") else self.component:CallOutputs("onstartTouch") end table.insert(self.touchingents, entity) self.triggered=true --System:Print("Added " ..entity:GetKeyValue("name") .. " to list") end end function Script:onendTouch(key, entity) if table.getn(self.touchingents) < 0 then return end if table.getn(self.touchingents) == 1 then -- If it's the last item, call a special function. self.component:CallOutputs("onendTouchAll") self.component:CallOutputs("onendTouch") else self.component:CallOutputs("onendTouch") end --System:Print("Removing " ..entity:GetKeyValue("name") .. " from list") table.remove(self.touchingents, key) end
  2. Just tried to re-detail the Vectronic and I noticed that the probes no longer make a difference. I also tried this with a blank project as well. Pretty much: Create a new map Place a few boxes and shapes Add in a probe Notice that the probe doesn't make the shadows lighter or make reflections. You can set the values to max, and it still will not make a difference.
  3. Probes build a cubemap texture once based on the location of the entity, and then applies it to the surrounding materials in it's radius. SSR is a post processing effect that in which all reflections update consistently. I haven't take a look at the new SSR, but here's hoping that it follows specular and roughness values.
  4. If you can help me get the Vectronic Demo pass the generic error when I upload to Seam, I'd be more than willing to update that to 4.2!
  5. Alright, sounds understandable. It's not too hard to do a hook to get those functions working again. Thanks for answering, just wanted to know if there was any improvement since the 22nd.
  6. Are all the functions working now? What's your plan for integrating actors with the editor?
  7. Here is a trigger material. Seems the blend mode only works if Z-Sort is on. (Intentional?) Edit: Added transparency! triggermat2.zip
  8. That makes me smile. You also forgot to mention this, which also makes me smile: Whoops, misread, this is experimental atm. http://www.leadwerks.com/werkspace/topic/15235-actor-class-for-c-entity-management/ Hopefully you can fix the bugs you listed soon. Also, did you mind taking a look at this? http://www.leadwerks.com/werkspace/topic/15355-exceptions-problem-visual-studio-17/ I was having similar issues. I'm about to start a new project so I can properly report what "kicks the bucket" more exclusively. Also, why didn't you use my workshop button graphic? Does it need more work or you don't like my take on it?
  9. Yeah, I get odd issues with the debug builds when loading a map. I thought it was something with my map loading code. Does the stock code have issues?
  10. A beam script that'll stretch a sprite from one point to another. Useful for lasers and cables. You can enable or disable auto updating if it isn't necessary. --[[ This script will create a simple sprite that looks like a beam or a cable. The beam is does not do any raycasting along and gets updated via the physics step. You can apply a script to the beam to change it's appearance such as flickering or pulsing. ]]-- Script.fxscriptfile=""--path "Beam Script" "Script (*.lua):lua|Scripts/Objects/Effects" Script.beamcolor=Vec4(1,1,1,1) --color "Beam Color" Script.beambrightness=1.0--float "Beam Brightness" Script.materialfile=""--path "Material" "Material (*.mat):mat|Materials" Script.beamwidth = .25 --float "Beam Width" Script.startpoint = nil --entity "Start Position" Script.endpoint = nil --entity "End Position" Script.beamhidden = false --bool "Hidden" Script.autoupdate = true --bool "Auto-Update" function Script:Start() -- Ignore pickers from picking us! self.entity:SetPickMode(0) -- Beam Sprite self.sprite = Sprite:Create() local material = Material:Load(self.materialfile) if material then self.sprite:SetMaterial(material) material:Release() else System:Debug("Beam material is missing.") end self.sprite:SetViewMode(6)--Rotate around z axis if self.fxscriptfile ~= nil then self.sprite:SetScript(self.fxscriptfile) end self.sprite:SetColor(self.beamcolor) self.sprite:SetIntensity(self.beambrightness) if not self.beamhidden then self.sprite:Show() else self.sprite:Hide() end -- If the first feild is nil, assume the user want's it to be the entity that holds this script. if self.startpoint == nil then self.startpoint = self.entity end -- A end point is needed. If nil, report error. if self.endpoint == nil then System:Debug("End point is nil.") end -- Only draw the beam once of auto-update is false. if not self.autoupdate then self:UpdateBeam() end end function Script:UpdateBeam() -- Return if the beam is hidden. if self.sprite:Hidden() then return end local p0 = self:GetStartPoint() local p1 = self:GetEndPoint() self.allignvector = p0 - p1 self.sprite:SetPosition((p0+p1)/2) self.sprite:AlignToVector(self.allignvector:Normalize(),2) -- Find distance between the two points. local distanceX = math.pow(p0.x - p1.x, 2) local distanceY = math.pow(p0.y - p1.y, 2) local distanceZ = math.pow(p0.z - p1.z, 2) local total_distance = math.sqrt(distanceX + distanceY + distanceZ) -- Modify the size of the beam based on the 2 points. self.sprite:SetSize(self.beamwidth, math.abs(total_distance)) end function Script:UpdatePhysics() if self.autoupdate then self:UpdateBeam() end end function Script:GetStartPoint() return self.startpoint:GetPosition(true) end function Script:GetEndPoint() return self.endpoint:GetPosition(true) end function Script:TurnOn()--in if self:IsOn() then return end self.sprite:Show() end function Script:TurnOff()--in if not self:IsOn() then return end self.sprite:Hide() end function Script:Toggle()--in if self:IsOn() then self:TurnOff() else self:TurnOn() end end function Script:IsOn() return not self.sprite:Hidden() end function Script:Release() self.sprite:Release() end If you're looking for a laser beam in which the end position is the end of a pick test, you can check out this post for details on how to do it. This script just has the basic functionality. You can reuse the script for more complex effects by ether cloning the script, or setting the script to an entity and then modifying it's values like. -- Make Pivot local p = Pivot:Create() -- Set Script to Pivot p:SetScript("scripts/objects/effects/beam.lua") -- Modify some values p.script.beamcolor=Vec4(1,0,0,1) p.script.autoupdate = false .... ....
  11. Cool, if you manage to get to finishing it, I'd be more than happy to have a look.
  12. Really like the flash drive idea as a prize, those are always handy! Also thanks for the extra 2 weeks. things can be busy with the holidays and all. I'll see what I can come up with and make it workshop friendly unlike last time.
  13. Like the flicker script, this will modify an entities intensity to create a pulsing effect. If any improvements can be made, let me know! Script.frequency=10.0--float "Frequency" Script.Recursive=true--bool function Script:Start() self:SaveIntensity(self.entity,self.Recursive) end --Store the original intensity values function Script:SaveIntensity(entity,recursive) entity:SetKeyValue("Pulse_Intensity",entity:GetIntensity()) if recursive then local n for n=0,entity:CountChildren()-1 do self:SaveIntensity(entity:GetChild(n),true) end end end --Apply a modified intensity value function Script:ApplyIntensity(entity,intensity,recursive) local i = entity:GetKeyValue("Pulse_Intensity") if i~="" then entity:SetIntensity(tonumber(i) * intensity) if recursive then local n for n=0,entity:CountChildren()-1 do self:ApplyIntensity(entity:GetChild(n),intensity,true) end end end end function Script:Draw() if self.color==nil then self.color = self.entity:GetColor() end local alpha = Math:Sin(Time:Millisecs()/self.frequency)*0.25+0.75 self:ApplyIntensity(self.entity,alpha,self.Recursive) end
  14. Odd, Josh mentioned he did that already, Maybe it didn't get pushed?
  15. Sadly most people on the Leadwerks forum use lua so C++ talk is kind of scarce. You'll need to purchase the Professional Edition DLC if you haven't already. First, join the beta branch. Leadwerks is going forward with Visual Studio 2017, and you can get the IDE here. Please note that Visual Studio is for Windows, and Code::Blocks is only for Linux. When you create a project or update an existing project, the project files for both IDE's will get cloned to your project. The code is set up to launch the engine, and call Main.lua/App.lua script. Again, Leadwerks at the moment is more focused on Lua, and I personally recommend only using C++ for program management (Time, level loading, etc) over game objects. (doors, swtiches)
  16. That's how I did it in the Vectronic Demo, it was kind of a pain tho.
  17. Yes, but if a trigger brush will get seen by the probe cameras and the reflection will have your trigger brush in the cubemap!
  18. Just recycling the vegetation billboard system would be ideal. Although lods are great, making them kind of sucks.
  19. Oh right, cause HUD textures are not suppose to have mipmaps. However, if a HUD texture does have mipmaps (for example, the advanced first person shooter crosshair), it'll remain pixelated. I'll give it another go in the future. Thanks,
  20. I hope one day SetLoadingMode is supported. Would be nice to have hud textures work properly.
  21. I find the default Start function fine for most cases. I only use my PostStart call for sounds. This will prevent any sounds playing while the level is loading. From my experience, Start seems to be called right after the entity and it's component has been made. I recall in a early build of the Vectronic Demo, the spawn sound played while the rest of the map was still loading. (Most noticeable in debug mode) Of course, that was back in 3.5/3.6, and I have been taking my own precautions since! Also, for the record, entity->CallFunction() can be called without a check to see if the entity has a script component attached to it.
  22. I made something a while back, but when you use it with probes, the reflection of the trigger brushes get baked within it's reflection. Josh said (a while back, mind you) he was gonna look into a "show in-game" option in which unlike "Hidden", would only have the entities Draw function skipped.
  23. At the end of my level loading process, tell all entities in my scene to start the function "PostStart". for (const auto& entity : world->entities) { entity->CallFunction("PostStart"); }
  24. reepblue

    SSLR WIP

    Really cool. Maybe if polished enough, it can be a standard scene option? This way the user doesn't need to worry about having this shader on top of the stack like the old one. A tick-box option for this would be great.
×
×
  • Create New...