Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About kc_0045

  • Rank
  1. Quote:Original post by JackTheRapper What do you mean by 'not working'? Is the texture being displayed but not as desired, or is it not displaying at all? At a quick glance it looks like you're using unsigned integers and then telling OGL you're using unsigned bytes, so each integer element for R, G, B and A is being read as the entire 4 byte RGBA pixel in the texture. Use unsigned char instead of unsigned int, eg: *** Source Snippet Removed *** Edit: fixed typos That fixed it, thanks.
  2. Hey, So yeah im trying to load the var data into a opengl texture, but it doesnt seem to be working. Any ideas? void effect::init(int h2,int w2) { h=h2; w=w2; data = (unsigned int*)new unsigned int[ ((h*w)*4) ]; for(int n=0; n<=(h*w);n++) { //Red n+0, Green n+1, Blue n+2, A0 n+3 data[(n*4)+0]=255; data[(n*4)+1]=255; data[(n*4)+2]=0; data[(n*4)+3]=255; } glEnable(GL_TEXTURE_2D); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, h, w, 0,GL_RGBA, GL_UNSIGNED_BYTE, data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); } I was trying to make a way to generate random effects into a texture then display it, any ideas? im declaring data in the effect class as public: unsigned int* data;
  3. So yeah, this should be simple but idk it just isnt working, im stumped. Trying to get LastDrawnx and LastDrawny to smoothly follow Mousex,Mousey so when ondraw is called it draws it smoothly. (for drawing a line) The code below would be in a while loop with something like while(dis>1) so it loops till it gets close(incase of fast mouse movement causing effects to look weird.) mOffsetx=Mousex-LastDrawnx; mOffsety=Mousey-LastDrawny; float fx=(float)mOffsetx; float fy=(float)mOffsety; float legth =sqrt( (fx*fx) + (fy*fx) ); if(((int)legth)!=0) { mOffsetx/=(int)legth; mOffsety/=(int)legth; } LastDrawnx+=mOffsetx; LastDrawny+=mOffsety; CSurface::OnDraw(Surf_Display, Surf_Brush, LastDrawnx,LastDrawny); it sorta gets to the mouse....but it acts all random and doesnt follow a pattern to my mouse.
  4. Okay, After thinking it over pretty much what I need to do is get the 2d position on a 3d plane, from a 3d position, one way I was thinking of would be to use Perspective projection, where the viewer position would be the same as the plane, would that work? I got the idea from But would there be a simpler way of doing this? :S
  5. First off, I have no idea if that subject title made any sense. Pretty much what I need to do is, Well look at these pictures (Made in secondlife, Woo haha) What I need to do, is the get "Local" offset of Object 2(Blue box) from object 1(Red box) By local offset, I mean the Green cylinder length would be the X value, and the Blue the Y value, But without using Cylinders of course. In this case the Red cylinder is going in the direction of objects 1 local Y axis. I would also need to be able to change this for each 6 sides(Well, 3 sides I guess I would just have to flip the x for the opposite. Any ideas on how to go about this? What I was thinking would be First you need to "Cancel out" objects 2s rotation, Aka if it was on the position seen in snapshot2, change it so it would be like in snapshot 1, then simply get the offset. But I have no idea how to do this :( Something to do with a Rotation Matrix im assuming, but I have never done anything with them before :( [Edited by - kc_0045 on July 16, 2008 10:03:28 PM]
  6. kc_0045

    3D projection question(s)!

    Okay, so just to make sure iv got this right, the Viewer position is essentially the "Cone" you see on cameras(for example, in most 3d rendering programs) while the X,Y control the plane Height/Length and the Z is the distance from the camera pos? I tried using Height/2 and Width/2 for the X,Y values and it seems to make an odd effect(Seemingly random, the object is there, and you can see it, but its like...warped like crazy) Edit: this seems to create a good looking effect, bx=(dx-0)*(80/dz); by=(dy-0)*(80/dz); and then in the setup part, Draw.x =width/2; Draw.y =height/2; (Draw is the object that everything is rendered to) 800 creates a rather huge zoomed effect, assuming it works that the "800" means 800 from the camera, that would be nearly across the map haha but I shall keep tweaking it, ill post an example in a sec
  7. kc_0045

    3D projection question(s)!

    Quote:Original post by staticVoid2 is Cam.x and Cam.y the camera position in world space or is it the viewer position in camera space? If it is the first then you need to define a separate location in camera space. this is just another translation vector. so take for example: (0, 0, 1000) this means the viewer will be positioned 1000 units behind(or infront) the camera. so your code will now look like: bx=(dx-0)*(1000/dz); by=(dy-0)*(1000/dz); note: you will probaly see points that are behind the camera because eg. (10, 10) / -5 = (-2, -2) which will still be a valid point on screen if your x and y axis intersect at for instance the center of the screen. Cam.x and Cam.y are the camera position in world space, this whole "Viewer position" and camera space is what is throwing me off :S is the Viewer how a Field of view effect would be applyed? I noticed theres a major fish eye effect going on as is
  8. kc_0045

    3D projection question(s)!

    okay! iv got it all working, expect one thing, I still cant figure out what this "the viewer position in camera space" is, it works if I keep it at 0,0,0 but then I cant raise the cams Z value without it going crazy :S
  9. First off, what im trying to do is create a basic 3d cord to 2d cord system in Actionscript3(Flash), but Iv got some questions, using the "Perspective projection" code found here Main questions are, The rotation of the camera, degrees/radians? the viewer position in camera space. Huh? anyone care to explain that, would it be just 0,0,0 or The Cam.x,Cam.y,Cam.z im sure ill have more as they come....oh and if I want my world to be setup as X/Y =left/forward and z=up/down what rotation would I change by 90 Degrees to get this?(on the camara) Currently the setup is acting very odd, cant seem to get it to work right(but zero errors!) function ScreenCordX(ax,ay,az) { var dx, dy, dz,bx,by,cx,cy,cz,crx,cry,crz; cx=Cam.x; cy=Cam.y; cz=Cam.z; crx=0; cry=0; crz=Cam.rotation/360; dx=cos(cry)*(sin(crz)*(ay-cy)+cos(crz)*(ax-cx))-sin(cry)*(ax-cx); dy=sin(crx)*(cos(cry)*(az-cz)+sin(cry)*(sin(crz)*(ay-cy)+cos(crz)*(ax-cx)))+cos(crx)*(cos(crz)*(ay-cy)-sin(crz)*(ax-cx)); dz=cos(crx)*(cos(cry)*(az-cz)+sin(cry)*(sin(crz)*(ay-cy)+cos(crz)*(ax-cx)))-sin(crx)*(cos(crz)*(ay-cy)-sin(crz)*(ax-cx)); bx=(dx-0)*(Cam.z/dz); by=(dy-0)*(Cam.z/dz); return bx; } I know the above is a very bad as far as scripting goes, but ill worry about formating later. Also, iv made functions sin(a)=Math.sin(a) simply to save some space and make it so they all line up
  10. kc_0045

    The water effect code...

    This article Okay im trying to get this working inside flash, in order to create real looking water but for some reason its giving odd looking waves, heres all the code for the objects that handels the points. onClipEvent (load) { Xsize=100; Ysize=10; WaveGrid = Array(Xsize); WaveGrid_Last = Array; for(var n=0;n<Xsize;n++) { WaveGrid[n]=Array(Ysize); } for(var nx=0;nx<Xsize;nx++) { for(var ny=0;ny<Ysize;ny++) { WaveGrid[nx][ny]=0; } } WaveGrid_Last=WaveGrid; WaveGrid[50][2]=100; } on (keyPress "<Up>") { WaveGrid_temp=WaveGrid; for(nx=1;nx<(Xsize-1);nx++) { for(ny=1;ny<(Ysize-1);ny++) { WaveGrid_temp[nx][ny]=((WaveGrid[nx+1][ny]+ WaveGrid[nx-1][ny]+ WaveGrid[nx][ny-1]+ WaveGrid[nx][ny+1])/2)- WaveGrid_Last[nx][ny]; WaveGrid_temp[nx][ny]*=0.9; } } WaveGrid=WaveGrid_temp; WaveGrid_Last=WaveGrid; } anything in the WaveGrid[x][2] is what is drawen since im using it for a side view game. this is what im getting... Example Press UP to run the "Smoothing" code...Any ideas? Edit: Fixed link [Edited by - kc_0045 on October 13, 2006 6:23:05 PM]
  11. kc_0045

    Best way to "Render to texture"

    Quote:Original post by zedzeek this is typically called a portal its pretty straight forward position camera at tv cams pos + dir render scene copy to texture setup normal viewpoint draw tv sceen with the above texture applied okay thank you
  12. What im trying to do is create a Video camara that is displayed on a t.v/screen in my game that is live(So in other words, it renders the world, saves it to a texture or somthing, then renders it onto a face) I dont care so much about the code(but an example would be nice :P) I just dont know what would be the best way to go about this, If anyone could give me some terms I could research that would be great. Also, im using TGE(Torque) so would the render for the Camara need to be saved before the Player view is rendered? just wondering how that would work and if im gonna have to do digging into TGE main code, or if I can manage to put all the code for it inside a Seperate objects render function.
  13. kc_0045

    lesson #26

    Would it be possable to apply a bumpmap to this? its exactly what im lookiing for but it needs to be sorta distorted Edit:
  14. kc_0045

    Rendering a grid...

    Quote:Original post by NickGravelyn I'm just kinda writing this in here, so don't get too mad if it's not 100% perfect. I'm not sure how to make a single quad strip, so I just render each "row" of quads as a strip. Not as efficient as it could be, but better than drawing each one separately. *** Source Snippet Removed *** I'm pretty sure that'll do the trick. If you're using a 2D array, just use z[x][y] and then z[x+1][y] and you'll be all set. Hopefully that works or at least gets you started. :) ok thanks alot there was an error in your code ( j needed to be y, just a typo) other then that it works, Thanks alot!
  15. Hello, im trying to make water for my game. but im having problems trying to figured out a way to render if. all I need to do is render a "grid" of quads 100*100 getting the z out of an array and each x,y is 1 away from the other. GL_QUAD_STRIP would be the best way to render this(i think) but i just cant seem to get my mind around how to use it to do what I want in a for loop. any ideas? :S
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!