Jump to content

pharoseer

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by pharoseer

  1. Just checked on Windows 10, it's working for me as well.
  2. No doubt! I hope more HMDs adopt that tech. I haven't been able to make use of it yet, but some of the demos I've tried have been pretty awesome. Being able to select targets by looking at them is really cool.
  3. Hey Josh, this is really great stuff. I started messing around with it this evening and drummed up the following VR controller. It's not complete, but maybe it'll help others get started. I'm stumped on how to change the HMD's base rotation to match a parent entity's though (very end of the code). I was trying to implement snap-turning. Also, just as a heads up, I'm testing with a Fove and it works great. I haven't tried it on my Rift yet. Script.TrackingSpace = 0 --choice "Tracking Type" "Seated, Roomscale" Script.CameraHeight = 1.75 --float "Camera Height" -- Maybe changing the FOV will stop items popping in and out at the edges Script.PlayerFOV = 90.0 --float "Player FOV" Script.MovementSpeed = 2.0 --float "Movement Speed" Script.SnapTurn = true --bool "Use Snap Turning" -- This is used when SnapTurn is true. Script.TurnAngle = 30 --int "Snap Turn Angle" -- This is used when SnapTurn is false. Script.TurnSpeed = 1.0 --float "Smooth Turn Speed" Script.Camera = nil local vr_enabled = true local actions = {} function Script:InitializeActions() --------------------------------------- -- Set this to false if you use QWERTY --------------------------------------- local dvorak = true if dvorak then actions.move_forward = Key.Comma actions.move_back = Key.O actions.strafe_left = Key.A actions.strafe_right = Key.E actions.turn_left = Key.Quotes actions.turn_right = Key.Period else -- Assume QWERTY actions.move_forward = Key.W actions.move_back = Key.S actions.strafe_left = Key.A actions.strafe_right = Key.D actions.turn_left = Key.Q actions.turn_right = Key.E end actions.center_view = Key.Space end function Script:Start() self.InitializeActions() -- Add basic character properties self.entity:SetMass(1) self.entity:SetCollisionType(Collision.Character) self.entity:SetPhysicsMode(Entity.CharacterPhysics) -- Create the VR camera self.Camera = Camera:Create() self.Camera:SetParent(self.entity) self.Camera:SetFOV(self.PlayerFOV) self.Camera:SetPosition(Vec3(0, self.CameraHeight, 0)) -- Enable VR if vr_enabled then VR:Enable() VR:SetTrackingSpace(self.TrackingSpace) end end function Script:UpdateWorld() self:CharacterMovement() end function Script:CharacterMovement() local forward = 0 local strafe = 0 local angle = 0 if window:KeyDown(actions.move_forward) then forward = forward + 1 end if window:KeyDown(actions.move_back) then forward = forward - 1 end if window:KeyDown(actions.strafe_left) then strafe = strafe - 1 end if window:KeyDown(actions.strafe_right) then strafe = strafe + 1 end if self.SnapTurn then -- Use KeyHit() instead of KeyDown() to avoid continuous turning. if window:KeyHit(actions.turn_left) then angle = angle - self.TurnAngle end if window:KeyHit(actions.turn_right) then angle = angle + self.TurnAngle end else if window:KeyDown(actions.turn_left) then angle = angle - self.TurnSpeed end if window:KeyDown(actions.turn_right) then angle = angle + self.TurnSpeed end end if window:KeyDown(actions.center_view) and vr_enabled then VR:CenterTracking() end forward = forward * self.MovementSpeed strafe = strafe * self.MovementSpeed local turn_angle = self.entity:GetRotation(true).y + angle self.entity:SetInput(turn_angle, forward, strafe) if vr_enabled then -- Set the HMD position to correspond to the parent entity. VR:SetOffset(self.entity:GetPosition(true) + Vec3(0.0, self.CameraHeight, 0.0)) -- TODO: How do I adjust the HMD's base rotation? This doesn't seem to work. if angle ~= 0 then VR:CenterTracking() end end end
  4. I've encountered this as well. Same exact setup with two CSG objects, one changes color only (works) and the other changes materials (doesn't work). Looking at the log it shows that the material was loaded, it just isn't being applied to the surface. (Edit) I figured I'd include the code for my script as well: Script.primary = "" --path "Primary Material" "Material File (*mat):mat|Material" Script.alternate = "" --path "Alternate Material" "Material File (*mat):mat|Material" Script.current = 0 function Script:SetPrimary()--in self.current = 0 local material = Material:Load(self.primary) if (not material) then print("[ERROR] ChangeMaterial:SetPrimary() -> Failed to load material") material = Material:Create() material:SetColor(1, 0, 1) end self.entity:SetMaterial(material, true) end function Script:SetAlternate()--in self.current = 1 local material = Material:Load(self.alternate) if (not material) then print("[ERROR] ChangeMaterial:SetAlternate() -> Failed to load material") material = Material:Create() material:SetColor(1, 0, 1) end self.entity:SetMaterial(material, true) end
  5. I was working through Jorn Theunissen's tutorials on youtube and when I got to #4 where he creates a pressure plate I wanted to toggle the texture or color of the plate to indicate that it was activated or deactivated. That was when I discovered that the ability to test for Enter and Exit events wasn't implemented yet for trigger volumes. I tinkered around a bit and come up with the following script that should handle that nicely: -------------------------------------------------------------------------------- -- Author: Frank Taylor -- Date: January 22, 2016 -- Description: Allows the detection of Enter and Exit events when applied to -- a trigger volume. -------------------------------------------------------------------------------- -- Toggles the states of the events allowing them to be fired only once before -- the other event is triggered again. Script.EnterEnabled = true Script.ExitEnabled = false -- This allows us to wait a period of time to ensure we've ACTUALLY left the -- volume. If it was true/false the state would rapidly toggle. Checking if -- this value drops below 0 is a two value decrease, meaning that -- Script:Collision was not triggered for at least one update -- a good sign -- that the volume is no longer occupied. Script.EventIndex = 1 function Script:Collision(entity, position, normal, speed) self.EventIndex = 1 if (self.EnterEnabled) then self.EnterEnabled = false self.ExitEnabled = true -- Send our event self.component:CallOutputs("Entered") if DEBUG then print("Volume ".. self.entity:GetKeyValue("name") .." Entered") end end end function Script:UpdateWorld() if (self.ExitEnabled and self.EventIndex < 0) then -- Enabled the Enter event self.EnterEnabled = true -- Disable the Exit event self.ExitEnabled = false -- Send our event self.component:CallOutputs("Exited") if DEBUG then print("Volume ".. self.entity:GetKeyValue("name") .." Exited") end end if (self.ExitEnabled) then self.EventIndex = self.EventIndex - 1 end end Feel free to use it. I wouldn't mind credit, but I won't demand it either. The only thing I've noticed is that the print statements don't seem to appear in the output until after exiting the game window. I've only been playing with Leadwerks for a few days so I'm sure I'm missing something. Cheers, Frank
×
×
  • Create New...