Jonathan2006

Member

11

122 Neutral

• Rank
Member

• Website
• Interests
Programming

Recent Profile Visitors

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

1. Transforming Angular Velocity

The red wire sphere code is the “mat4 rotateMatrix” that I posted further above. Thank you JoeJ for your time. I just don’t know enough to figure this out. Below are some things I have learned. After skimming through some game developer physics books, euclideanspace.com, and your posts here’s what I think I have learned so far... 1) Axis Angle can be used to represent the length and direction of angular velocity/rotations in quaternions and matrices. 2) Multiplying two quaternions is just like multiplying two matrices. 3) Angular velocity can be represented in a 3x3 skew matrix. What went wrong 1) I could never get any of my axis angle functions to work with more than one integrator. 2) Not sure about multiplying quaternions since I could never get the correct output after multiplying. 3) I tried multiplying several skew matrices together and the final matrix had all zero values. I used the GLM library for most of my quaternion and matrix code but I was never really able to debug the axis angle quaternions. I tried axis angle matrices from euclideanspace.com and I did find a bug in the GLM code that I fixed in my code. The output of angular velocity in the matrices never came out correctly after I added more than one integrator. Since nothing worked I will have to use my old unreliable code below: vec3 angleRadians = GEEulerAngleFromMat4(matrix); vec3 angularVelocity = (angleRadians - oldAngleRadians) / globalTimeStep; vec3 oldAngleRadians = angleRadians; Hope this helps anyone else with this problem. Thanks again, Jonathan

6. OpenGL Color Anaglyphs

I'm having trouble getting anaglyphs working for a game that uses OpenGL ES 1.1 . Right now I'm trying to use code that I found on Paul Bourke's website. I've tried changing the color of the Cube() with lighting but if the cube is anything other than white the red and blue masks disappear. My question is how do I get colored objects other than white to look 3D with my red and blue glasses? I'm using the Toe-in Method which is explained here: http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/stereographics/stereorender/ Thanks, Jonathan [Edited by - Jonathan2006 on June 27, 2010 4:05:40 PM]
7. Smooth moving on terrain

Sorry about that. I fixed it now.
8. Smooth moving on terrain

Well I'm confused now. Can someone please explain some ways to improve the code I already have so I don't get weird results. I'm writing in a different code language but below it's written in kind of pseudocode/C which should be easier to read. I also just use one square in the code but if you want to see the weird results add an array of squares. Here's the code I'm using: #define kGravity 3.0 char keyboardCommand; BOOL keyUp, collision; float xSpeed, ySpeed, zSpeed; float xPoint, yPoint, zPoint; float xOldPoint, yOldPoint, zOldPoint; float lastDistance, normalForce; float vectorDistance(float x1Vert, float y1Vert, float z1Vert, float x2Vert, float y2Vert, float z2Vert, float x3Vert, float y3Vert, float z3Vert, float xP, float yP, float zP); void keyboardDown(void); void keyPressed(char command) { keyUp = NO; // Sometimes this doesn't fire when the key is held down for a long time. // So I update it in the timer keyboardCommand = command; } void keyboardUp(char command) { keyUp = YES; xSpeed = 0.0; ySpeed = 0.0; zSpeed = 0.0; switch(command) { case 'w': case 's': zSpeed = 0.0; break; } } // this is where everything is updated void timer(void) { float x1Vert =-1.0; float y1Vert = 1.0; float z1Vert = 0.0; float x2Vert = 1.0; float y2Vert = 3.0; float z2Vert = 0.0; float x3Vert = 1.0; float y3Vert = 3.0; float z3Vert =-1.0; float x4Vert =-1.0; float y4Vert = 1.0; float z4Vert =-1.0; float A = y1Vert * (z2Vert - z3Vert) + y2Vert * (z3Vert - z1Vert) + y3Vert * (z1Vert - z2Vert); float B = z1Vert * (x2Vert - x3Vert) + z2Vert * (x3Vert - x1Vert) + z3Vert * (x1Vert - x2Vert); float C = x1Vert * (y2Vert - y3Vert) + x2Vert * (y3Vert - y1Vert) + x3Vert * (y1Vert - y2Vert); float D = x1Vert * (y2Vert * z3Vert - y3Vert * z2Vert) + x2Vert * (y3Vert * z1Vert - y1Vert * z3Vert) + x3Vert * (y1Vert * z2Vert - y2Vert * z1Vert); float vectorMagnitude = sqrt(A * A + B * B + C * C); float s; // This has more code but I don't want to write it out // All it does is count the time between when the timer(); was last called float theTimeSegment; xPoint += (xSpeed * theTimeSegment); yPoint += ((ySpeed - kGravity + normalForce) * theTimeSegment); zPoint += (zSpeed * theTimeSegment); // this needs to be after the speed keyboardDown(); if (s > 0.1) { xOldPoint = xPoint; yOldPoint = yPoint; zOldPoint = zPoint; } s = A * xPoint + B * yPoint + C * zPoint - D; if (lastDistance >=-0.1 && s <= 0.1) { // Normalize and finding the unit length of the normal float xPlanePoint = xPoint - ((s / vectorMagnitude) * (A / vectorMagnitude)); float yPlanePoint = yPoint - ((s / vectorMagnitude) * (B / vectorMagnitude)); float zPlanePoint = zPoint - ((s / vectorMagnitude) * (C / vectorMagnitude)); // This is for a square but it can be done for any polygon float distance1 = vectorDistance(x1Vert, y1Vert, z1Vert, x2Vert, y2Vert, z2Vert, (x1Vert - A), (y1Vert - B), (z1Vert - C), xPlanePoint, yPlanePoint, zPlanePoint); float distance2 = vectorDistance(x2Vert, y2Vert, z2Vert, x3Vert, y3Vert, z3Vert, (x2Vert - A), (y2Vert - B), (z2Vert - C), xPlanePoint, yPlanePoint, zPlanePoint); float distance3 = vectorDistance(x3Vert, y3Vert, z3Vert, x4Vert, y4Vert, z4Vert, (x3Vert - A), (y3Vert - B), (z3Vert - C), xPlanePoint, yPlanePoint, zPlanePoint); float distance4 = vectorDistance(x4Vert, y4Vert, z4Vert, x1Vert, y1Vert, z1Vert, (x4Vert - A), (y4Vert - B), (z4Vert - C), xPlanePoint, yPlanePoint, zPlanePoint); // Since the planes are pointing inward we check for a positive distance if (distance1 >= 0.0 && distance2 >= 0.0 && distance3 >= 0.0 && distance4 >= 0.0) { // Normalize float xNorm = A / vectorMagnitude; float yNorm = B / vectorMagnitude; float zNorm = C / vectorMagnitude; float dotProduct = (xSpeed * xNorm + ySpeed * yNorm + zSpeed * zNorm); xSpeed -= xNorm * dotProduct; ySpeed -= yNorm * dotProduct; zSpeed -= zNorm * dotProduct; xPoint = xOldPoint; yPoint = yOldPoint; zPoint = zOldPoint; normalForce = kGravity; collision = YES; } } lastDistance = s; } float vectorDistance(float x1Vert, float y1Vert, float z1Vert, float x2Vert, float y2Vert, float z2Vert, float x3Vert, float y3Vert, float z3Vert, float xP, float yP, float zP) { float A = y1Vert * (z2Vert - z3Vert) + y2Vert * (z3Vert - z1Vert) + y3Vert * (z1Vert - z2Vert); float B = z1Vert * (x2Vert - x3Vert) + z2Vert * (x3Vert - x1Vert) + z3Vert * (x1Vert - x2Vert); float C = x1Vert * (y2Vert - y3Vert) + x2Vert * (y3Vert - y1Vert) + x3Vert * (y1Vert - y2Vert); float D = x1Vert * (y2Vert * z3Vert - y3Vert * z2Vert) + x2Vert * (y3Vert * z1Vert - y1Vert * z3Vert) + x3Vert * (y1Vert * z2Vert - y2Vert * z1Vert); return ((A * xP) + (B * yP) + (C * zP) - D); } void keyboardDown(void) { if (keyUp == NO) { switch(keyboardCommand) { case 'w': if (collision) { xSpeed = 0.0; ySpeed = 0.0; zSpeed = 0.0; if (normalForce == kGravity) normalForce = 0.0; zSpeed =-2.0; collision = NO; } break; case 's': if (collision) { xSpeed = 0.0; ySpeed = 0.0; zSpeed = 0.0; if (normalForce == kGravity) normalForce = 0.0; zSpeed = 2.0; collision = NO; } break; } } } [Edited by - Jonathan2006 on May 23, 2006 9:11:35 PM]
9. Smooth moving on terrain

Right now I'm checking my collision detection between a point and a polygon/terrain. The way I test to see if the point needs to be moved is if it flys through the polygon and then I send it back to the point it was before the collision. This collision detection is pretty rough and I sometimes get my point to warp at the edges of each polygon and fly off in weird directions. Is there any way to get the point to follow the polygons smoother than flying through stopping and then changing the direction of the speed vector? Is there some kind of terrain avoidance or something that I could use?
10. Changing a vector so it slopes with terrain

Thanks so much for the replies. It worked perfect.
11. Changing a vector so it slopes with terrain

I have a vector u = -1.0, 0.0, 0.0 and it hits a plane with a normal vector of v = 2.0, 2.0, 0.0 . When the vector collides with the plane what formulas should I use to make the u vector change to follow the slope of the plane?
×

Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!