Home › Forums › Programming › collision detection
Tagged: physics
- This topic has 11 replies, 3 voices, and was last updated 1 year, 7 months ago by kdv.
-
AuthorPosts
-
2023-04-06 at 6:31 pm #61811bigmike814Customer
Hello,
I’m working with the collision detection in the physics puzzle and have come across an issue that I know can be resolved, but I’m not sure of the best way to go about it.
The first issue is the collision detection library is storing my object positions in the wrong way. It has y as z and also inverse.
The other issue is that it seems to be set for a 2m x 2m cube. I am able to fix this by going in and adjusting the code in the visual_logic.js file, but I will need to use it on more than just one size, so just changing the cube won’t resolve my issue.
// do not allow empty-sized shapes
size.x = size.x || 0.5;
size.y = size.y || 0.5;
size.z = size.z || 0.5;if (shape == ‘BOX’) {
var geometry = new Ammo.btBoxShape(new Ammo.btVector3(
size.x * 0.5, size.y * .65, size.z * .9));
} else if (shape == ‘CAPSULE’)It looks like the Arcade Racing game was able to assign the items and then give each item a unique size.
// Vehicle contants
var chassisWidth = 1.0;
var chassisHeight = 0.4;
var chassisLength = 3.6;
var massVehicle = 800;But there is more going on here than what I need and am not sure on how to set it up for just the ghost collision detection.
Here is the issue I am having. To see the issue, point the move the building to view the right wall (brown wall) and open the doors/window accordion and click the add window button (no need to select a size).
I’m having issues uploading to the website. Will post it when I get it uploaded if it is needed.
Thanks in advance!
2023-04-06 at 10:00 pm #61812kdvParticipantThe first issue is the collision detection library is storing my object positions in the wrong way. It has y as z and also inverse.
It’s not an issue. The native coordinate system for THREE.js/V3D.js is
Y-Up-Right
The rest is hard to get what are talking about. Even with the example…
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-04-06 at 10:44 pm #61814bigmike814CustomerI had a feeling it had something to do with that.
You can see that the collision isn’t detected when the rectangles actually collide. If I’m using 2×2 cubes they will detect precisely on impact. It looks like the collision detection is set at a 2m X 2m cube rather than the actual size of the box.
I can fix this by declaring the dimensions I need in the visual_logic.js script, but it’s a pain to have to do this every time I update the puzzles. It looks like they added exec code into the puzzle for the Arcade Racing that allowed them to set the size of the chassis and other items.
2023-04-06 at 10:54 pm #61815kdvParticipantIt looks like the collision detection is set at a 2m X 2m cube rather than the actual size of the box.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-04-06 at 11:46 pm #61816bigmike814Customerthis is using the physics puzzle? or that bounding box?
Maybe it’s because my coordinates are set wrong. I’ll have to set my blender to Y up and test again.
2023-04-07 at 12:11 am #61817kdvParticipantthis is using the physics puzzle?
Yes
BBoxes are here https://v3d.net/g15I’ll have to set my blender to Y up and test again.
There is no need to do it.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-04-07 at 12:22 am #61818bigmike814Customerthis might better show the issue I’m running into. I tried setting the Y up and rotating it and it still isn’t working.
2023-04-07 at 12:24 am #61819kdvParticipantPerhaps, your problem is in scaling or morphing, but definitely not in coordinate systems.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
2023-04-07 at 12:25 am #61820bigmike814Customercan you send that to me so I can see what I am doing wrong?
2023-04-07 at 7:40 am #61830Alexander KovelenovStaffHi, the are two things you should pay attention when using physics:
1) In JavaScript the coordinate system is different. Contrary to Blender/Max Y axis looks Up, not Z. See here for more info.
2) You should always apply scaling to all physics objects in the modelling suite.
2023-04-07 at 3:03 pm #61845bigmike814CustomerThanks Alex and KDV! You guys are a big help.
This works for everything that is box shaped, but I do have a couple items that will be rectangle. Is there a way to set the scale on that without dipping into the visual_logic script? I can make it work if it is too complicated by calling those objects a capsule or other item and assigning the proper scale in the visual_logic when I’m ready to go live, but just wondering.
2023-04-07 at 3:11 pm #61846kdvParticipantA box doesn’t mean a cube. It works with rectangular boxes too. And with meshes, and other shapes. Otherwise the simulation wouldn’t work.
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
-
AuthorPosts
- You must be logged in to reply to this topic.