Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

absobj.cpp File Reference


Detailed Description

Implementation of AbsObj class.

#include <GL/gl.h>
#include <iostream>
#include <vector>
#include "absobj.h"
#include "maths.h"

Include dependency graph for absobj.cpp:

Include dependency graph

Functions

int getside (float *in)
 Given a set of floats, identifies the single one on the wrong side of 0 (where wrong is arbitrary).
Vec4 getintersect (float &fin1, float &fin2, Vec4 &in1, Vec4 &in2)
 This finds the intersection of a line with a plane.
bool inTriangle (Vec4 p, Vec4 p0, Vec4 p1, Vec4 p2)
 Given a point p, and a triangle p0,p1,p2, calculate if p is within the triangle.
bool inflattriangle (float x1, float y1, float x2, float y2, float x3, float y3, float px, float py)
 Find if a point is in a 2D triangle.
int collideResponse (float time, AbsObj &bill, AbsObj &ben, Vec4 &pt, Vec4 &n, Vec4 &intr, float sticky)
 Collision response.

Function Documentation

int collideResponse float  time,
AbsObj bill,
AbsObj ben,
Vec4 pt,
Vec4 n,
Vec4 intr,
float  sticky
 

Collision response.

Important rigid-body physics. This does lots of important collision response for all objects.

Todo:
Write this in more depth.
Parameters:
time The length of time of the collision.
bill One of the colliding objects.
ben The other object.
pt Point of collision (in world space).
n Normal of collision.
intr Intersection of the objects.
sticky The elasticity coefficient. Between 0 and 1.
Returns:
0. Return value not used atm.

Todo:
Fix intersection code. While the code itself is correct, the way in which we find the intersection distance is not correct.
See also:
AbsObj::collide.

Here is the call graph for this function:

Vec4 getintersect float &  fin1,
float &  fin2,
Vec4 in1,
Vec4 in2
 

This finds the intersection of a line with a plane.

I have NO IDEA how.

Parameters:
fin1 The result of putting in1 into a plane equation.
fin2 The result of putting in2 into a plane equation.
in1 A point.
in2 Another point.
Returns:
The point on the plane.

Here is the call graph for this function:

int getside float *  in  ) 
 

Given a set of floats, identifies the single one on the wrong side of 0 (where wrong is arbitrary).

This is a very bizarre function, that I'm quite proud of. It creates a bitmask corresponding to whether an entry in the array is greater than 0 (or not). As we don't care which side is which, as long as one is different from the other two, it negates 4-7 down to 0-3.

Returns:
An integer from 0-4. 0 means the array does not swap sides. Subtract 1 otherwise.

bool inflattriangle float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
float  px,
float  py
 

Find if a point is in a 2D triangle.

This takes three pairs of floats as the triangle, and the fourth pair as the point. I made a pretty test-harness that used it to draw triangles, so it should work.

bool inTriangle Vec4  p,
Vec4  p0,
Vec4  p1,
Vec4  p2
 

Given a point p, and a triangle p0,p1,p2, calculate if p is within the triangle.

All points are assumed to be coplanar.

Parameters:
p The point of unknown placement.
p0 First point of triangle.
p1 Second point.
p2 Third.
Returns:
True if point is within triangle.
Todo:
remove calculation of normal.

Here is the call graph for this function:


Generated on Mon Jan 3 15:14:19 2005 for Graviton by  doxygen 1.3.9.1