Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About NullStar

  • Rank

Personal Information

  • Role
    Amateur / Hobbyist
  • Interests


  • Steam

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. NullStar

    Adding squared values

    I think I did come up with an alternative. Instead of adding the radius to one of the distances, I can add the radius of both spheres together, square that, then just make sure the squared distance between the centers is greater or less. I know my original question didn't have enough information for anyone to be able to point this out, so that was my bad.
  2. NullStar

    Adding squared values

    Unfortunately, I wouldn't have access to the values before they were squared. They are computed as distances between points in a cluster of points (spheres). Currently, I am using sqrt to compute the distances, but was trying to avoid using sqrt for every point distance test by comparing squared distances. Comparing distances in squared form usually works, but apparently not for spheres? Thanks for your advice
  3. NullStar

    Adding squared values

    Not a lot of activity in this forum, except for all of my dumb questions. This one is very basic. Something I should probably already know the answer to. I'm wondering if it is possible to add two squared values together in a way that produces its squared result, or if there is any way to modify the inputs of an operation to produce the desired (squared) result. For example 3 + 3 = 6, but 3*3 + *3*3 != 6*6. If I have two squared distances, is there a clever way to combine these into the sum of their roots or the sum of their squares without using sqrt? The reason I'm wanting to do this is to compare two squared distances while adding a radius to one of them. Is there any way to do this without finding the roots first? if( dist_sq < len_sq + RADIUS_SQ ) // won't work - cannot extend either side by radius without sqrt? Thanks for any advice
  4. NullStar

    Special Center of Points

    Thank you for pointing that out. You just saved me a ton of time. Back to the research.
  5. NullStar

    AABB is Behind Plane Test

    Thanks, I appreciate the feedback. The part I was least confident in was the concept of generating a single point to represent the AABB in respect to the plane. I wasn't sure if that made sense.
  6. NullStar

    Special Center of Points

    I'm trying to generate a single bounding sphere for a collection of rigid body shapes. The shapes are limited to sphere, capsule, cylinder, and box. I am currently simplifying the box into a sphere, and the cylinder into a capsule to reduce stress. So as far as what I need to generate a bounding sphere, I can essentially represent each of these shapes with one or two spheres (capsule becomes its two contained spheres). Currently, I am iterating the spheres, and for each one, combining the result with the new sphere by computing a container sphere of both. The new center is half-way between the extents of both spheres (center = (a.pos + -a.radius + b.pos + b.radius) / 2 ), and the new radius is half of { distance + a.radius + b.radius }. I've done a little research into how complex it can be to find the spacial center of an arbitrary cluster of points. So I'm wondering if this will work as efficiently (volume space wise) as using one of these functions? If I iterate my spheres and generate the container sphere for each situation, will the end result be efficient as far as only being large enough to encapsulate all of the internal spheres? Or will its center be offset in some weird direction because of the order I iterated them? My game code is a heavy construction mess at the moment, or I would just test the code under a bunch of situations to see how well it does. If anyone has ever tried this, or can already see that it won't work well, I appreciate the insights. Thanks!
  7. NullStar

    AABB is Behind Plane Test

    Hello. I'm trying to come up with a simple method to cull an AABB against frustum planes, and I have something here, but I'm wondering if the logic is flawed. I am not currently able to test it, and have been in these situations before where I think I have a solid idea and then later realize it didn't make much sense. Can anyone confirm or deny this will work? The idea is pretty simple. Find the corner of the AABB that is farthest into the direction of the plane normal and test only that single point. If the point is in front of the plane (inside the camera frustum), then the AABB cannot be culled by that frustum plane and is still considered visible. Function to test against a single plane: bool TestPlaneAABB(const VEC3 &eye,const VEC3 &normal,const AABB &box) const { // prepare most-positive vector offset // + this will be the (offset of the) corner of the AABB that is farthest into the direction of the plane normal VEC3 most_positive_offset( ( normal.x < 0 ? box.Left : box.Right ) - eye.x, // choose x-side that is most positive relative to plane normal.x ( normal.y < 0 ? box.Bottom : box.Top ) - eye.y, // choose y-side that is most positive relative to plane normal.y ( normal.z < 0 ? box.Back : box.Front ) - eye.z ); // choose z-side that is most positive relative to plane normal.z // now simply return the result based on which side (of the plane) the most positive corner is on // + if this returns true, the most positive point is on the positive side and the box is still partially visible // + if it returns false, the most positive point is BEHIND the plane, meaning the entire box is behind the plane return Dot3( normal, most_positive_offset ) >= 0; } So I would just execute this function once for each frustum plane to determine if the box is hidden or visible. I tried to do some research on AABB frustum tests, but didn't find much that helped. If there is a simpler or easier way to do this, I really appreciate any insights. Thanks!
  8. NullStar

    Find angle of radius at distance

    Yeah, that would work pretty well for testing general angle thresholds. My attacks just have a specific min/max angle that's specified by a proxy object in the 3D model scene. So for example, a certain type of knife swing may only hit targets to the right or left. My main problem was taking the target sizes into account. If you are fighting a very large enemy, part of his body can be at an angle the attack can hit while his origin position is completely outside of it. This is the reason for the radius angle offset.
  9. NullStar

    Find angle of radius at distance

    Thanks for confirming that. Am I right in thinking that the maximum angle of this result will be 90 degrees? I'm wondering what to do when a potential target gets so close to the attacker that their radius is overlapping the attacker's origin. If I'm giving the attacker extra angle based on the defender's radius, would it make sense to just go ahead and give them a full 90 degree angle bonus when the sphere (defender) center is overlapping the origin (attacker)? Here are some images to better explain this. The blue sphere is the defender. The white angle is the attack area. One image shows a normal situation with a defender in front. The other shows a defender getting too close, but still being inside the attack area.
  10. NullStar

    Find angle of radius at distance

    @ Zakwayda: that is extremely helpful. Thank you for your time. If it doesn't work, it gives me a good place to start.
  11. NullStar

    Find angle of radius at distance

    Thank you for the reference. I will look at it closer soon. But at first glance it looks like I would need 2 vectors for this to be relevant? I only have one - the direction from the origin to the sphere. Finding the angle between two destinations from one source is simple with dot product and acos. But I'm not sure how to generate a second destination with my one source, one destination, and radius (radius being "the distance between the two destinations"). Maybe I didn't explain this well. I think what I'm wanting is pretty simple. It's probably handled by a single math function. I want to compute the dot product or angle to rotate from one side of a circle to the other from an origin that is a specific distance away from it. What I have: origin, sphere_center, sphere_radius I also have the direction vector from the origin to the sphere of course. Thanks again
  12. Hello, I'm trying to find the angle (difference) between a sphere's center and it's surface from an external position. Math is not my strongest skill, and I'm much better reading code than formula. If you can write the solution in code form, my brain will thank you. The reason I'm trying to calculate this is for a melee attack scan. The attacker scans for targets within a certain radius and angle of the attack origin. But I want to subtract each potential target's size (radius) from the angle test, so larger targets are easier to hit. So currently I just have the direction vector and distance from the attacker and Target origin. I would like to find the angle I need to reduce the angle requirements to be hit. Thanks for any advice!
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!