aabb

In Unity3D, what would “setting” the bounds of a mesh do or achieve?

旧城冷巷雨未停 提交于 2019-12-24 01:34:13
问题 In a Unity code base, I saw this: // the game object currently has no mesh attached MeshFilter mFilter = gameObject.AddComponent<MeshFilter>(); gameObject.AddComponent<MeshRenderer>(); // no problem so far mFilter.mesh = MakeASmallQuadMesh(0.1f); // great stuff mFilter.mesh.bounds = SomeSpecificBounds(); // what ? The function "MakeASmallQuadMesh" has the usual completely normal code for making a mesh, so Mesh mesh = new Mesh(); mesh.SetVertices(verts); mesh.SetIndices(indices); mesh.SetUVs(0

Calculate bounding box of arbitrary pixel-based drawing

蹲街弑〆低调 提交于 2019-12-20 01:09:05
问题 Given a contiguous drawing of arbitrary pixels (e.g. on an HTML5 Canvas) is there any algorithm for finding the axis-aligned bounding box that is more efficient than simply looking at every pixel and recording the min/max x/y values? 回答1: Just scanline from top left to right and down to get y top,and similar algorithm with different directions for the rest. Edit by Phrogz: Here's a pseudo-code implementation. An included optimization ensures that each scan line does not look at pixels covered

Fast axis aligned cell traversal algorithm

我只是一个虾纸丫 提交于 2019-12-19 03:55:30
问题 Given an axis aligned square divided in four cells of equal size A, B, C and D. Given a line segment going from point s1 to point s2. What is the fastest way to find the cells traversed by the segment (if any), sorted by traversal order ? In the example above, the correct results are : Segment 1 : [D] Segment 2 : [A, B] Segment 3 : [C, D, B] Segment 4 : [] Segment 5 : [C] 回答1: You can try "A Fast Voxel Traversal Algorithm for Ray Tracing" by Amanatides and Woo. It is intended to deal with big

Fast axis aligned cell traversal algorithm

倾然丶 夕夏残阳落幕 提交于 2019-12-19 03:55:12
问题 Given an axis aligned square divided in four cells of equal size A, B, C and D. Given a line segment going from point s1 to point s2. What is the fastest way to find the cells traversed by the segment (if any), sorted by traversal order ? In the example above, the correct results are : Segment 1 : [D] Segment 2 : [A, B] Segment 3 : [C, D, B] Segment 4 : [] Segment 5 : [C] 回答1: You can try "A Fast Voxel Traversal Algorithm for Ray Tracing" by Amanatides and Woo. It is intended to deal with big

Collision test between a triangle and a rectangle (AABB) in 2D

☆樱花仙子☆ 提交于 2019-12-12 19:08:30
问题 I've spent a good amount of time getting intersections working correctly between various 2D shapes (circle-circle, circle-tri, circle-rect, rect-rect - a huge thanks to those who've solved such problems from which I drew my solutions from) for a simple project and am now in the process of trying to implement an triangle-AABB intersection test. I'm a bit stuck however. I've tried searching online and thinking it through however I've been unable to get any ideas. The thing that's given me the

AABB in a game with moveable and rotateable characters/objects/etc

為{幸葍}努か 提交于 2019-12-10 21:46:12
问题 In those day I'm creating my very first 3d game and I've ran into couple of problems. I read about AABB intersectioning and the idea of building trees from it, but the one thing that I couldn't understand is, if my "character" rotates during the game, the concept of the Axis-aligned isn't preserved! I've checked a couple of libraries (like oz-collide, OPCODE, and more), and I've seen that the implementations were made for static objects, because it uses the boxes without an origin (for non

Calculating an AABB for a transformed sphere

喜夏-厌秋 提交于 2019-12-04 18:00:30
问题 I have a sphere represented in object space by a center point and a radius. The sphere is transformed into world space with a transformation matrix that may include scales, rotations, and translations. I need to build a axis aligned bounding box for the sphere in world space, but I'm not sure how to do it. Here is my current approach, that works for some cases: public void computeBoundingBox() { // center is the middle of the sphere // averagePosition is the middle of the AABB //

Calculating an AABB for a transformed sphere

怎甘沉沦 提交于 2019-12-03 11:30:55
I have a sphere represented in object space by a center point and a radius. The sphere is transformed into world space with a transformation matrix that may include scales, rotations, and translations. I need to build a axis aligned bounding box for the sphere in world space, but I'm not sure how to do it. Here is my current approach, that works for some cases: public void computeBoundingBox() { // center is the middle of the sphere // averagePosition is the middle of the AABB // getObjToWorldTransform() is a matrix from obj to world space getObjToWorldTransform().rightMultiply(center,

Calculate bounding box of arbitrary pixel-based drawing

心已入冬 提交于 2019-12-01 18:55:43
Given a contiguous drawing of arbitrary pixels (e.g. on an HTML5 Canvas) is there any algorithm for finding the axis-aligned bounding box that is more efficient than simply looking at every pixel and recording the min/max x/y values ? adrix89 Just scanline from top left to right and down to get y top,and similar algorithm with different directions for the rest. Edit by Phrogz: Here's a pseudo-code implementation. An included optimization ensures that each scan line does not look at pixels covered by an earlier pass: function boundingBox() w = getWidth() # Assuming graphics address goes from [0

Fast axis aligned cell traversal algorithm

瘦欲@ 提交于 2019-11-30 22:50:26
Given an axis aligned square divided in four cells of equal size A, B, C and D. Given a line segment going from point s1 to point s2. What is the fastest way to find the cells traversed by the segment (if any), sorted by traversal order ? In the example above, the correct results are : Segment 1 : [D] Segment 2 : [A, B] Segment 3 : [C, D, B] Segment 4 : [] Segment 5 : [C] You can try "A Fast Voxel Traversal Algorithm for Ray Tracing" by Amanatides and Woo. It is intended to deal with big grids, but the principle can be useful for your application too. The following can be done using only a