Jump to content

  • Log In with Google      Sign In   
  • Create Account

Muzzy A

Member Since 25 May 2007
Offline Last Active Today, 06:45 PM

#5197591 Ray/AABB Intersection Incorrect

Posted by Muzzy A on 11 December 2014 - 09:30 AM

Learn a little about AABB to Ray intersect instead of just copying the code.  It's not that difficult if you know vector math.  But there are other guides to help you.

 

Another topic about AABB to Line Segment ( has Ray to AABB code )

Video Explaining Ray to AABB ( No code, just the math side )

A little guide to creating Ray to AABB Checks ( Has code, gives a little bit of explanation for it too )

 

EDIT:

After you complete that, I would look into using OBB's instead of AABB's if your cube is going to be changing orientation.




#5195790 Shader always returns white

Posted by Muzzy A on 01 December 2014 - 04:38 PM

PROBLEM SOLVED

 

My graphics card doesn't support version 3.0 pixel shaders, had to use version 2.0.  I was looking up reasons why ID3DXEffect::ValidateTechnique() would fail and found a topic on here that led me to test the version I'm using.  3.0 works with the vertex shader however... I guess I better put it down to 2.0 just to be safe, just have to be careful with how many calculations I perform.

 

Before I made this topic I thought about changing those down to 2.0 to see if it worked... I should have done it, but I assumed this computer was new enough to be aware of version 3.0, assumptions can cause problems.  Lesson learned.




#5195652 Finding covered tiles of the brush

Posted by Muzzy A on 01 December 2014 - 02:27 AM

Not an expert on this or anything, but no one else has replied so I will put in my opinion =P

 

 

From what your saying it seems like I would personally do something like casting a ray from the camera and get the point of collision on the terrain from that ray.  Then create a vertical cylinder, rectangle, or whatever the shape will represent your brush the best, then test that geometric shape against the terrain to find all of the tiles that are either inside or colliding with the shape.

 

Hope this helps!




#5144409 DirectX 11 Drawing multiple instances of the same object

Posted by Muzzy A on 04 April 2014 - 12:39 PM

Well this Tutorial explains everything I need. Thanks for the post.




#5143109 A question about where to store the Camera!

Posted by Muzzy A on 29 March 2014 - 01:09 PM

Hi, I'm building my own little renderer and there's a couple things that I get undecided about.

 

Where exactly do most of you store things like the Camera and Projection matrix?

I've seen and tried several different ways of doing so, but I'm not satisfied by any of them.

  • Save it in the renderer, pass them as parameters to the render functions - Probably the best way, but I don't want Parameters!
  • Make a singleton for the camera ( HORRIBLE! ) to access it anytime.
  • Make a static variable in the render objects that holds a reference to the camera and projection matrix.

 

I'm just a little curious at how others would do this minor little thing.




#5123221 SIMD Function - Illegal instruction?

Posted by Muzzy A on 12 January 2014 - 11:59 PM

It doesn't support AVX. Thanks for making me double check.




#5097523 WT* ?

Posted by Muzzy A on 28 September 2013 - 06:37 PM

LOL this topic brightened my day.




#5097500 Circle vs Line Segment collision

Posted by Muzzy A on 28 September 2013 - 04:02 PM

struct Segment
{
    Vector3 start;
    Vector3 end;
};
struct Sphere
{
    Vector3 center;
    float fRadius;
};

This code will find the closest point to the sphere that is on the line segment.

Vector3 point = sphere.center;
 
// Get the direction of the line segment from start to end
Vector3 line = segment.end - segment.start;
float length = Math::Length(line); // The length of the line
line /= length; // Normalize
 
// The Vector from the center of the sphere to the start of the line seg
Vector3 toStart = segment.start - point;
 
// How far up the line the closest point is
float dist = Math::DotProduct(toStart,line);
 
// ensure that the closest point is on the line segment
if( dist < 0 )
dist = 0;
else if(dist > length)
dist = length;
 
// Calculate the closest point
ClosestPoint = segment.start + line * dist;

Now you have the closest point, just do a simple radius check

Vector3 toPoint = sphere.center - ClosestPoint;
 
// For optimization you can use the square distances
float dist = dot_product( toPoint,toPoint ); // Equivelant to LengthSqu()
 
if( dist <= sphere.fRadius*sphere.fRadius )
    // There is a collision



#5095040 Question about programming in team, and svn...

Posted by Muzzy A on 18 September 2013 - 04:10 PM

There is usually an Interface which tells you what lines of code were changed in a file.  You have to see where they made their changes and merge it with yours into one copy, and usually you can see what that final copy looks like as well.  It's not hard, you just have to be careful when doing it because you can easily leave out someone else's code by accident and they'll have to either redo it, or revert back.




#5094833 Calculus Vs Algebra based Physics

Posted by Muzzy A on 17 September 2013 - 10:02 PM

you don't really need to go to those classes, If you want to do a game just start learning DirectX or OpenGL and as you learn it by osmosis you just start making more and more complex things, and as you go you will find everything you need on the internet. Going to university(in programming) is more about meeting other people.

this actually depends on the person, some people learn much better when being taught the subject in person rather than reading it online.

 

 

Anyways assuming this is a standard physics class and not for game programming, yes I agree with Hodgens. Formulas used in programming are all usually derived from calculus, but look like simple Linear Algebra and are usually common and can be found online.  Linear Algebra is the only real thing you need to know. I would say Linear Algebra is a requirement for Game Programming, but that's just me.




#5084492 Box vs Plane Collision Detection

Posted by Muzzy A on 09 August 2013 - 03:28 PM

if it's an Axis Aligned box, things are easy, you can actually treat the center as a radius

struct Sphere { float m_Radius; Vector3 m_Center; };
struct AABB { Vector3 min,max; };
struct Plane { Vector3 normal; float offset; };
 
int SphereToPlaneCollision(const Plane& plane, const Sphere& sphere)
{
    float dot = dot_product(plane.normal,sphere.m_Center) - plane.offset;
 
    if(dot > sphere.m_Radius)
        return 1; // The sphere is in front of the plane
    else if(dot < -sphere.m_Radius)
        return 2; // The sphere is behind the plane
 
    return 3; // The sphere collides/straddles with the plane
}
int AabbToPlaneCollision(const Plane& plane, const AABB& aabb)
{
    // Get the Extense vector
    Vector3 E = (aabb.max - aabb.min)/2.0f;
    
    // Get the center of the Box
    Vector3 center = aabb.min + E;
 
    Vector3 N = plane.normal;
 
    // Dot Product between the plane normal and the center of the Axis Aligned Box
    // using absolute values
    float fRadius = abs(N.x*E.x) + abs(N.y*E.y) + abs(N.z*E.z);
 
    Sphere sphere;
    sphere.m_Center = center;
    sphere.m_Radius = fRadius;
 
    return SphereToPlaneCollision( plane,sphere );
}



#5082678 std::vector<> vs cli::array<>

Posted by Muzzy A on 03 August 2013 - 12:02 AM

The fact that it's managed makes me want to remove it from my computer =P

 

Thanks for the explanation. I probably wont be using any cli::arrays in the near future lol. I enjoy managing my own memory, I have an attachment to it.




#5079081 Orbit (ellipse) collision detection between many many objects

Posted by Muzzy A on 19 July 2013 - 09:48 PM

There's this thing called the KD Tree I think? It can get quite complex, but basically puts every object in to a list of AABB's and objects only check collision in the surrounding AABB's.

 

You can define the size of your AABB's yourself obviously. And there's no limit to how big you can make this tree, there's alot of overhead for it, but it's extremely useful when you have a large amount of objects like that.




#5078377 Jumping - What did I do wrong?

Posted by Muzzy A on 16 July 2013 - 11:28 PM

@Muzzy A
  The code has been remade and re-posted  smile.png (see comment right before yours)

You still have this

if(m_pos.y != 0);
 
// Should be
if(m_pos.y <= 0);

Though you're only adding or subtracting '0.5', in an actual game/project time is a factor and '0.00001 != 0.0', just a heads up. It will only work in your case.

 

 

I had to stop myself from writing a tutorial :P




#5078375 D3DXVECTOR3 with doubles

Posted by Muzzy A on 16 July 2013 - 11:22 PM

I imagine negative positions wouldn't be hard to add in there, try that out and see what happens. If it doesn't work you can easily create your own Vector3 with doubles. If that doesn't work, then it's in your math.

 

100,000 shouldn't be to high for you to get those jerky results IMO. Do some optimizations so that you're doing as little math as possible on those large numbers is my suggestion. But I could be wrong. Good Luck :)






PARTNERS