Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] Compound shapes (Cylinder)

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Nov 2018 22:26 Edited at: 23rd Nov 2018 01:39
**** EDIT : I THINK THIS IS NOT WORKING CORRECTLY **
I'm looking at it further


Before i start with the shapes i would like to talk about the physics scale. This can be set when you create the physics environment.
Create3DPhysicsWorld( scaleFactor )
The default scale factor is 40. For things to work at this scale they have to be pretty big. Much larger than what 3D programs produce by default.

The scale factor in this example is 8. You can change that to a larger number, say 30, and you will see tunneling.

I have spent some time trying to get to grips with compound shapes and thought i would share my results here.
The attached example is a hoop or torus shape.



What the program has is the torus model and a model of a cylinder aligned to one of the 12 segments around the torus.
It first gets the size of the segment using the GetObjectMeshSizeMin/Max functions.
Then it fixes the segment to the torus and rotates the torus (in 30 degree increments) to extract the position and rotation of that segment within the torus.

It is here where the documentation is a little misleading as it states;
"positionVec3 - The vector Id of the vector with the world position for the center of the shape."

This is only true when the torus is positioned at 0,0,0. So the position of the segment is really relative to the position of the Torus, not world co-ordinates.

It is also important to remember that the length of the segment (cylinder) lies along the x-axis, so we set the axis (axis - 0 = X axis, 1 = Y axis, 2 = Z axis) value to 0

Anyway this and not understanding the scale factor has always scared me away from 3D physics so it's nice to get a handle on these things.
I sure there's a hell of a lot more i need to understand before i can make anything decent.

The demo will step through as it extracts the data for each segment. The you can then press the spacebar to drop the hoop.

Hope this helps
If you have any questions or input, critical or otherwise, feel free to ask

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

puzzler2018
User Banned
Posted: 22nd Nov 2018 22:45 Edited at: 22nd Nov 2018 22:46
thats awesome, great work always

gives me an idea for mesh memblock creation of something like this - if thats ok
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Nov 2018 22:48 Edited at: 22nd Nov 2018 22:48
Sounds like a great idea
puzzler2018
User Banned
Posted: 22nd Nov 2018 22:54
thanks - your version of a torus dramatically reduces FPS. i wouldnt like to think how many polygons make a true torus buts im sure its near 1000
puzzler2018
User Banned
Posted: 22nd Nov 2018 23:00 Edited at: 22nd Nov 2018 23:01
What this could also acheive is a ride to go through / inside it - we just have to invert the faces to be internal - it be like a tunnel ride.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 22nd Nov 2018 23:40
Quote: "thanks - your version of a torus dramatically reduces FPS. i wouldn't like to think how many polygons make a true torus but i'm sure its near 1000"


My version of the torus has 144 faces. I get a solid 29.9999 fps. At the start when it is creating the compound shape there is a programmed delay, sleep(1000),between frames so you can see it getting built
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Nov 2018 00:41 Edited at: 23rd Nov 2018 02:26
If you have a look you can see that the torus is not touching the cone which tells me my compound shape isn't working. I tried with spheres and it works (Thanks fubar)



Very frustrating

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Nov 2018 03:08 Edited at: 23rd Nov 2018 03:10
In order to try and understand what is going on i simplified the shape to just 4 cylinders at 0, 90, 180 and 270
I then dropped a whole pile of very small spheres over the shape to see if i could see the hit shape emerge
This is what i got;



As you can see there are areas at top, right, bottom and left (Orange rectangles) where the little spheres would not go.
So i think my hit shapes are somehow not lining up with the shape of my torus

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Nov 2018 04:23 Edited at: 23rd Nov 2018 04:24
When i use 12 segments you can see the "halo" between the inner taurus and the spheres. You can also see it's lifted off the surface so for some reason it's thinking the cylinder is bigger than it actually is (i think)

Attachments

Login to view attachments
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 23rd Nov 2018 20:47
Awesome!

[/url]
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 23rd Nov 2018 22:34
Not awesome at all! It's not working properly. It's driving me nuts!!

Attached is my current progress
You can toggle the type of compound shape by pressing H (Sphere, Cylinder, Box or Capsule). Sphere is the only shape that works as i would expect it too

You can see, when the compound shape is not a sphere, the hoop will sit away from the cone when it falls

An interesting thing, that i'm probably doing wrong, is when i set the shape of the cone using SetObjectShapeCone(), It makes what appears to be a collision shape that is larger than the actual object. When i set it's shape using SetObjectShapeStaticPolygon() the collision shape appears to be the right size.
You can see this if you set the compound shape to sphere and the Cone shape to cone

Any help at all would be greatly appreciated. I am at a total loss here

Attachments

Login to view attachments
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 23rd Nov 2018 23:50 Edited at: 24th Nov 2018 00:12
This post has been marked by the post author as the answer.
I find your effort awesome, the problem always finds it's champion.
Math3d and Basic3d are fun topics!
I can also confirm, that there is some interesting behavior inside AppGameKit based on some origin/ pivot point problems,
but I met it at another place and could not track it down.

Related to your question:
Just guessing:



maybe the unique scale factors of your objects?:

this is the original scale between hoop.obj, segment.obj, segment1.obj as seen in AGK:

as you see, segment and segment1 are slightly smaller that the hoop.

[/url]

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 24th Nov 2018 05:31 Edited at: 24th Nov 2018 06:31
Thanks for your effort jake, i really appreciate it.

I have tried various sizes for the segment from slightly larger to slightly smaller and everything in between

Ok so setting the shape position at 2.0 works for the inner shape bout what about the outside? I think the collision shape will create a halo around the hoop

EDIT: As a hack i've made the segment super thin so it sits just inside the outer edge of the hoop. Messy, but it works.

Thanks heaps for your help jack. I was tearing my hair out
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Nov 2018 03:53
To demonstrate that moving the shape further away from the center solves the inner shape but creates an outer halo.
The red cylinder is like a kinematic mouse. You can knock the hoop around.
I think i will submit this a a bug and see what they say. What do you think?

Attachments

Login to view attachments
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Nov 2018 07:54
I get an error at SetObjectShapeCone(ConObj, 1) when I press "c" "Object ID is not valid" tried setting it global
But from what I have seen just changing the hoop objects it appears to be working but its a small enough
program so I don't see any reason why it shouldn't be submitted as a bug if its not behaving properly. After
saying that tho Paul has been commenting on allot of posts lately bug testing im surprised he just hasn't
seen this post yet but im sure he is very busy and doesn't always get a chance to check all forum posts.
fubar
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 25th Nov 2018 09:09 Edited at: 25th Nov 2018 09:11
Yeah. It's just for showing that moving the compound shape away from the center will cause a halo around the shape.
Just hit spacebar and then you can use the mouse to move the hoop. Dont press "C"
When i played with it i thought of air hockey for the carnival games

Login to post a reply

Server time is: 2024-11-23 12:13:54
Your offset time is: 2024-11-23 12:13:54