Jump to content

beo6

Developers
  • Posts

    862
  • Joined

  • Last visited

Everything posted by beo6

  1. a Realtime Strategy: The models are of course placeholders.
  2. wait wait. its ok when you remove the attribute of the entity. But removing the whole Quat class is a bit too much. And also it seems to work creating a Quat in lua. And how are we supposed to make something like this without a Quat? http://www.leadwerks.com/werkspace/topic/8487-question-about-physic/page__st__20#entry66616
  3. +1 However you can have a look at my probably very bad script here: http://www.leadwerks.com/werkspace/topic/8487-question-about-physic/page__st__20#entry66616
  4. In the Documentation quaternion is documented as a entity attribute. However it has Vec3 as Type? Is that really correct? Also i wasn't successful even getting the quaternion value of an entity: System:Print("entity quaternion:"..self.entity.quaternion:ToString()) --------------------------- Error --------------------------- attempt to index field 'quaternion' (a nil value) --------------------------- OK ---------------------------
  5. Hello, since it seems Quaternions exist they should be added to the Documentation.
  6. Hello, Yes SetRotation accepts a Quad. I think i got it working: --Private values Script.minTargetDistance = 1.0 function Script:Start() self.targetPos = self.entity:GetPosition() -- create pivot that is the real controller self.pivot = Pivot:Create() self.pivot:SetPosition(self.entity:GetPosition(true), true) self.pivot:SetMass(1) self.pivot:SetPhysicsMode(Entity.CharacterPhysics) self.pivot:SetCollisionType(Collision.Character) self.pivot:SetPickMode(0) self.entity:SetPickMode(0) self.entity:SetNavigationMode(true, true) self.originalInclinationQuat = Quat() end function Script:GoToPosition( pos ) self.targetPos = Vec3(pos.x, pos.y, pos.z) if self.pivot:GoToPoint(pos, self.speed, self.acceleration) then --System:Print("unit "..self.entity:GetKeyValue("name", "").." responded. ") else self.pivot:Stop() --System:Print("unit "..self.entity:GetKeyValue("name", "").." cannot go there. ") end end function Script:UpdateWorld() -- set model position to pivot position self.entity:SetPosition(self.pivot:GetPosition(true), true) -- disable model picking self.entity:SetPickMode(0) local world = World:GetCurrent() local pickinfo = PickInfo() local pivotPos = self.pivot:GetPosition() local rayStart = Vec3(pivotPos.x, pivotPos.y+1, pivotPos.z) local rayEnd = Vec3(rayStart.x, rayStart.y-50, rayStart.z) -- pick the ground normal for rotation if (world:Pick(rayStart,rayEnd,pickinfo,0.1,true,Collision.Scene)) then local interpolateSpeed = 0.07 local terrainNormal = pickinfo.normal local localYRel = terrainNormal.y local localY = Vec3( 0, localYRel, 0 ) local weight = 0.1 local newNormal = localY * ( 1 - weight ) + terrainNormal * weight local inclinationAngle = Math:ACos(localY:Dot(newNormal)) local newNormalCross = localY:Cross( newNormal ) local inclinationAxis = newNormalCross:Normalize() inclinationAxis = inclinationAxis:Inverse() --not exactly sure why local inclination = Quat( inclinationAngle, inclinationAxis ) local inclinationSlerp = self.originalInclinationQuat:Slerp( inclination, interpolateSpeed / Time:GetSpeed() ) self.entity:SetRotation(inclinationSlerp) self.originalInclinationQuat = inclinationSlerp -- save interpolated quaternion --turn model to rotation of controller local pivotRotation = self.pivot:GetRotation(true) self.entity:Turn(0,pivotRotation.y,0) end -- reenable model picking self.entity:SetPickMode(Entity.SpherePick) local selfPosition = self.entity:GetPosition(true) -- is entity near destination stop pathfinding if selfPosition:DistanceToPoint(self.targetPos) < self.minTargetDistance then self.pivot:Stop() --System:Print("unit "..self.entity:GetKeyValue("name", "").." reached destination. ") end end It is by no means perfect but it gets the job done for me until a better way is found by someone who is better than me which should not be hard. //Edit: added interpolation to terrain alignment
  7. thanks Rick for adding it. However you added the link to the thread-start. But all experiments me and other did there are not really working. Now it looks like the link contains the solution.
  8. Please add a tutorial how to align a character controller to the ground. See some experiments about it here: http://www.leadwerks.com/werkspace/topic/8487-question-about-physic/
  9. Hello, i just saw some code from Ogre3D that looked to me like almost the same commands as Leadwerks has, so i ported it over: local terrainNormal = pickinfo.normal local localY = self.entity:GetRotation(true) local weight = 0.10 local newNormal = localY * ( 1 - weight ) + terrainNormal * weight local inclinationAngle = Math:ACos(localY:Dot(newNormal)) if (inclinationAngle ~= 0.0) then local inclinationAxis = Vec3( localY:Cross( newNormal) ).Normalize() --local inclination = Vec3( inclinationAngle, inclinationAxis ) --not exactly sure how to create a Quaternion local inclination = Quat( inclinationAngle, inclinationAxis ) self.entity:SetRotation(inclination) end but beside that i am not sure how a quaternion is now exactly represented in LE and that it seems it crashes on the :Cross() function from a Vector i had no luck.
  10. See the Steam refund policy: https://support.steampowered.com/kb_article.php?ref=8360-WEJC-2625#refund But you might still try to contact the steam support and explain that your hardware is not compatible. Maybe they do it.
  11. I think that makes sense since it seems the faces of the terrain are rotated on the other side of the hill. Do we have something like Quaternion.FromToRotation() in the Unity Engine? http://answers.unity3d.com/questions/8867/how-to-get-quaternionfromtorotation-and-hitnormal.html
  12. as far as i have read the studio license will allow export of mo-cap data.
  13. seen this for facial animation? http://www.indiegogo.com/projects/facerig/ don't know how good it will be. but only 11 hours left.
  14. Hello, i got it half working now. here is the script: function Script:Start() -- create pivot that is the real controller self.pivot = Pivot:Create() self.pivot:SetPosition(self.entity:GetPosition(true), true) self.pivot:SetMass(1) self.pivot:SetPhysicsMode(Entity.CharacterPhysics) self.pivot:SetCollisionType(Collision.Character) end function Script:UpdateWorld() -- set model position to pivot position self.entity:SetPosition(self.pivot:GetPosition(true), true) -- disable model picking self.entity:SetPickMode(0) local world = World:GetCurrent() local pickinfo = PickInfo() local rayStart = self.pivot:GetPosition() local rayEnd = Vec3(rayStart.x, rayStart.y-50, rayStart.z) -- pick the ground normal for rotation if (world:Pick(rayStart,rayEnd,pickinfo,0,true,Collision.Scene)) then local v = Vec3(pickinfo.normal.x,pickinfo.normal.y,pickinfo.normal.z) -- align to ground normal if (pickinfo.normal) then self.entity:AlignToVector(v,1,0.3) end System:Print("entityPick normal.x:"..pickinfo.normal.x) System:Print("entityPick normal.y:"..pickinfo.normal.y) System:Print("entityPick normal.z:"..pickinfo.normal.z) end local pivotRotation = self.pivot:GetRotation(true) local modelRotation = self.entity:GetRotation(true) -- overwrite driving direction rotation with pivot rotation self.entity:SetRotation(modelRotation.x, pivotRotation.y, pivotRotation.z, true) -- reenable model picking self.entity:SetPickMode(Entity.SpherePick) end However it only works on one side of a hill. the other side of a hill still rotates the model but in the wrong direction. I need to somehow invert the rotation when on the other side. Anyone an idea?
  15. I am not sure if that is meant here so i might be wrong. But i think it would be nice to have the possibility to flaten terrain by code ingame. Since i am working a bit on realtime strategy this would be nice when placing buildings on terrain. Not sure if that is possible though.
  16. i don't use C++ at the moment. i think something like this should work: local world = World:GetCurrent() local pickinfo = PickInfo() local rayStart = self.entity:GetPosition() local rayEnd = Vec3(rayStart.x, rayStart.y-50, rayStart.z) if (world:Pick(rayStart,rayEnd,pickinfo,0,true,Collision.Scene)) then self.entity:AlignToVector(pickinfo.normal,1) end however i just get a flickering rotation. Maybe the GoToPoint method overwrites the rotation?
  17. i don't understand. Which perspective view?
  18. The Sound class is nothing else than a more easy use of the Source class: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/source/ there you have all commands you might need.
  19. MajorAF: i don't think a Video just for adding a single command to a code is necessary. That you see blackness is correct when you set the minimum and maximum value to the same number. If you add a camera in the editor you can see in the camera tab that the default value is min: 0.1 and max: 1000. So if you want to have a higher viewing range you need to set max higher than 1000. If you create your camera by code you need to use the SetRange command. So most likely this line right after you create your camera: self.camera:SetRange(0.1,2000) -- double the viewing range
  20. Have you tried self.camera:SetRange()? http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/camera/camerasetrange-r203
  21. I agree to rick. It would be nice if the path would be accessible. But another idea: Can't we use PickInfo.triangle and entity:AlignToVector or something like that to align it to the ground? In my testing it looked like it might work but i would have to play with it a bit more.
  22. i agree to Rick. chopping wood on a tree is not much different than shooting a gun at an enemy. But always try to have it as general as possible. What i mean with that try to avoid calling a function inside the player script from the entity the player has hit. This will save you from having to change all entity scripts when you change something small in your player. So just return to the player what the player should actually change. like adding 10 wood and don't change the player.wood value from inside the tree. i hope that was understandable.
  23. Hello again. i got it working now with going through all entities of the world. So far the speed is good. Will need to see how it goes when more entities are there. Thanks again
  24. Thanks everyone. I really appreciate the help. I tested around and i think at least ForEachVisibleEntityDo is bugged. See my bugreport: http://www.leadwerks.com/werkspace/topic/8457-crash-on-foreachvisibleentitydo-when-entity-is-too-far-away/ I will see if i can find out why ForEachEntityInAABBDo didn't worked for me. But for now i am stuck until the bug is fixed. Or i just go over all entites of the world. Must see how fast that is.
  25. Hello, sorry that i only got to try it out today. Unfortunately i again stumbled over an issue. Whenever i call world:ForEachVisibleEntityDo(self.entity,"Callback",context) inside the entity script i get the error "Assert failed." The Function "Callback" is empty so there should be no error: function Callback(camera,entity, extra) --nothing here end inside the App.lua it just crashes with no error. Also the example of the function looks a bit odd and copy/pasted from the ForEachEntityInAABBDo function. For example there is the unused aabb variable and the description talks about specifying an aabb but there is no parameter for it.
×
×
  • Create New...