diff --git a/Documentation/ScriptingAPI-Documentation.md b/Documentation/ScriptingAPI-Documentation.md index 98b9e3326..64d5f7ffd 100644 --- a/Documentation/ScriptingAPI-Documentation.md +++ b/Documentation/ScriptingAPI-Documentation.md @@ -247,10 +247,11 @@ A four component floating point vector. Provides efficient calculations with SIM - SetY(float value) - SetZ(float value) - SetW(float value) -- Transform(Matrix matrix) - Length() : float result - Normalize() : Vector result - QuaternionNormalize() : Vector result +- Transform(Vector vec, Matrix matrix) +- TransformNormal(Vector vec, Matrix matrix) - Add(Vector v1,v2) : Vector result - Subtract(Vector v1,v2) : Vector result - Multiply(Vector v1,v2) : Vector result diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 13fa57b97..03fab8d43 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -751,12 +751,12 @@ void EditorComponent::Update(float dt) xDif = 0.1f*xDif*(1.0f / 60.0f); yDif = 0.1f*yDif*(1.0f / 60.0f); wiInputManager::setpointer(originalMouse); - wiInputManager::hidepointer(false); + wiInputManager::hidepointer(true); } else { camControlStart = true; - wiInputManager::hidepointer(true); + wiInputManager::hidepointer(false); } const float buttonrotSpeed = 2.0f / 60.0f; diff --git a/WickedEngine/MainComponent.cpp b/WickedEngine/MainComponent.cpp index 6ab8559ed..7d3bd5bd0 100644 --- a/WickedEngine/MainComponent.cpp +++ b/WickedEngine/MainComponent.cpp @@ -199,12 +199,12 @@ void MainComponent::Run() void MainComponent::Update(float dt) { + wiLua::GetGlobal()->Update(); + if (GetActivePath() != nullptr) { GetActivePath()->Update(dt); } - - wiLua::GetGlobal()->Update(); } void MainComponent::FixedUpdate() diff --git a/WickedEngine/Vector_BindLua.cpp b/WickedEngine/Vector_BindLua.cpp index 2eaed910f..8982aeb42 100644 --- a/WickedEngine/Vector_BindLua.cpp +++ b/WickedEngine/Vector_BindLua.cpp @@ -16,6 +16,7 @@ Luna::FunctionType Vector_BindLua::methods[] = { lunamethod(Vector_BindLua, SetZ), lunamethod(Vector_BindLua, SetW), lunamethod(Vector_BindLua, Transform), + lunamethod(Vector_BindLua, TransformNormal), lunamethod(Vector_BindLua, Length), lunamethod(Vector_BindLua, Normalize), lunamethod(Vector_BindLua, QuaternionNormalize), @@ -138,19 +139,39 @@ int Vector_BindLua::SetW(lua_State* L) int Vector_BindLua::Transform(lua_State* L) { int argc = wiLua::SGetArgCount(L); - if (argc > 0) + if (argc > 1) { - Matrix_BindLua* mat = Luna::lightcheck(L, 1); - if (mat) + Vector_BindLua* vec = Luna::lightcheck(L, 1); + Matrix_BindLua* mat = Luna::lightcheck(L, 2); + if (vec && mat) { - Luna::push(L, new Vector_BindLua(XMVector4Transform(vector, mat->matrix))); + Luna::push(L, new Vector_BindLua(XMVector4Transform(vec->vector, mat->matrix))); return 1; } else - wiLua::SError(L, "Transform(Matrix matrix) argument is not a Matrix!"); + wiLua::SError(L, "Transform(Vector vec, Matrix matrix) argument types mismatch!"); } else - wiLua::SError(L, "Transform(Matrix matrix) not enough arguments!"); + wiLua::SError(L, "Transform(Vector vec, Matrix matrix) not enough arguments!"); + return 0; +} +int Vector_BindLua::TransformNormal(lua_State* L) +{ + int argc = wiLua::SGetArgCount(L); + if (argc > 1) + { + Vector_BindLua* vec = Luna::lightcheck(L, 1); + Matrix_BindLua* mat = Luna::lightcheck(L, 2); + if (vec && mat) + { + Luna::push(L, new Vector_BindLua(XMVector3TransformNormal(vec->vector, mat->matrix))); + return 1; + } + else + wiLua::SError(L, "TransformNormal(Vector vec, Matrix matrix) argument types mismatch!"); + } + else + wiLua::SError(L, "TransformNormal(Vector vec, Matrix matrix) not enough arguments!"); return 0; } int Vector_BindLua::Length(lua_State* L) diff --git a/WickedEngine/Vector_BindLua.h b/WickedEngine/Vector_BindLua.h index 9ebd99100..56b5f82b5 100644 --- a/WickedEngine/Vector_BindLua.h +++ b/WickedEngine/Vector_BindLua.h @@ -28,6 +28,7 @@ public: int SetW(lua_State* L); int Transform(lua_State* L); + int TransformNormal(lua_State* L); int Length(lua_State* L); int Normalize(lua_State* L); int QuaternionNormalize(lua_State* L); diff --git a/WickedEngine/wiInputManager.cpp b/WickedEngine/wiInputManager.cpp index 7ec57c188..aecb04052 100644 --- a/WickedEngine/wiInputManager.cpp +++ b/WickedEngine/wiInputManager.cpp @@ -177,11 +177,11 @@ namespace wiInputManager #ifndef WINSTORE_SUPPORT if (value) { - while (ShowCursor(true) < 0) {}; + while (ShowCursor(false) >= 0) {}; } else { - while (ShowCursor(false) >= 0) {}; + while (ShowCursor(true) < 0) {}; } #endif } diff --git a/WickedEngine/wiSceneSystem.cpp b/WickedEngine/wiSceneSystem.cpp index 390901937..382d90d04 100644 --- a/WickedEngine/wiSceneSystem.cpp +++ b/WickedEngine/wiSceneSystem.cpp @@ -1965,8 +1965,15 @@ namespace wiSceneSystem ForceFieldComponent& force = forces[args.jobIndex]; Entity entity = forces.GetEntity(args.jobIndex); const TransformComponent& transform = *transforms.GetComponent(entity); - force.position = transform.GetPosition(); - XMStoreFloat3(&force.direction, XMVector3Normalize(XMVector3TransformNormal(XMVectorSet(0, -1, 0, 0), XMLoadFloat4x4(&transform.world)))); + + XMMATRIX W = XMLoadFloat4x4(&transform.world); + XMVECTOR S, R, T; + XMMatrixDecompose(&S, &R, &T, W); + + XMStoreFloat3(&force.position, T); + XMStoreFloat3(&force.direction, XMVector3Normalize(XMVector3TransformNormal(XMVectorSet(0, -1, 0, 0), W))); + + force.range = force.range_local * max(XMVectorGetX(S), max(XMVectorGetY(S), XMVectorGetZ(S))); }); } void RunLightUpdateSystem( @@ -1992,6 +1999,8 @@ namespace wiSceneSystem XMStoreFloat4(&light.rotation, R); XMStoreFloat3(&light.direction, XMVector3TransformNormal(XMVectorSet(0, 1, 0, 0), W)); + light.range = light.range_local * max(XMVectorGetX(S), max(XMVectorGetY(S), XMVectorGetZ(S))); + switch (light.type) { case LightComponent::DIRECTIONAL: diff --git a/WickedEngine/wiSceneSystem.h b/WickedEngine/wiSceneSystem.h index 044f132cb..a996e4426 100644 --- a/WickedEngine/wiSceneSystem.h +++ b/WickedEngine/wiSceneSystem.h @@ -651,7 +651,7 @@ namespace wiSceneSystem }; LightType type = POINT; float energy = 1.0f; - float range = 10.0f; + float range_local = 10.0f; float fov = XM_PIDIV4; float shadowBias = 0.0001f; float radius = 1.0f; // area light @@ -662,6 +662,7 @@ namespace wiSceneSystem // Non-serialized attributes: XMFLOAT3 position; + float range; XMFLOAT3 direction; XMFLOAT4 rotation; XMFLOAT3 front; @@ -789,10 +790,11 @@ namespace wiSceneSystem int type = ENTITY_TYPE_FORCEFIELD_POINT; float gravity = 0.0f; // negative = deflector, positive = attractor - float range = 0.0f; // affection range + float range_local = 0.0f; // affection range // Non-serialized attributes: XMFLOAT3 position; + float range; XMFLOAT3 direction; void Serialize(wiArchive& archive, uint32_t seed = 0); diff --git a/WickedEngine/wiSceneSystem_Serializers.cpp b/WickedEngine/wiSceneSystem_Serializers.cpp index ffb36302a..0a6b610e9 100644 --- a/WickedEngine/wiSceneSystem_Serializers.cpp +++ b/WickedEngine/wiSceneSystem_Serializers.cpp @@ -454,7 +454,7 @@ namespace wiSceneSystem archive >> color; archive >> (uint32_t&)type; archive >> energy; - archive >> range; + archive >> range_local; archive >> fov; archive >> shadowBias; archive >> radius; @@ -469,7 +469,7 @@ namespace wiSceneSystem archive << color; archive << (uint32_t&)type; archive << energy; - archive << range; + archive << range_local; archive << fov; archive << shadowBias; archive << radius; @@ -522,14 +522,14 @@ namespace wiSceneSystem archive >> _flags; archive >> type; archive >> gravity; - archive >> range; + archive >> range_local; } else { archive << _flags; archive << type; archive << gravity; - archive << range; + archive << range_local; } } void DecalComponent::Serialize(wiArchive& archive, uint32_t seed) diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 09284de72..95f5a04d7 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 26; // minor bug fixes, alterations, refactors, updates - const int revision = 5; + const int revision = 6; long GetVersion() diff --git a/scripts/character_controller_tps.lua b/scripts/character_controller_tps.lua index e06766f1c..7c2b88232 100644 --- a/scripts/character_controller_tps.lua +++ b/scripts/character_controller_tps.lua @@ -14,8 +14,14 @@ Character = { target = INVALID_ENTITY, -- Camera will look at this location, rays will be started from this location, etc. idle_anim = INVALID_ENTITY, walk_anim = INVALID_ENTITY, + head = INVALID_ENTITY, + left_hand = INVALID_ENTITY, + right_hand = INVALID_ENTITY, + left_foot = INVALID_ENTITY, + right_foot = INVALID_ENTITY, face = Vector(0,0,1), -- forward direction velocity = Vector(), + velocityPrev = Vector(), ray = Ray(Vector(),Vector()), o = INVALID_ENTITY, -- collision prop with scene (entity) p,n = Vector(), -- collision props with scene (position,normal) @@ -39,6 +45,11 @@ Character = { self.idle_anim = scene.Entity_FindByName("idle") self.walk_anim = scene.Entity_FindByName("walk") + self.head = scene.Entity_FindByName("testa") + self.left_hand = scene.Entity_FindByName("mano_L") + self.right_hand = scene.Entity_FindByName("mano_R") + self.left_foot = scene.Entity_FindByName("avampiede_L") + self.right_foot = scene.Entity_FindByName("avampiede_R") local model_transform = scene.Component_GetTransform(self.model) model_transform.ClearTransform() @@ -54,37 +65,6 @@ Character = { scene.Component_Attach(self.target, self.model) end, - MoveForward = function(self,f) - local model_transform = scene.Component_GetTransform(self.model) - local target_transform = scene.Component_GetTransform(self.target) - - -- avoid falling outside the world - local velocityPrev = self.velocity; - self.velocity = self.face:Multiply(Vector(f,f,f)) - self.velocity.SetY(velocityPrev.GetY()) - self.ray = Ray(target_transform.GetPosition():Add(self.velocity),Vector(0,-1,0)) - self.o,self.p,self.n = Pick(self.ray, PICK_OPAQUE, ~self.layerMask) - if(self.o ~= INVALID_ENTITY) then - self.state = self.states.WALK - else - self.state = self.states.STAND - self.velocity = velocityPrev - end - - -- front block - local ray2 = Ray(target_transform.GetPosition(),self.face) - local o2,p2,n2 = Pick(ray2, PICK_OPAQUE, ~self.layerMask) - local dist = vector.Subtract(target_transform.GetPosition(),p2):Length() - if(o2 ~= INVALID_ENTITY and dist < 1.5) then - -- run along wall instead of going through it - local velocityLen = self.velocity.Length() - local velocityNormalized = self.velocity.Normalize() - local undesiredMotion = n2:Multiply(vector.Dot(velocityNormalized, n2)) - local desiredMotion = vector.Subtract(velocityNormalized, undesiredMotion) - self.velocity = vector.Multiply(desiredMotion, velocityLen) - end - - end, Jump = function(self,f) self.velocity = self.velocity:Add(Vector(0,f,0)) self.state = self.states.JUMP @@ -94,7 +74,7 @@ Character = { local target_transform = scene.Component_GetTransform(self.target) local savedPos = model_transform.GetPosition() model_transform.ClearTransform() - self.face = dir:Normalize().Transform(target_transform.GetMatrix()) + self.face = vector.Transform(dir:Normalize(), target_transform.GetMatrix()) self.face.SetY(0) self.face = self.face.Normalize() model_transform.MatrixTransform(matrix.LookTo(Vector(),self.face):Inverse()) @@ -104,7 +84,10 @@ Character = { model_transform.UpdateTransform() scene.Component_Detach(self.target) scene.Component_Attach(self.target, self.model) - self:MoveForward(f) + self.velocityPrev = self.velocity; + self.velocity = self.face:Multiply(Vector(f,f,f)) + self.velocity.SetY(self.velocityPrev.GetY()) + self.state = self.states.WALK end, Input = function(self) @@ -149,8 +132,10 @@ Character = { self.face.SetY(0) self.face=self.face:Normalize() input.SetPointer(self.savedPointerPos) + input.HidePointer(true) else self.savedPointerPos = input.GetPointer() + input.HidePointer(false) end end, @@ -174,6 +159,24 @@ Character = { self.state = self.states.STAND end + -- front block shoots multiple rays in front to try to find obstruction + local rotations = {0, 3.1415*0.3, -3.1415*0.3} + for i,rot in ipairs(rotations) do + local origin = target_transform.GetPosition() + local dir = vector.Transform(self.face, matrix.RotationY(rot)) + local ray2 = Ray(origin,dir) + local o2,p2,n2 = Pick(ray2, PICK_OPAQUE, ~self.layerMask) + local dist = vector.Subtract(origin,p2):Length() + if(o2 ~= INVALID_ENTITY and dist < 1) then + -- run along wall instead of going through it + local velocityLen = self.velocity.Length() + local velocityNormalized = self.velocity.Normalize() + local undesiredMotion = n2:Multiply(vector.Dot(velocityNormalized, n2)) + local desiredMotion = vector.Subtract(velocityNormalized, undesiredMotion) + self.velocity = vector.Multiply(desiredMotion, velocityLen) + end + end + -- check what is below the character self.ray = Ray(target_transform.GetPosition(),Vector(0,-1,0)) local pPrev = self.p @@ -182,8 +185,10 @@ Character = { self.p=pPrev -- if nothing, go back to previous position end - -- try to put water ripple if character is directly above water - local w,wp,wn = Pick(self.ray,PICK_WATER) + -- try to put water ripple if character head is directly above water + local head_transform = scene.Component_GetTransform(self.head) + local waterRay = Ray(head_transform.GetPosition(),Vector(0,-1,0)) + local w,wp,wn = Pick(waterRay,PICK_WATER) if(w ~= INVALID_ENTITY and self.velocity.Length()>0.1) then PutWaterRipple("../Editor/images/ripple.png",wp) end @@ -191,10 +196,10 @@ Character = { -- add gravity: self.velocity = vector.Add(self.velocity, Vector(0,-0.04,0)) - -- check if we are below the ground: + -- check if we are below or on the ground: if(model_transform.GetPosition().GetY() <= self.p.GetY() and self.velocity.GetY()<=0) then self.state = self.states.STAND - model_transform.Translate(vector.Subtract(self.p,model_transform.GetPosition())) + model_transform.Translate(vector.Subtract(self.p,model_transform.GetPosition())) -- snap back to last succesfully traced position self.velocity.SetY(0) -- don't fall below ground self.velocity = vector.Multiply(self.velocity, 0.8) -- slow down gradually on ground end @@ -220,7 +225,7 @@ ThirdPersonCamera = { self.camera = CreateEntity() local camera_transform = scene.Component_CreateTransform(self.camera) camera_transform.ClearTransform() - camera_transform.Translate(Vector(self.side_offset,self.height,-self.rest_distance)) + camera_transform.Translate(Vector(self.side_offset,self.height)) scene.Component_Attach(self.camera, character.target) end, @@ -228,30 +233,27 @@ ThirdPersonCamera = { if(self.character ~= nil) then local camera_transform = scene.Component_GetTransform(self.camera) local target_transform = scene.Component_GetTransform(self.character.target) - - local camTargetDiff = vector.Subtract(target_transform.GetPosition(), camera_transform.GetPosition()) + + -- Keep distance from player + local camPos = camera_transform.GetPosition() + local camTargetDiff = vector.Subtract(target_transform.GetPosition(), camPos) local camTargetDistance = camTargetDiff.Length() - - local use_correction = true + if(camTargetDistance < self.rest_distance) then + camera_transform.Translate(Vector(0,0,-(self.rest_distance - camTargetDistance))) + end - -- Cast a ray from the camera eye and check if it hits something other than the player... - local camRay = Ray(camera_transform.GetPosition(),camTargetDiff.Normalize()) - local camCollObj,camCollPos,camCollNor = Pick(camRay, PICK_OPAQUE, ~self.character.layerMask) - if(camCollObj ~= INVALID_ENTITY) then - -- It hit something, see if it is between the player and camera: - local camCollDiff = vector.Subtract(camCollPos, camera_transform.GetPosition()) - local camCollDistance = camCollDiff.Length() - if(camCollDistance < camTargetDistance) then - -- If there was something between player and camera, clamp camera position inside: - camera_transform.Translate(Vector(0,0,camCollDistance-0.1)) - use_correction = false + -- Cast ray from the camera eye and check if it hits something other than the player... + local rayDir = camTargetDiff.Normalize() + local camRay = Ray(camPos, rayDir) + local camCollObj,camCollPos,camCollNor = Pick(camRay, PICK_OPAQUE, ~self.character.layerMask) + if(camCollObj ~= INVALID_ENTITY) then + -- It hit something, see if it is between the player and camera: + local camCollDiff = vector.Subtract(camCollPos, camPos) + local camCollDistance = camCollDiff.Length() + if(camCollDistance < camTargetDistance) then + camera_transform.Translate(Vector(0,0,camCollDistance)) + end end - end - - if(use_correction and camTargetDistance < self.rest_distance) then - -- Camera is closer to target than rest distance, push it back some amount... - camera_transform.Translate(vector.Multiply(getDeltaTime() * 60, Vector(0,0,-self.correction_speed))) - end local cam = GetCamera() cam.TransformCamera(camera_transform) @@ -319,11 +321,6 @@ end -- Draw runProcess(function() - local head = scene.Entity_FindByName("testa") - local left_hand = scene.Entity_FindByName("mano_L") - local right_hand = scene.Entity_FindByName("mano_R") - local left_foot = scene.Entity_FindByName("avampiede_L") - local right_foot = scene.Entity_FindByName("avampiede_R") while true do @@ -347,15 +344,15 @@ runProcess(function() DrawBox(target_transform.GetMatrix()) -- Head bone - DrawPoint(scene.Component_GetTransform(head).GetPosition(),0.2, Vector(0,1,1,1)) + DrawPoint(scene.Component_GetTransform(player.head).GetPosition(),0.2, Vector(0,1,1,1)) -- Left hand bone - DrawPoint(scene.Component_GetTransform(left_hand).GetPosition(),0.2, Vector(0,1,1,1)) + DrawPoint(scene.Component_GetTransform(player.left_hand).GetPosition(),0.2, Vector(0,1,1,1)) -- Right hand bone - DrawPoint(scene.Component_GetTransform(right_hand).GetPosition(),0.2, Vector(0,1,1,1)) + DrawPoint(scene.Component_GetTransform(player.right_hand).GetPosition(),0.2, Vector(0,1,1,1)) -- Left foot bone - DrawPoint(scene.Component_GetTransform(left_foot).GetPosition(),0.2, Vector(0,1,1,1)) + DrawPoint(scene.Component_GetTransform(player.left_foot).GetPosition(),0.2, Vector(0,1,1,1)) -- Right foot bone - DrawPoint(scene.Component_GetTransform(right_foot).GetPosition(),0.2, Vector(0,1,1,1)) + DrawPoint(scene.Component_GetTransform(player.right_foot).GetPosition(),0.2, Vector(0,1,1,1)) -- Wait for the engine to render the scene diff --git a/scripts/dungeon_generator.lua b/scripts/dungeon_generator.lua index ee16fe2de..b67f150b2 100644 --- a/scripts/dungeon_generator.lua +++ b/scripts/dungeon_generator.lua @@ -62,7 +62,7 @@ dungeon={ local function GenerateDungeon(remaining, pos, rotY) remaining = remaining - 1 local rotMat = matrix.RotationY(rotY) - local transformMat = matrix.Multiply( rotMat, matrix.Multiply( matrix.Translation(pos), scalingMat ) ) + local transformMat = matrix.Multiply(rotMat, matrix.Multiply(matrix.Translation(pos), scalingMat)) -- Mark exit point if the generation ended and return from recursion if (remaining < 0) then @@ -77,14 +77,14 @@ dungeon={ if(select2 < 1) then --left turn if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,2)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/turnleft.wiscene",transformMat) - GenerateDungeon(remaining,pos:Add(Vector(-1,0,1).Transform(rotMat)),rotY-0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(-1,0,1):Transform(rotMat)),rotY-0.5*math.pi) else GenerateDungeon(remaining,pos,rotY) end elseif(select2 < 2) then --right turn if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,2)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/turnright.wiscene",transformMat) - GenerateDungeon(remaining,pos:Add(Vector(1,0,1).Transform(rotMat)),rotY+0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(1,0,1):Transform(rotMat)),rotY+0.5*math.pi) else GenerateDungeon(remaining,pos,rotY) end @@ -92,9 +92,9 @@ dungeon={ if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,2)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/tjunction.wiscene",transformMat) -- right - GenerateDungeon(remaining,pos:Add(Vector(1,0,1).Transform(rotMat)),rotY+0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(1,0,1):Transform(rotMat)),rotY+0.5*math.pi) -- left - GenerateDungeon(remaining,pos:Add(Vector(-1,0,1).Transform(rotMat)),rotY-0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(-1,0,1):Transform(rotMat)),rotY-0.5*math.pi) else GenerateDungeon(remaining,pos,rotY) end @@ -102,18 +102,18 @@ dungeon={ if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,2)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/crossjunction.wiscene",transformMat) -- right - GenerateDungeon(remaining,pos:Add(Vector(1,0,1).Transform(rotMat)),rotY+0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(1,0,1):Transform(rotMat)),rotY+0.5*math.pi) -- left - GenerateDungeon(remaining,pos:Add(Vector(-1,0,1).Transform(rotMat)),rotY-0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(-1,0,1):Transform(rotMat)),rotY-0.5*math.pi) -- straight - GenerateDungeon(remaining,pos:Add(Vector(0,0,2).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(0,0,2):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end else --straight block if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,2)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/block.wiscene",transformMat) - GenerateDungeon(remaining,pos:Add(Vector(0,0,2).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(0,0,2):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end @@ -123,28 +123,28 @@ dungeon={ if( select2 < 20 ) then --small room left if CheckSegmentCanBePlaced(AABB(Vector(-5,0,0),Vector(1,2,6)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/smallroomleft.wiscene",transformMat ) - GenerateDungeon(remaining,pos:Add(Vector(-5,0,5).Transform(rotMat)),rotY-0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(-5,0,5):Transform(rotMat)),rotY-0.5*math.pi) else GenerateDungeon(remaining,pos,rotY) end elseif( select2 < 30 ) then --odd corridor if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(3,2,8)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/oddcorridor.wiscene",transformMat ) - GenerateDungeon(remaining,pos:Add(Vector(2,0,8).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(2,0,8):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end elseif( select2 < 60 ) then --up corridor if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,4,6)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/upcorridor.wiscene",transformMat ) - GenerateDungeon(remaining,pos:Add(Vector(0,2,6).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(0,2,6):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end else --corridor if CheckSegmentCanBePlaced(AABB(Vector(-1,0,0),Vector(1,2,6)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/corridor.wiscene",transformMat ) - GenerateDungeon(remaining,pos:Add(Vector(0,0,6).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(0,0,6):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end @@ -153,11 +153,11 @@ dungeon={ if CheckSegmentCanBePlaced(AABB(Vector(-4,0,0),Vector(4,8,8)).Transform(transformMat)) then LoadModel(modelpath .. "dungeon/room.wiscene",transformMat ) -- right - GenerateDungeon(remaining,pos:Add(Vector(4,0,4).Transform(rotMat)),rotY + 0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(4,0,4):Transform(rotMat)),rotY + 0.5*math.pi) -- left - GenerateDungeon(remaining,pos:Add(Vector(-4,0,4).Transform(rotMat)),rotY - 0.5*math.pi) + GenerateDungeon(remaining,pos:Add(Vector(-4,0,4):Transform(rotMat)),rotY - 0.5*math.pi) -- straight - GenerateDungeon(remaining,pos:Add(Vector(0,0,8).Transform(rotMat)),rotY) + GenerateDungeon(remaining,pos:Add(Vector(0,0,8):Transform(rotMat)),rotY) else GenerateDungeon(remaining,pos,rotY) end