# xissburg

Member

629

204 Neutral

• Rank

• Interests
Art
Programming
1. ## After collision car greatly jumps [ video ]

Well, the front of the car is hitting the floor so it should received a great impulse, but it looks like your is kinda light and consequently has a low moment of inertia. You could try to edit the collision shape to have a higher front, just to get rid of that undesired effect.
2. ## Intersection Between 2D Ray and Rectangle Borders

You could use the tangent of the angle of the dir vector. Depending on the direction it is pointing, you use a different formula based on the angle of the diagonal of the AABB. I've came up with this: [source lang="cpp"] // WARNING: Untested code Point Intersect(Point min, Point max, float alpha) // alpha is the dir vector angle { float beta = atan2(max.y - min.y, max.x - min.x); // AABB diagonal angle float hw = (max.x - min.x)*0.5; // AABB width/2 float hh = (max.y - min.y)*0.5; // AABB height/2 float tanAlpha = tan(alpha); if (fabsf(alpha) < beta) // right section return Point(max.x, min.y + hh + tanAlpha*hw); else if (fabsf(PI - alpha) < beta) // left section return Point(min.x, min.y + hh - tanAlpha*hw); else if (fabsf(PI*0.5 - alpha) < PI*0.5 - beta) // top section return Point(min.x + hw + 1.f/tanAlpha*hh, max.y); else if (fabsf(1.5f*PI - alpha) < PI*0.5 - beta) // bottom section return Point(min.x + hw - 1.f/tanAlpha*hh, min.y); else // should not happen o_ O return WTF; } [/source]
3. ## [Answered] Matrix create from XYZ rotation: scale problem

Ouch. You better create a simple rotation matrix for each axis and multiply(compose) all three to obtain the final rotation matrix.
4. ## Improper rotations (reflections) with quaternions

Rotation matrices can perform reflections, also known as improper rotations, roto-reflections etc. One way to find out whether a rotation matrix represents an improper rotation is to check whether its determinant is negative. Can a quaternion represent such transforms? How to make a reflection quaternion? Thanks.
5. ## Fitting a plane to a 3d point set

Least Square Method
6. ## Inheritance and iterators

It is calling Shape::area because o object slicing. Try using pointers instead: for(std::vector<Shape*>::iterator it = shapes.begin(); it != shapes.end(); it++) { Shape *s = *it; s->area(); }
7. ## Implementing First Person Camera with Gun

Displace your weapon so that it will be at the desired location 'relative to the camera' then multiply its transform by the camera matrix, which should rotate it and translate it properly. If you still dont get it, show us some code.
8. ## moving ellipsoid VS moving triangles

GJK + Conservative Advancement = FTW
9. ## Rendering Bounding boxes [Direct3D]

I think there's nothing wrong with the Direct3D rendering code. I think the order of the vertices is not correct. I don't know which corner BoundingBox.GetCorner(i) returns.
10. ## Why is a message always there when I PeekMessage() - can't exit past PeekMessage loop

Quote:Original post by pinacolada The title of this thread is pretty funny if you cut it off at the right place: yeah I actually thought this was a joke..
11. ## Something Wrong With My Pointers ?

Use double pointer IDirect3DDevice9** as parameter to the init()method.
12. ## OpenGL OpenGL rendering incorrect texture colors

Oh it was the color that was set using glColor . . . this is what happens when you copy-paste code...lol Thanks
13. ## OpenGL One thought about mixing 2d and 3d

Quote:In order to easily draw a 2D interface in front of a 3D scene, is it possible to save a GL_PROJECTION matrix and load it as a GL_MODELVIEW matrix? Cant get what you mean. If you are going to draw a 2D GUI you should set an ortho projection matrix. Then first draw the 3D stuff and then set an ortho matrix and draw the 2D stuff over everything, using textured quads, with some transparency or so. And you dont need to specify the z position for this 2D stuff, you dont want them to intersect the 3D stuff do you? And you want to compute frames per [b]second[/i] without using a timer??? Id like to know how to do this =)
14. ## Is there a triangulation lib somehwere?

3ds Max can do this operation on splines, it is called outline: But if you exaggerate in the parameter the spline overlaps itself.
15. ## OpenGL OpenGL rendering incorrect texture colors

To load a texture from file and properly render it in OpenGL has been seriously boring me and...well that turned into a whole history now.. Since I'm using SDL in the project, I chose to use SDL_LoadBMP to load a texture (this project is very simple CG wise). And SDL loads it, and correctly. But when I render it as a texture in OpenGL The texture gets a greenish-brownish appearance. Then I loaded a texture with 100% red, blue and green large strips, took a screenshot of my app and color picked it in Photoshop (lighting is off). Then I noticed that the red and green are at 100% but the blue is at 50%. I really don't know what else I can do :/ HALP My simple load texture code: SDL_Surface* surface = SDL_LoadBMP("groundTexture.bmp"); if(surface == NULL) { std::cout << "Failed to load groundTexture.bmp" << std::endl; return; } Uint8 nOfColors = surface->format->BytesPerPixel; GLenum textureFormat = GL_RGBA; if (nOfColors == 4) // contains an alpha channel { if (surface->format->Rmask == 0x000000ff) textureFormat = GL_RGBA; else textureFormat = GL_BGRA_EXT; } else if (nOfColors == 3) // no alpha channel { if (surface->format->Rmask == 0x000000ff) textureFormat = GL_RGB; else textureFormat = GL_BGR_EXT; } glGenTextures( 1, &groundTexture ); glBindTexture( GL_TEXTURE_2D, groundTexture ); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); //glTexParameterf(GL_TEXTURE_2D, 0x84FE, 8);//hardcoded anisotropy glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); gluBuild2DMipmaps(GL_TEXTURE_2D, nOfColors, surface->w, surface->h, textureFormat, GL_UNSIGNED_BYTE, surface->pixels); /*glTexImage2D( GL_TEXTURE_2D, 0, nOfColors, surface->w, surface->h, 0, textureFormat, GL_UNSIGNED_BYTE, surface->pixels );*/ glBindTexture(GL_TEXTURE_2D, 0); Thanks