Hello,
I'm trying to create some clothes in a game but I found a strange behaviour. Indeed it's about scaling and then positionning a cloth object, it seems to be a problem.
PROBLEM : if you are scaling a cloth object (scale object), the position of the object (phy set cloth position) is also scaled. Don't place the cloth object at the origin point (0,0,0) to understand this problem.
EXAMPLE WITHOUT SCALING:
A cloth object is created and positionned (10,10,0). You can see in the code below that the cloth is correctly positionned.
phy start
sync on
phy set gravity 0,0,0
`Floor
make object box 1,1000,1,1000
color object 1,rgb(0,255,0)
`Cloth
phy make cloth 2
phy set cloth dimensions 2, 10, 10, 0.2
phy set cloth position 2, 10, 10, 0
phy set cloth rotation 2, 90, 0, 0
phy build cloth 2
`Spheres
make object sphere 3,5 : position object 3,10,10,0
make object sphere 4,5 : position object 4,100,100,0
position camera 80, 40,-250
do
set cursor 0,0
print "Cloth initial position (10,10,0)"
print "First sphere : position (10,10,0) <- cloth position without scaling"
print "Second sphere : position (100,10,0) <- cloth position with scaling (x10)"
phy update
sync
loop
EXAMPLE WITH SCALING
I'm now scaling my cloth object 10 times because it's too small in my level. The object must be positionned at the same position but it's wrong.
The object is scaled 10 times so its position is also multiplied by 10. Initial position (10,10,0) ==> (100,100,0). Take a look below :
phy start
sync on
phy set gravity 0,0,0
`Floor
make object box 1,1000,1,1000
color object 1,rgb(0,255,0)
`Cloth
phy make cloth 2
phy set cloth dimensions 2, 10, 10, 0.2
phy set cloth position 2, 10, 10, 0
phy set cloth rotation 2, 90, 0, 0
phy build cloth 2
scale object 2,1000,1000,1000
`Spheres
make object sphere 3,5 : position object 3,10,10,0
make object sphere 4,5 : position object 4,100,100,0
position camera 80, 40,-250
do
set cursor 0,0
print "Cloth initial position (10,10,0)"
print "First sphere : position (10,10,0) <- cloth position without scaling"
print "Second sphere : position (100,10,0) <- cloth position with scaling (x10)"
phy update
sync
loop
EDIT : ATTACHING A CLOTH
There is a problem with positions and scaling so it's really difficult to attach a scaled cloth to another object. You can try to make an attached banner and then to scale it to see that it's not working.
Are you agree with this or is there something wrong ?
Coding is dangerous for health ...