• Advertisement

FireViper

Member
  • Content count

    69
  • Joined

  • Last visited

Community Reputation

129 Neutral

About FireViper

  • Rank
    Member
  1. Collision detection with Verlet integration

    thanks for clearing everything up. I will check out the article.
  2. Collision detection with Verlet integration

    thanks for the reply serumas, I have a few questions. On the move function, is 'air' a float? Also, what does the 'satisfy_all_objects_constraints' function do?
  3. I recently read an article on Verlet integration ([url="http://lol.zoy.org/blog/2011/12/14/understanding-motion-in-games"]http://lol.zoy.org/b...motion-in-games[/url]) and wanted to apply it. It seems to work, but I'm not sure how to use it with my collision detection code. My update function looks something like this: [source lang="cpp"]void State::Update(float dt) { Vector accel = Vector(...) //get accelreation based on user input Vector oldVel = vel; vel += (accel) * dt; pos += (oldVel + vel) * 0.5 * dt; if( if_collision_is_enabled ) { Vector newpos = CollideWithWorld(pos,vel); //get new position //update velocity & position based on the new position vel = newpos - pos; pos = newpos; } }[/source] It seems to work, but the movement isnt as smooth as it is without collision. I assume I'm not updating the velocity and position correctly after the collision. Does anyone know a better way to do this?
  4. OpenGL Jpeglib texture loading issue

    thanks for the reply, I swapped the rows and its working.
  5. I'm trying to load jpg files using jpeglib, and found this example ([url="http://www.efkhoury.com/content/opengl-jpeg-texture-loader-using-ijg-libjpeg"]http://www.efkhoury....ing-ijg-libjpeg[/url]) I got it to work but the textures are being rendered incorrectly. I have to open them using mspaint, rotate them 180 degrees and flip them horizontally, in order for them to render correctly. I noticed the same thing happened when I tried to load png files. After searching google, I found out I have to swap the rows of the texture buffer before loading it in to opengl. However, I couldn't to find any code (or pseudo code) on it. If someone could tell me how to do this, it would be great. This is the function I'm using to load the texture: [code] unsigned char* LoadJPG(const string& filename, int& width,int& height, int& nChannel) { unsigned char * big_buff; struct jpeg_decompress_struct cinfo; struct my_error_mgr jerr; FILE * infile; JSAMPARRAY buffer; int row_stride; if ((infile = fopen(filename.data(), "rb")) == NULL) return NULL; cinfo.err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = my_error_exit; if (setjmp(jerr.setjmp_buffer)) { jpeg_destroy_decompress(&cinfo); fclose(infile); return NULL; } jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo, infile); (void) jpeg_read_header(&cinfo, TRUE); (void) jpeg_start_decompress(&cinfo); row_stride = cinfo.output_width * cinfo.output_components; buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); big_buff = (unsigned char*)malloc(cinfo.output_height * cinfo.output_width * cinfo.output_components); while (cinfo.output_scanline < cinfo.output_height) { JDIMENSION read_now = jpeg_read_scanlines(&cinfo, buffer, 1); memcpy(&big_buff[(cinfo.output_scanline - read_now) * cinfo.output_width * cinfo.output_components], buffer[0], row_stride); } width = cinfo.output_width; height = cinfo.output_height; nChannel = cinfo.num_components; (void) jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); fclose(infile); return big_buff; } [/code]
  6. player vs player collision

    thanks for the reply oliii.I know there are a lot of articles on the net about sphere-to-sphere collision, but the part that confuses me is changing vector spaces. In this article, all points (basePoint, velocity, and the 3 triangle points) are scaled by eSpace before the collisionPoint is detected. When I test against a sphere, do I have to scale the sphere's position and radius as well?
  7. player vs player collision

    I've recently read the Improved Collision detection and Response article, and implemented player-vs-world collision system. I was wondering what is the best way to do play-vs-play collision? Since the "Collision Response" part of the algorithm only needs an intersectionPoint and intersectionDistance, I assume the only thing that needs to change is "Collision Detection" part. If one of the player is defined as a unit sphere(after being scaled by the Ellipsoid Vector Space) and the other player is an ellipsoid (assuming it doesn't have the same radii as the first player) what is the best way to determine if an intersection has occurred, and if so, find the intersection point?
  8. Smooth skinning algorithm

    ok, let me clarify a few things. Each Bone has: Parent - A pointer to its parent length - (float) the length of the bone Rotation/Position - (vector) The Rotation and Position Direction - (vector) Bone's Direction Transform - The Transformation Matrix InverseBind - The Inverse of Transform in the reference pose Start/End - The Start and End points of the bone This is the code I use to move a Bone. void bone::Set() { //Calculate Bone's Relative Matrix Transform = matrix4(); //Set Transform to its Identity Transform.SetRotation( Rotation ); //If parent exist if(Parent!=NULL) //Combine Relative Matrix with Parent's Matrix to form Absolute Matrix Transform = Transform * Parent->Transform; //Calculate Bone's orientation vector3 tempVec = (Direction * length) * Transform; if(Parent!=NULL) Start = Parent->End; else Start = vector3(); End = Start + tempVec; } The only translation I see here is the distance from Start to End, which is calculated in tempVec. Are you saying I should combine this with the Transformation Matrix?
  9. Smooth skinning algorithm

    I get what you'er saying, but Im not sure how to do it. I mean I know I have to translate the matrix by a certain point, then rotate it, and translate it back, but I'm not sure how to calculate the translation?
  10. Smooth skinning algorithm

    Quote:So for a point attached to the hand, the matrices should have some translation at least. The only thing Im doing to the bones are rotating them, where does the translation come from? Are you referring to the distance from the start of the bone to the end as the translation?
  11. Smooth skinning algorithm

    noone know what Im doing wrong? well any suggestions would be appreciated.
  12. I've read a few articles (and skimmed through a bunch of posts) about CPU skinning. I've tried to implement it for a while, but it just doesn't seems to work for me. I know that the equation looks something like this, v' = sum( Weight[i] * TransformMatrix[i] * ReferencePose[i]^-1 ) * v; But when I try to implement this on a single point, it fails. Below are 2 screen shots I took. The first pic is a skeleton in its reference pose, with left arm rotated at -90 degrees in the z axis, and the right arm rotated in 90 degrees in the z axis. and the blue point is a vertex of a mesh, its coords are (19.426800, 9.168850, 0.129585) the second pic is the skeleton's right arm is in its default pose, where all its matrices are set to their identities. since the blue point is at the edge, I assume its under the influence of just 1 bone. So I don't have to calculate the sum of the weights, I just calculate: v'= TransformMatrix * ReferencePose^-1 * v where: v = (19.426800, 9.168850, 0.129585) TransformMatrix = Identity Matrix ReferencePose^-1 = the inverse matrix of 90 degrees in the z axis And when I compute the result, I get v'=(9.168850, -19.426800, 0.129585) As you can see in the second pic, that is not where v' should be. Any ideas on what I'm doing wrong?
  13. Skeleton Animation reference pose

    Quote:Original post by emeyex 2) ensure your Bone[i].InverseBind is correct (after you compute the inverse of the reference pose, invert the matrix again and ensure it's "equal" to the reference pose) well Im not sure if it makes a difference, but the way I calcualte the Inverse matrix is, during the Binding function, I loop through all the bones, Set the Inverse matrix to the Transpose of the Bone's Transform matrix. However, thats shouldnt really matter, because when i multiply the Transform by its Inverse, I get its Identity. Quote: I'll think a little longer and re-post if anything else jumps out at me. Thanks, that would really help.
  14. Skeleton Animation reference pose

    Well you didnt confuse me....much. I tried to do what you said, but I the same results. Here my rendering code: int maxBones; int maxTri; //maxTriangles Bones[maxBones]; //Holds Transform & Inverse matrix VertSkin[maxTri]; //Class holds skin influence data (bone IDs & Weights) matrix4 SkinMat[maxBones]; // skinning matrix vector3 Vertex[maxVertices]; //holds list of vertices (float x,y,z) polygon Polygon[maxTri]; //holds triangle indices (int a,b,c) for(i=0; i < maxBones; i++) //loop through i'th bones { //Calculate skinning matrix SkinMat[i] = Bone[i].Transform * Bone[i].InverseBind; } for(i=0; i<maxTri; i++) //Loop through i'th triangles { vector3 v1 = Vertex[Polygon[i].a]; //untransformed point int maxInfluences; //# of bones that influence v matrix4 M; //holds sum of weights //loop through j'th weights for(int j=0; j < maxInfluences; j++) { int boneID = VertSkin[ Polygon[i].a ].ID[j]; float weight = VertSkin[ Polygon[i].a ].Weight[j]; if(j==0) M = SkinMat[ boneID ] * weight; else M = M+(SkinMat[ boneID ] * weight); } //transform v1 by the sum of all weights v1 = M * v1; ... // Calculate v2 & v3 ... // Render Triangle } Im not sure if im making a mistake in the rendering code, or my matrix multiplication code. Heres a screenshot of simple skinned mesh in its reference pose: And here is a screenshot once i rotate the arm bones,
  15. Skeleton Animation reference pose

    Quote:Original post by emeyex v' = sum_for_each_vertex_weight_i( W[i] * Mref[ B[i] ]^-1 * M[ B[i] ] ) * v; so the program would loop through the number of weights influenced by the vertex, multiply (float)W[i] with (matrix4x4)Mref[ B[i] ]^-1, which would give another 4x4 matrix, which is then multipled by M[ B[i]], and the result is stored in another matrix, which is multiplied by v when the loop ends. Alright, I think I got it, but its been a while since I did matrix math, and can't remember how to multiply a float to matrix. So when I multiply W[i] * Mref[ B[i] ]^-1, I just scale all of Mref[ B[i] ]'s values by W[i]?
  • Advertisement