Marianne

Members
  • Content count

    77
  • Joined

  • Last visited

Community Reputation

163 Neutral

About Marianne

  • Rank
    Member
  1. Alpha question

    Quote:Original post by Lord_Evil Let me try: Your rgb channels don't just show one color right? Let's say you have a tree whose leaves are stored in that texture and you want the leaves look like leaves with all the shades of green (or some other color). However, when you select the tree, the leaves should be all bright red (or some other color), is that what you want to do? Yes, exactly Quote:Original post by Lord_Evil If you're using shaders that's easy, but if not I'd say you need two textures (you can separate your single texture into a rgb texture and an alpha/luminance texture). Then you draw the object textured with your rgb texture or color with a single color depending on the selection state and let OpenGL modulate both "texture" stages in either case. (Keep in mind that with 2 textures the first stage (color and texture 1) needs to just use the texture, with just alpha and color you have to modulate here). Shaders sound itneresting, i would need to learn them though. However i am doing 2D graphics, aren't shaders a bit of an overkill for that? Well if the rendering cost is not high i wouldn't mind though. Of course keeping 2 textures is a possibility that was thre right from the start, i just wanted to know if there's another way. I'll look at shaders - but if you know some references for doing that kind of flat shading it would be appreciated. Thanks
  2. Alpha question

    Hi, thanks for letting me for this function. it partially works as it does color the textures. However it's still not a viable solution because this way i can't control much the output color and i need to.
  3. Alpha question

    Hi, i have a texture with alpha channel. However, i would like, at some point, to display it with solid color (e.g. don't display RGB data, display plain red instead) but still retaining the alpha channel to keep the general shape of the object. The rationale is that i want to display an obejct as selected, however it is black tehrefore simple glColor4f() won't do the job. Is this possible without keeping 2 different textures? I have tried a bit playing with blend and coloring functions but have had very little success. Thanks
  4. quaternion interpolation behaves weirdly

    it works! may thanks about the C++ code... you're right! before doing C++ i was doing Java, i think it shows [totally]
  5. Hi, i am interpolating between 2 quaternions with slerp. It's just that sometimes, it goes the "wrong" way. i.e., instead of rotating 10 degress clockwise, it rotates 350 degrees counter clockwise. Is it normal? How can this be fixed to always take the shortest path? And also, it doesn't always do that. I haven't been successful in finding when it does and when it doesn't. I suspect you might want to see my slerp function, so here it is: [source lang=cpp] Quat* slerp(Quat* qa, Quat* qb, double t) { // quaternion to return Quat* qm = new Quat(); // Calculate angle beteen them. double costheta = qa->w * qb->w + qa->x * qb->x + qa->y * qb->y + qa->z * qb->z; double theta = acos(costheta); // if theta = 0 then return qa if (abs(theta) < 0.01){ qm->w = qa->w; qm->x = qa->x; qm->y = qa->y; qm->z = qa->z; return qm; } // Calculate temporary values. double sinTheta = sqrt(1.0 - costheta*costheta); // if theta*2 = 180 degrees then result is undefined if (abs(sinTheta) < 0.01){ qm->w = (qa->w * 0.5 + qb->w * 0.5); qm->x = (qa->x * 0.5 + qb->x * 0.5); qm->y = (qa->y * 0.5 + qb->y * 0.5); qm->z = (qa->z * 0.5 + qb->z * 0.5); return qm; } double ratioA = sin((1 - t) * theta) / sinTheta; double ratioB = sin(t * theta) / sinTheta; //calculate Quaternion. qm->w = (qa->w * ratioA + qb->w * ratioB); qm->x = (qa->x * ratioA + qb->x * ratioB); qm->y = (qa->y * ratioA + qb->y * ratioB); qm->z = (qa->z * ratioA + qb->z * ratioB); return qm; }
  6. New to angelscript

    Well, i got it to build but not the "right" way. CallSystemFunction wasn't defined in the archive, so i added the file defining it to my project. I'm not sure if this is a valid way of going. And the code i'm using is the one from the tutorial example. (i removed the getSystemTime thing because i didn't implement a mac-os version of it. I just removed calls to it... could this be a problem? i thought it would just hang instead of timing out but maybe there's something i didn't think about) float calc(float a, float b) { // Print the value that we received Print("Received: " + a + ", " + b + "\n"); // Do the calculation and return the value to the application return a * b; }
  7. New to angelscript

    Right now i am using Mac OS X with gcc 3.3. I believe gcc is supported, right? following the source code, i fell upon as_callfunc files... i tried adding them to my project so that they could be built properly, but got the following message: script (1, 1) : INFO : Compiling double calc(double, double) script (4, 24) : ERR : Found more than one matching operator script (4, 28) : ERR : Found more than one matching operator script (4, 35) : ERR : No conversion from '<unrecognized token>' to math type available. ../../source/as_compiler.cpp:6132: failed assertion `ctx->type.dataType.IsReference()'
  8. New to angelscript

    Yes, Console works. but, from it, i can't figure out how to make a simple angelcode script that uses objetcs/functions declared from C/C++... i guess i'll try working with the tutorial, but as i said i have absolutely no angelcode knowledge and fixing things you don't know about is sometimes a little hard =) But im sure i can do it... what i meant is that it would have been nice to have these simple samples, but if i don't have them i can still manage i believe and conio.h isn't found either, i don't know what this is EDIT: I Adapted the turorial example the best i can, but at linking i get these: ld: warning prebinding disabled because of undefined symbols ld: Undefined symbols: PrepareSystemFunction(asCScriptFunction*, asSSystemFunctionInterface*, asCScriptEngine*) CallSystemFunction(int, asCContext*, void*) why aren't these functions there? libangelscript.a is linked [Edited by - Marianne on August 6, 2006 1:22:05 PM]
  9. New to angelscript

    Hi, i'm new to AngelScript... i am looking for a scripting language to embed into my C/C++ app. I'm mostly working on mac and linux. Unfortunately, almost all provided samples use "windows.h"... is there a minimal cross-platform sample? just to demonstrate how it works... thanks =) PS: i've seen the documentation on angelcode.com but i couldn't find any that creates a whole program. they all seem to focus on a specific part of the program and leave me with no clue of how to do a whole program
  10. matrix interpolation

    it works!!! :D many thanks, i didn't know i was so close to get it to work. next time i'll try to look carefully at the conventions, however the page i got my info at didn't mention them (or maybe i'm blind!)
  11. matrix interpolation

    but i'd like to a know a way to do it with matr ices if possible because my whole program is based on matrices, so with Quaternions i need to convert my matrices to quats, interpolate them and then convert them back to a matrix. performance isn't crucial in my program but still it's awkward. well i oduble-checked my conversion codes with the one presented on the website where i got them (i'm not yet fluent with thiese maths so i can probably let something slip very easily... i adapted code from http://www.euclideanspace.com/maths/) personnaly i'd think the mistake would be in the matrix to quat code rather than in slerp to avoid the nasty 2D arrays in C++ i just used a single dimension array in this order: 0 1 2 3 4 5 6 7 8 (i'm doing this mostly to learn so please excuse stupid mistakes!) // ------------------------ Matrix to quat -------------------------- float trace = matrix->i[0] + matrix->i[4] + matrix->i[8] + 1.0f; /* --> here i'm not sure... the code on the website was 'if (trace > M_EPSILON)' however i couldn't find M_EPSILON anywhere... the text along the code stated 'if bigger than zero' so i just put zero. that might be the problem */ if( trace > 0 ) { float s = 0.5f / sqrtf(trace); qw = 0.25f / s; qx = ( matrix->i[5] - matrix->i[7] ) * s; qy = ( matrix->i[6] - matrix->i[2] ) * s; qz = ( matrix->i[1] - matrix->i[3] ) * s; } else { if ( matrix->i[0] > matrix->i[4] && matrix->i[0] > matrix->i[8] ) { float s = 2.0f * sqrtf( 1.0f + matrix->i[0] - matrix->i[4] - matrix->i[8]); qx = 0.25f * s; qy = (matrix->i[3] + matrix->i[1] ) / s; qz = (matrix->i[6] + matrix->i[2] ) / s; qw = (matrix->i[7] - matrix->i[5] ) / s; } else if (matrix->i[4] > matrix->i[8]) { float s = 2.0f * sqrtf( 1.0f + matrix->i[4] - matrix->i[0] - matrix->i[8]); qx = (matrix->i[3] + matrix->i[1] ) / s; qy = 0.25f * s; qz = (matrix->i[7] + matrix->i[5] ) / s; qw = (matrix->i[6] - matrix->i[2] ) / s; } else { float s = 2.0f * sqrtf( 1.0f + matrix->i[8] - matrix->i[0] - matrix->i[4] ); qx = (matrix->i[6] + matrix->i[2] ) / s; qy = (matrix->i[7] + matrix->i[5] ) / s; qz = 0.25f * s; qw = (matrix->i[3] - matrix->i[1] ) / s; } } // ----------------------- Quat to matrix ----------------- Matrix* matrix=new Matrix(); matrix->i[0] = 1 - 2*_SQUARE(qy) - 2*_SQUARE(qz); matrix->i[1] = 2*qx*qy - 2*qz*qw; matrix->i[2] = 2*qx*qz + 2*qy*qw; matrix->i[3] = 2*qx*qy + 2*qz*qw; matrix->i[4] = 1 - 2*_SQUARE(qx) - 2*_SQUARE(qz); matrix->i[5] = 2*qy*qz - 2*qx*qw; matrix->i[6] = 2*qx*qz - 2*qy*qw; matrix->i[7] = 2*qy*qz + 2*qx*qw; matrix->i[8] = 1 - 2*_SQUARE(qx) - 2*_SQUARE(qy); return matrix; // ---------------------- SLERP ----------------------- Quat* slerp(Quat* qa, Quat* qb, double t) { // quaternion to return Quat* qm = new Quat(); // Calculate angle beteen them. double costheta = qa->qw * qb->qw + qa->qx * qb->qx + qa->qy * qb->qy + qa->qz * qb->qz; double theta = acos(costheta); // if theta = 0 then return qa if (abs(theta) < 0.01){ qm->qw = qa->qw; qm->qx = qa->qx; qm->qy = qa->qy; qm->qz = qa->qz; return qm; } // Calculate temporary values. double sinTheta = sqrt(1.0 - costheta*costheta); // if theta*2 = 180 degrees then result is undefined if (abs(sinTheta) < 0.01){ qm->qw = (qa->qw * 0.5 + qb->qw * 0.5); qm->qx = (qa->qx * 0.5 + qb->qx * 0.5); qm->qy = (qa->qy * 0.5 + qb->qy * 0.5); qm->qz = (qa->qz * 0.5 + qb->qz * 0.5); return qm; } double ratioA = sin((1 - t) * theta) / sinTheta; double ratioB = sin(t * theta) / sinTheta; //calculate Quaternion. qm->qw = (qa->qw * ratioA + qb->qw * ratioB); qm->qx = (qa->qx * ratioA + qb->qx * ratioB); qm->qy = (qa->qy * ratioA + qb->qy * ratioB); qm->qz = (qa->qz * ratioA + qb->qz * ratioB); return qm; }
  12. matrix interpolation

    hi, i'm trying to do matrix interpolation, to have a 3D object smoothly pass from one location to another (only rotation matters here, i can do the translation myself) . All i have is two matrices and a delta. (I know an older topic already mentions this here, but i couldn't anything to work!) i have tried converting my matrices to quaternions, but the object starts moving in the wrong direction (?) i have tried converting to axis-angle, however it only works one way, e.g. clockwise is okay, counter-clockwise isn't (either going in the wrong way, or sometimes going the right way but much too slowly (?) ) i have also tried direclty interpolating each number inside the matrix. well it works but as i expected the object gets distorted in the process. so right now the one that seems to work best is axis-angle... how could i know in which way to rotate the angle then? thanks! (if you need to see a bit what i've tried, just ask i can post some pseudo code)
  13. OpenGL 2D Sprites

    really great =) thanks for your help
  14. OpenGL 2D Sprites

    anyone?
  15. OpenGL 2D Sprites

    Quote: Even though it's not a perfect solution, you'd probably be safe with assuming the user's card supports the extension I tried on my comuter and it didn't work :( Quote: No, put you can blit the images onto a surface in that way in your program. Yes, i was asking how to do that please... Quote:http://www.mevis.de/opengl/gluBuild2DMipmaps.html How could i use that in my purpose? I know about mipmaps for smooth 3D textures, so i don't see how i can use that for my purpose?