Jump to content
  • Advertisement

frankd

Member
  • Content Count

    227
  • Joined

  • Last visited

Community Reputation

164 Neutral

About frankd

  • Rank
    Member

Recent Profile Visitors

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

  1. frankd

    2D animation w/ OGL

    You probably want to use glMatrixMode(GL_TEXTURE). Then you can set the texture area using glTranslate and glScale. eg. say you wanted to draw a 64x64 subimage at (128,0) in a 256x256 texture: glMatrixMode(GL_TEXTURE); glTranslatef(128/256, 0, 0); glScalef(64/256, 64/256, 0); (you divide by 256 because texture coordinates are from (0,0) to (1,1)).
  2. frankd

    image editing

    What you need to learn is how to load and save an image file format. When you've loaded your image, the pixel data is simply stored in an array, so you can do whatever operations you want on the pixels simply by iterating through the array. Here's an overview of a load/edit/save system: struct pixel_t { byte red, green, blue; }; struct image_t { int width, height; pixel_t *pixel_data; }; image_t *load_image(const char *file) { image_t *image = new image_t; //open the file, read in the info you need //eg. width and height image->pixel_data = new pixel_t[image->width*image->height]; //read the pixel data in from the file either directly into //image->pixel_data (if the format permits), or by loading //into a temporary buffer and copying into image->pixel_data //pixel by pixel return image; } void my_image_edit(image_t *image) { for(int i=0; i<(image->width*image->height); ++i) { //do what you want with image->pixel_data } } void save_image(const image_t *image, const char *file) { //open the file, write out the image //in the format of the file } Hope that helps.
  3. When I try using std::string with a minimal libc in the style of libctiny I get a few unresolved symbols: void std::Xlen() void std::Xran() CxxFrameHandler except_list What are these, and what should they do? If I implement these, will the majority of the STL work, or will I keep encountering more functionality that needs to be implemented? Thanks
  4. frankd

    Will Computing End In Our Lifetime

    ITER predict the first commercial fusion reactor by 2050. That's if they ever get round to choosing a site for their reactor. Quote:Well there is hydrogen.. Just the irony is, with hydrogen, an awful lot of power is required to seperate it from oxygen in water.. Exactly the same ammount of power that you get from using it as a fuel. That's why hydrogen from water will only ever be a fuel, not an energy source (except in the case of hydrogen isotopes for fusion).
  5. I'm confusing myself over this, can anyone help me? I've got bones which have an orientation and position, stored as quaternions and vectors. Something like this: struct bone_t { quat ref_pose_orientation; vector3 ref_pose_position; }; struct bone_instance_t { bone_t *bone; quat orientation; vector3 position; //not actually animating this at the moment }; I calculate the absolute versions of these each frame (ie. relative to the root bone instance). These are passed to the vertex program as bone_quat and bone_pos below. They're interpolated to make quat and trans, and then I rotate the vertex position by quat and translate by trans. I don't really know if this is right though. I've only been able to test the rotation on its own so far and that works alright. What I don't get is how the translation works. What exactly should I be pre-translating the vertex positions with? An interpolation of the reference pose orientations/positions for each influential bone? All the documentation I can find makes each bone into a matrix and then "interpolates" the matrices in the v.p., and because I have no idea what's actually happening when this is done, I can't do the interpolation manually with quats and vectors. I'd rather not use matrices because they need more space in program.local. Also is the XPD command a 1 step operation? Thanks, Frank !!ARBvp1.0 ATTRIB weights = vertex.attrib[6]; ATTRIB bone_indices = vertex.attrib[7]; PARAM bone_quat[40] = { program.local[0..39] }; PARAM bone_pos[40] = { program.local[40..79] }; PARAM bones_offset = program.local[80]; TEMP pos, trans, quat, t1, t2; ADDRESS a0; # four bone lerp of quats and linear interpolation of trans: # quat = lerp(bone_quat[t1.x], weights.x, bone_quat[t1.y], weights.y, etc.) # trans = bone_pos[t1.x]*weights.x + bone_pos[t1.y]*weights.y + etc. SUB t1, bone_indices.x, bones_offset.xxxx; ARL a0.x, t1.x; MUL quat, bone_quat[a0.x], weights.x; MUL trans, bone_pos[a0.x], weights.x; ARL a0.x, t1.y; MAD quat, bone_quat[a0.x], weights.y, quat; MAD trans, bone_pos[a0.x], weights.y, trans; ARL a0.x, t1.z; MAD quat, bone_quat[a0.x], weights.z, quat; MAD trans, bone_pos[a0.x], weights.z, trans; ARL a0.x, t1.w; MAD quat, bone_quat[a0.x], weights.w, quat; MAD trans, bone_pos[a0.x], weights.w, trans; # renormalize DP4 t2.w, quat, quat; RSQ t2.w, t2.w; MUL quat, quat, t2.w; # transform position with interpolated bone (pos=quat*pos*quat_conjugate; pos+=trans;) MOV pos.xyz, vertex.position; XPD t1, quat, pos; MAD t1.xyz, quat.w, pos, t1; DP3 t1.w, quat, -pos; XPD pos, t1, -quat; MAD pos.xyz, t1.w, -quat, pos; MAD pos.xyz, quat.w, t1, pos; MOV pos.w, vertex.position.w; ADD pos.xyz, pos, trans;
  6. frankd

    quaternion bone blending

    I'm trying to use quaternion interpolation instead of matrix interpolation, so I can't just switch over to matrices for the final weighted blending. I end up with just a final blended rotation quaternion, but nowhere to rotate it about. eg. in this picture: the blended vertices second from the left are rotated (with a blend of the 2 bones' rotations) around the centre of their circle, which is a point about 2/3 along the first bone. How is this point decided? With matrix blending it all seems hidden inside the combined rotation/translation matrices. Thanks
  7. frankd

    quaternion bone blending

    Thanks, that helps. I still don't get why it works though. Going back to an arm example, the 50:50 blended elbow vertices would then be rotated around a point halfway up the upper arm. So if the elbow was bent 50 degrees, the elbow bits would rotate 25 degrees around a point halfway up the upper arm, which doesn't sound right. Maybe I should just stop thinking about it and play around with it... Thanks
  8. frankd

    quaternion bone blending

    What I have is a heirachy of bones, each one something like this: struct bone_t { vector3 pos, abs_pos; quaternion orientation, abs_orientation; }; The abs_... versions (absolute) are calculated each frame by traversing the tree from the root. They are then put in program.local for the vertex shader, which interpolates the relevant quaternions for each vertex. Even if I now convert the resultant quaternion into a rotation matrix, I don't understand how to use it. If I just transform the vertex with it, what bone's local space do I put the vertex in before doing so? Thanks
  9. frankd

    quaternion bone blending

    Cheers but I'm looking to avoid matrix blending. I'm trying to use a blended quaternion but because it doesn't do translation like with a blended matrix, I'm left wondering what I rotate around using the blended quaternion. It can't be blended positions because then you'd end up rotating 50:50 blended elbow vertices around a point halfway up the upper arm.
  10. I'm trying to interpolate between bone quaternions to skin a mesh. Once the rotation has been deduced by lerping between the 2 quaternions, how does the program decide which bone's origin to use as the origin of rotation for a vertex? eg. on an elbow joint, you'd want the blended vertices on the upper arm to rotate around the lower arm's origin, not the upper's, right? How does the program decide which to use given any joint system?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

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!