Jump to content

friction between objects


nelsoncs
 Share

Recommended Posts

Can objects interact with friction in Leadwerks?

 

As an example, If I drop one cube ontop of another, when I rotate the bottom cube, the top one seems to have no actual interaction with the lower one and does not rotate.

 

I f there was friction between them, I would expect the top cube to rotate based on its points of contact with the lower cube.

 

I have tried SetFriction for both objects and various collision types ( probably not exhaustive). Any suggestions on how to accomplish this?

Link to comment
Share on other sites

@ cassius there is a entity:SetFriction command in LE3: http://www.leadwerks.com/werkspace/page/documentation/_/command-reference/entity/entitysetfriction-r142

 

@nelsoncs your cubes have to have a physics body, their masses set greater than 0 or the engine thinks the mesh is static, and you have to use PhysicsSetRotation/PhysicsSetPosition or the physics get broken

function App:Start()

self.window = Window:Create()

self.context = Context:Create(self.window)

self.world = World:Create()

self.camera = Camera:Create()

 

self.camera:Move(0,2,-4)

self.light = DirectionalLight:Create()

self.light:SetRotation(35,35,0)

 

self.ground = Model:Box(10,.1,10)

self.ground:SetColor(0,1,0,1)

local shape = Shape:Box(0,0,0, 0,0,0, 10,.1,10)

self.ground:SetShape(shape)

shape:Release()

 

self.model1 = Model:Box()

self.model1:SetColor(1,0,0,1)

self.model1:SetPosition(0,1,0)

self.model1:SetMass(1)

local shape = Shape:Box(0,0,0, 0,0,0, 1,1,1)

self.model1:SetShape(shape)

shape:Release()

 

self.model2 = Model:Box()

self.model1:SetColor(1,.5,0,1)

self.model2:SetPosition(0,2.0,0)

self.model2:SetMass(1)

local shape = Shape:Box(0,0,0, 0,0,0, 1,1,1)

self.model2:SetShape(shape)

shape:Release()

 

rotY = 0

return true

end

 

function App:Loop()

if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end

 

self.model1:PhysicsSetRotation(0,rotY,0,.1)

rotY = rotY + 1

if rotY==360 then rotY = 0 end

 

Time:Update()

self.world:Update()

self.world:Render()

self.context:Sync()

 

return true

end

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

"you have to use PhysicsSetRotation/PhysicsSetPosition" <----- this is absolutely correct, thanks for the info. Without these calls a moving platform has no friction and a very odd collision shape. You can move the platform out from under objects and they hang in mid-air.

Link to comment
Share on other sites

addendum: using "PhysicsSet....." made it possible to have a moving surface with objects on top that showed friction and moved reasonably well with the underlying surface. rotating the underlying surface was very very laggy.

 

adding a .phy shape file to the model breaks everything and one can no longer set the rotation or position. so, my current conclusion is I have to use a different physics library, which I am disinclined to do or to drop the project altogether. this is rather disappointing.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...