Advertisement Jump to content
  • Advertisement

weewun

Member
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

122 Neutral

About weewun

  • Rank
    Member
  1. First off, Sorry if this is not the right place to post this. OK, I worked in the QA department at Realtime Worlds (some of you will be aware of what happened to that company) and myself and 4 others with various disciplines (I'm a coder) are looking to apply to one of the University's here in Dundee for a prototyping grant - money to make a game prototype with the hope of finding a publisher / turn what we did into a sustainable company. We are just in the preliminary stages of discussion at the moment, and I am looking into what engine would be best to use (not necessarily a free one). We will have a better Idea of exactly what we need out of the engine after meeting up again on Wednesday. I wont go into too much detail about the game. The main things we are looking for is a good, versatile 2D engine, that allows the game to be published to a number of platforms relatively easily, primarily PC and web browser - the possibility of others would be a bonus. Another thing is, due to the conditions of the grant, we need to take on a number of students to 'work' for us, and as the other members of the group don't have a huge amount of programming experience, at least a couple of the students we take on will be coders. This means that it has to be pretty straight forward to pick up. I have looked at Torque and Unity, and was leaning towards the 2D version of Torque so far, although Unity does seem very powerful but maybe a bit overkill for our project. I was wondering what other engines it would be a good idea to look into, and if anyone has any thoughts/experience on the ones already mentioned. Any feedback is appreciated! Cheers, Ian
  2. Yes, i had already spent many hours staring at the debug screen to try and find out what the problem was, i was more interested in whether or not the theory behind how i was trying to do it was correct - sorry if it appeared otherwise. After spending many more hours on this, i found the main reason (granted, there were a couple other errors i had to fix due to just being dumb) for the sprite just move in a circle. the line: deltaAng = wRate - (2 * ( wRate / ((rand()%10) + 1) ) ) i was using to generate a random angular displacement tended to favour more positive numbers in the long run (although it did produce negative numbers frequently too which is why it took me a while to see the error) so i have settled for a non-random size of angular displacement and just choose a set +ve or -ve one at random and it seems to work fine. if anyone is interested in(granted, a slopp version as i have just finished it with alot of experimentation ) what i have incase its useful to anyone in the future is: void agent::wander() { ///////////// // for the wander algorithm, i am using the 'wander steering behavior' // described here: http://www.red3d.com/cwr/steer/Wander.html // this involves getting a point on a circle projected in front of // the object and moving this around the circle each fram. with this // a steering vector is found which is then used to 'steer' the object ///////////// //find circle center circleCenter.set(theSprite.actualPosition.getX() + (theSprite.direction.getX() * rootTwoStrength), theSprite.actualPosition.getY() + (theSprite.direction.getY() * rootTwoStrength)); //rotate wDirection a random amount if(rand()%2 == 0) deltaAng = -wRate; else deltaAng = wRate; if(deltaAng < 0) deltaAng += 360; deltaAng *= PI / 180.0 ; float angle = atan2( wDirection.getY(), wDirection.getX() ); //the current angle of the wDirection deltaAng += angle; wDirection.normalise(); wDirection.setX(cos(deltaAng)); wDirection.setY(sin(deltaAng)); //find point on circle that steering vector will be created from steeringPosition.set(circleCenter.getX() + (wDirection.getX() * wStrength), circleCenter.getY() + (wDirection.getY() * wStrength)); //find steering vector steeringVector.set( steeringPosition.getX() - theSprite.actualPosition.getX(), steeringPosition.getY() - theSprite.actualPosition.getY()); steeringVector.normalise(); //adjust direction vector depending on steering vector theSprite.direction.set(theSprite.direction.getX() + (steeringVector.getX() /50), theSprite.direction.getY() + (steeringVector.getY() /50)); theSprite.direction.normalise(); //just incase theSprite.actualPosition.move( theSprite.direction.getX() * velocity, theSprite.direction.getY() * velocity); }
  3. hi, iv been trying to get a basic wander algorithm to work (see here for the one im trying to use: http://www.red3d.com/cwr/steer/Wander.html ) but when i try to impliment it, i just get the sprite wandering in a circle and i cant figure out why :( the code iv created to do this is shown below. if anyone can see where im going wrong please help :P cheers void agent::wander() { ///////////// // for the wander algorithm, i am using the 'wander steering behavior' // described here: http://www.red3d.com/cwr/steer/Wander.html // this involves getting a point on a circle projected in front of // the object and moving this around the circle each fram. with this // a steering vector is found which is then used to 'steer' the object ///////////// //find circle center vector2d circleCenter; circleCenter.set(theSprite.position.getX() + (theSprite.direction.getX() * rootTwoStrength), theSprite.position.getY() + (theSprite.direction.getY() * rootTwoStrength)); //rotate wDirection a random amount float Ang = wRate - (2 * (wRate/(rand()%10 + 1 ))); // +1 so no division by 0 if(Ang < 0) Ang += 360; Ang *= PI / 180.0 ; wDirection.normalise(); wDirection.setX( (wDirection.getX() * cos(Ang)) - (wDirection.getY() * sin(Ang))); wDirection.setY( (wDirection.getY() * cos(Ang)) + (wDirection.getX() * sin(Ang))); //find point on circle that steering vector will be created from vector2d steeringPosition; steeringPosition.set(circleCenter.getX() + wDirection.getX() * wStrength, circleCenter.getY() + wDirection.getY() * wStrength); //find steering vector vector2d steeringVector; steeringVector.set( steeringPosition.getX() - theSprite.position.getX(), steeringPosition.getY() - theSprite.position.getY()); steeringVector.normalise(); //adjust direction vector depending on steering vector theSprite.direction.set((theSprite.direction.getX() + steeringVector.getX() ) /2, (theSprite.direction.getY() + steeringVector.getY() ) /2); theSprite.direction.normalise(); //just incase theSprite.actualPosition.move( theSprite.direction.getX() * velocity, theSprite.direction.getY() * velocity); }
  4. im about to make a program that will represent curves in 3D space using openGL and was wondering what the best way to draw them would be. i was thinking about using a quad strip but was thinking that to make it look smooth would require alot of quads. is there a better way to do this? any input would be appreciated :) cheers
  5. Hi there, im about to start a project looking at AI for university. Primarily, looking at creating a world with hundreds of simultanious AI agents running around gathering resources, bulding settlements etc (focus is on large numbers of AI agents collaborating). and what i am looking for is a relatively 'easy to use the basics of' game engine (would prefer a 3d one to be honest, but a good 2d one would suffice - maybe better in some respects). I would like to be able to code in c++ as that is what i am most familiar with too. Or if anyone knows any good engines that let you concentrate even more on the AI aspect, please mention those too :P i was thinking about Ogre3d primarily because i have used it before and it provides some nice camera functions, and i can easily put my MS3D models into it :P cheers.
  6. weewun

    collaborative AI

    hi there, im looking to undertake a project that will demonstrate seperate AI entities working together to achieve a certain task. I am thinking of having a maze and placing a number of 'bots' into it and they must work together to find a way out of the maze by each sharing their exploration information and devising exploration tactics between themselves(i.e. you go that way il go this way). i am relatively new to AI and was wondering if anybody knew of any good resources around this area of AI to look at or point me in the right direction. cheers.
  7. ok, im currently making a terrain generator and am wanting to redflect the terrain onto some water (this is my 1st terrain generator thing i have tried :) ) and i am having some problems. i have a large multi textured set of triangles for the water, which is placed 0.8 units above the 0 value of the terrain. i am rendering the reflection of the terrain onto the water using the stencil buffer etc as described in the NeHe tutorials for reflections and this sort of works. as in, when i dont render the 'seabed' as in any triangles of the terrain under the water then it reflect fine (but looks a bit odd because the terrain looks like it is floating - but that is expected) picture: http://img440.imageshack.us/my.php?image=reflectionmp7.jpg but when i tell it to render the triangles under the water too, the reflection dissapears as shown here. picture: http://img187.imageshack.us/my.php?image=noreflectionez2.jpg what i am wanting is the reflection on the water and to render the terrain under the water. i have tried playing with the setting s a wee bit but it usually makes it look a bit strange :(. here is the main bit of my render loop: double eqr[] = {0.0f,-8.0f, 0.0f, 0.0f}; // Plane Equation To Use For The Reflected Objects glColorMask(0,0,0,0); glEnable(GL_STENCIL_TEST); // Enable Stencil Buffer For "marking" The Floor glStencilFunc(GL_ALWAYS, 1, 1); // Always Passes, 1 Bit Plane, 1 As Mask glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // We Set The Stencil Buffer To 1 Where We Draw Any Polygon // Keep If Test Fails, Keep If Test Passes But Buffer Test Fails // Replace If Test Passes glDisable(GL_DEPTH_TEST); // Disable Depth Testing water.render(); glEnable(GL_DEPTH_TEST); // Enable Depth Testing glColorMask(1,1,1,1); // Set Color Mask to TRUE, TRUE, TRUE, TRUE glStencilFunc(GL_EQUAL, 1, 1); // We Draw Only Where The Stencil Is 1 // (I.E. Where The Floor Was Drawn) glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // Don't Change The Stencil Buffer glEnable(GL_CLIP_PLANE0); // Enable Clip Plane For Removing Artifacts // (When The Object Crosses The Floor) glClipPlane(GL_CLIP_PLANE0, eqr); // Equation For Reflected Objects glPushMatrix(); // Push The Matrix Onto The Stack glScalef(1.0f, -1.0f, 1.0f); // Mirror Y Axis terrain.render(); glPopMatrix(); // Pop The Matrix Off The Stack glDisable(GL_CLIP_PLANE0); // Disable Clip Plane For Drawing The Floor glDisable(GL_STENCIL_TEST); // We Don't Need The Stencil Buffer Any More (Disable) terrain.render(); water.render(); sorry if my explanation is a bit obscure :P cheers for any feedback
  8. weewun

    texturing problem

    ok, so i finally gave up and have just used the mlti texturing technique to texture it with a single texture and it works fine... now im having a problem with my blending. each square in my particle system is textured with a circular plume of smoke, with black around the edges of it - that i want to be completely transparent. however, when i do this with the blend function: glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_COLOR); it leaves a sort of invisible square around each one. i know why this is - that quad is being rendred to the screen before the one behind it is so it is just blending the background into the clear spots and then when one is rendered behiund it, the part of the quad behind the first one is not rendwered at all. now, without setting it up to calculate the distance fomr the camera every time etc and drawing them in the correct order, is there a way around this? sorry if my explanation is a odd, i foud it difficult to describe :P
  9. weewun

    texturing problem

    ok, iv messed about with it a bit more but im still stumped :S the full code for my terrain renderer is this getting posted... incase iv done something odd somewhere in it: void Terrain::render(){ glDisable(GL_LIGHTING); int row=0; int column=0; float textureHeight=0; float rgb=0; float alpha=0; for(int i=0; i<(MAP_SIZE*MAP_SIZE);i++){ //texture 0 = sand //texture 1 = grass //rexture 2 = rock ///part 1 - load base texture glActiveTextureARB( GL_TEXTURE0_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, sandTexture ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );//change 'GL_MODULATE' to GL_REPLACE' for a more faded-together effect of the textures //-- glActiveTextureARB(GL_TEXTURE2_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, rockTexture ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); //part 2 - set 2nd texture or something? glActiveTextureARB( GL_TEXTURE1_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, grassTexture); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );//GL_SRC_COLOR glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );//GL_SRC_COLOR glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR ); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Material_Diffuse); float rgbValue =0; float alphaValue = 0; glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glBegin (GL_TRIANGLES); glNormal3f(myNormals.x,myNormals.y,myNormals.z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 0.0f, 0.0f ); setTexContributions(rgbValue, alphaValue, i); glColor4f( rgbValue, rgbValue, rgbValue, alphaValue ); glVertex3f(row*UNIT, myGround.y,column*UNIT); textureHeight=setTextureHeight(i+MAP_SIZE); glNormal3f(myNormals[i+MAP_SIZE].x,myNormals[i+MAP_SIZE].y,myNormals[i+MAP_SIZE].z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 0.0f, 1.0f ); setTexContributions(rgbValue, alphaValue, (i+MAP_SIZE)); glColor4f( rgbValue, rgbValue, rgbValue, alphaValue ); glVertex3f(row*UNIT, myGround[i+MAP_SIZE].y,(column+1)*UNIT); textureHeight=setTextureHeight(i+1); glNormal3f(myNormals[i+1].x,myNormals[i+1].y,myNormals[i+1].z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 1.0f, 0.0f ); setTexContributions(rgbValue, alphaValue, (i+1)); glVertex3f((row+1)*UNIT, myGround[i+1].y,column*UNIT); textureHeight=setTextureHeight(i+1+MAP_SIZE); glNormal3f(myNormals[i+1+MAP_SIZE].x,myNormals[i+1+MAP_SIZE].y,myNormals[i+1+MAP_SIZE].z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 1.0f, 1.0f ); setTexContributions(rgbValue, alphaValue, (i+1+MAP_SIZE)); glColor4f( rgbValue, rgbValue, rgbValue, alphaValue ); glVertex3f((row+1)*UNIT, myGround[i+1+MAP_SIZE].y,(column+1)*UNIT); textureHeight=setTextureHeight(i+1); glNormal3f(myNormals[i+1].x,myNormals[i+1].y,myNormals[i+1].z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 1.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 1.0f, 0.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 1.0f, 0.0f ); setTexContributions(rgbValue, alphaValue, (i+1)); glColor4f( rgbValue, rgbValue, rgbValue, alphaValue ); glVertex3f((row+1)*UNIT, myGround[i+1].y,column*UNIT); textureHeight=setTextureHeight(i+MAP_SIZE); glNormal3f(myNormals[i+MAP_SIZE].x,myNormals[i+MAP_SIZE].y,myNormals[i+MAP_SIZE].z ); glMultiTexCoord2fARB( GL_TEXTURE0_ARB, 0.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE1_ARB, 0.0f, 1.0f ); glMultiTexCoord2fARB( GL_TEXTURE2_ARB, 0.0f, 1.0f ); setTexContributions(rgbValue, alphaValue, (i+MAP_SIZE)); glColor4f( rgbValue, rgbValue, rgbValue, alphaValue ); glVertex3f(row*UNIT, myGround[i+MAP_SIZE].y,(column+1)*UNIT); glEnd(); if(i==5050){ rgb = rgbValue; alpha= alphaValue;} row++; if(row>=MAP_SIZE){ row=0; column++;} } glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE2_ARB); glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); and the main thing i am trying to texture is some smoke im trying to make with a simple particle generator i have modified from the NeHe tutorials :P the render function is below. half thinking now that i maybe have to set a state that multitexturing changes or something in here, but im not sure :S void ParticleSmoke::render(){ glDisable(GL_LIGHTING); glEnable(GL_BLEND); // Enable Blending glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // Type Of Blending To Perform glDisable(GL_COLOR_MATERIAL); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,texture[0]); for (loop=0;loop<MAX_PARTICLES;loop++) // Loop Through All The Particles { if (particle[loop].active) // If The Particle Is Active { float x=particle[loop].x; // Grab Our Particle X Position float y=particle[loop].y; // Grab Our Particle Y Position float z=particle[loop].z; // Particle Z Pos + Zoom // Draw The Particle Using Our RGB Values, Fade The Particle Based On It's Life glColor4f(1,1,1,particle[loop].life-0.1); glPushMatrix(); glTranslatef(mX, mY, mZ); glRotatef(particle[loop].rot,0,1,0); glBegin(GL_TRIANGLE_STRIP); // Build Quad From A Triangle Strip glTexCoord2d(1,1); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 1); glVertex3f(x+(0.5f*PARTICLE_SIZE),y+(0.5f*PARTICLE_SIZE),z/*+(0.3*PARTICLE_SIZE)*/); // Top Right glTexCoord2d(0,1); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 1); glVertex3f(x-(0.5f*PARTICLE_SIZE),y+(0.5f*PARTICLE_SIZE),z/*-(0.3*PARTICLE_SIZE)*/); // Top Left glTexCoord2d(1,0); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1, 0); glVertex3f(x+(0.5f*PARTICLE_SIZE),y-(0.5f*PARTICLE_SIZE),z/*-(0.3*PARTICLE_SIZE)*/); // Bottom Right glTexCoord2d(0,0); //glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0, 0); glVertex3f(x-(0.5f*PARTICLE_SIZE),y-(0.5f*PARTICLE_SIZE),z/*+(0.3*PARTICLE_SIZE)*/); // Bottom Left glEnd(); // Done Building Triangle Strip glPopMatrix(); //glPopMatrix(); particle[loop].x+=particle[loop].xi/(slowdown*1000);// Move On The X Axis By X Speed particle[loop].y+=particle[loop].yi/(slowdown*1000);// Move On The Y Axis By Y Speed particle[loop].z+=particle[loop].zi/(slowdown*1000);// Move On The Z Axis By Z Speed particle[loop].xi+=particle[loop].xg; // Take Pull On X Axis Into Account particle[loop].yi+=particle[loop].yg; // Take Pull On Y Axis Into Account particle[loop].zi+=particle[loop].zg; // Take Pull On Z Axis Into Account particle[loop].life-=particle[loop].fade; // Reduce Particles Life By 'Fade' if (particle[loop].life<0.0f) // If Particle Is Burned Out { particle[loop].life=1.0f; // Give It New Life particle[loop].fade=float(rand()%100)/1000.0f+0.001f; // Random Fade Value particle[loop].x=0.0f; // Center On X Axis particle[loop].y=0.0f; // Center On Y Axis particle[loop].z=0.0f; // Center On Z Axis particle[loop].xi=float((rand()%10)-5.0f); // X Axis Speed And Direction particle[loop].yi=yspeed+float((rand()%30)-15.0f); // Y Axis Speed And Direction particle[loop].zi=float((rand()%10)-5.0f); // Z Axis Speed And Direction // particle[loop].r=colors[col][0]; // Select Red From Color Table // particle[loop].g=colors[col][1]; // Select Green From Color Table // particle[loop].b=colors[col][2]; // Select Blue From Color Table } /* // If Number Pad 8 And Y Gravity Is Less Than 1.5 Increase Pull Upwards if (keys[VK_NUMPAD8] && (particle[loop].yg<1.5f)) particle[loop].yg+=0.01f; // If Number Pad 2 And Y Gravity Is Greater Than -1.5 Increase Pull Downwards if (keys[VK_NUMPAD2] && (particle[loop].yg>-1.5f)) particle[loop].yg-=0.01f; // If Number Pad 6 And X Gravity Is Less Than 1.5 Increase Pull Right if (keys[VK_NUMPAD6] && (particle[loop].xg<1.5f)) particle[loop].xg+=0.01f; // If Number Pad 4 And X Gravity Is Greater Than -1.5 Increase Pull Left if (keys[VK_NUMPAD4] && (particle[loop].xg>-1.5f)) particle[loop].xg-=0.01f; if (keys[VK_TAB]) // Tab Key Causes A Burst { particle[loop].x=0.0f; // Center On X Axis particle[loop].y=0.0f; // Center On Y Axis particle[loop].z=0.0f; // Center On Z Axis particle[loop].xi=float((rand()%50)-26.0f)*10.0f; // Random Speed On X Axis particle[loop].yi=float((rand()%50)-25.0f)*10.0f; // Random Speed On Y Axis particle[loop].zi=float((rand()%50)-25.0f)*10.0f; // Random Speed On Z Axis }//*/ } } glDisable(GL_TEXTURE_2D); glDisable(GL_BLEND); // Disable Blending glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); }
  10. weewun

    texturing problem

    oh, and on a side note how do i post code properly? i tried 'code' '/code' in the square brackets... but if failed :(
  11. hey, im currently making a terrain generator and i am using multitexturing to texture the ground and water, but when i try to texture something with a single texture in the same scene the texture is not drawn. im pretty sure im doing something wrong with my multitexturing code because when i dont render the ground and water the other things texture is applied correctly. the code at the start of my terrain render loop is: glActiveTextureARB( GL_TEXTURE0_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, sandTexture ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );//change 'GL_MODULATE' to GL_REPLACE' for a more faded-together effect of the textures //-- glActiveTextureARB(GL_TEXTURE2_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, rockTexture ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_ALPHA); //part 2 - set 2nd texture glActiveTextureARB( GL_TEXTURE1_ARB ); glEnable( GL_TEXTURE_2D ); glBindTexture( GL_TEXTURE_2D, grassTexture); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_PREVIOUS_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR );//GL_SRC_COLOR glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_TEXTURE ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR );//GL_SRC_COLOR glTexEnvi( GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, GL_PRIMARY_COLOR_ARB ); glTexEnvi( GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, GL_SRC_COLOR ); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, Material_Diffuse); float rgbValue =0; float alphaValue = 0; glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); this is followed by the drawing the vertexes etc with three sets of texture coords. the code after that is just: glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE2_ARB); glDisable(GL_TEXTURE_2D); i do it a very similar way for my water. if i comment out the line to render the terrain AND water - the other textures are shown correctly, but as soon as i call either one of them, it pretty much kills my texturing on the other objects. any help would be appreciated :)
  12. weewun

    xinput lnk error

    OMG! posting a reply on the off chance anyone else has this error, but its bacuase i am a simpleton :( the line : #pragma comment(lib, “XInput.lib”) // Library containing necessary 360 has the worng kind of " in it, but this was only a warning from the compiler (it had thw wrong kind becasue i copy/pasted it) so it should be : #pragma comment(lib, "XInput.lib") // Library containing necessary 360 cheers to anyone who had a ponder over this :P
  13. ok, i am looking to get an xbox 360 controller working on the pc to code with. i have tried to create a class to encorporate the functions of xinput to make it easier to use, but i get a "LNK2001: unresolved external symbol _XinputGetState@8" error when i try to call the main function in it that updatres the state of the pad. the file compiles fine etc. and i can create a controll pad object, but when i try to call the CheckControllerStatus() function it comes up with this error. does anyone know what i am doing wrong? chers for any help. my .h file is shown below: ///////////////////////////////////////////// #include <Winerror.h> #include <windows.h> #include <XInput.h> // Defines XBOX controller API #pragma comment(lib, “XInput.lib”) // Library containing necessary 360 // functions // // // i do not know if this actually works yet because i have not had a chance to test it properly! // when i tried it at home i got a LNK error which the 'XInputGetState' // // // // // // class XBOX360CONTROLLER{ XINPUT_STATE state; // Data type that stores all the current states XINPUT_VIBRATION vibration; public: bool CheckControllerStatus() //updates controller state, and checks to see if a controller { //is plugged in (must be called every loop!) DWORD dwResult; // Used to store if a controller is connected // of a controller. ZeroMemory( &state, sizeof(XINPUT_STATE) ); // Zeros out the states of // the controller. // Get all the current states of controller 1 dwResult = XInputGetState( 0, &state ); //ERROR IS HERE // I THINK! //this bit sets the dead zone for the two analogue sticks :) if( (state.Gamepad.sThumbLX < XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE && state.Gamepad.sThumbLX > -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) && (state.Gamepad.sThumbLY < XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE && state.Gamepad.sThumbLY > -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE) ) { state.Gamepad.sThumbLX = 0; state.Gamepad.sThumbLY = 0; } if( (state.Gamepad.sThumbRX < XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE && state.Gamepad.sThumbRX > -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) && (state.Gamepad.sThumbRY < XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE && state.Gamepad.sThumbRY > -XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) ) { state.Gamepad.sThumbRX = 0; state.Gamepad.sThumbRY = 0; } //will make sure that the controller is connected, and returns true or false each time if( dwResult == ERROR_SUCCESS ) { // Controller is connected. return true;// } else { return false;// Controller is disconnected. } } int LeftTrigger(){ //returns the values of the left and right triggers if(state.Gamepad.bLeftTrigger && state.Gamepad.bLeftTrigger < XINPUT_GAMEPAD_TRIGGER_THRESHOLD) { return state.Gamepad.bLeftTrigger; } //returns a value between 0-255 } int RightTrigger(){ if(state.Gamepad.bRightTrigger && state.Gamepad.bRightTrigger < XINPUT_GAMEPAD_TRIGGER_THRESHOLD) { return state.Gamepad.bRightTrigger; } //returns a value between 0-255 } //for the 4 coloured buttons bool X(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_X) return true; else return false;} bool Y(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_Y) return true; else return false;} bool A(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_A) return true; else return false;} bool B(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_B) return true; else return false;} //for the D-pad bool Up(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) return true; else return false;} bool Down(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) return true; else return false;} bool Left(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) return true; else return false;} bool Right(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) return true; else return false;} //shoulder buttons bool RightShoulder(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) return true; else return false;} bool LeftShoulder(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_SHOULDER) return true; else return false;} //analogue sticks int RightStickX(){return state.Gamepad.sThumbRX;} //returns a valuse between -3768 and +3768 so be careful! int RightStickY(){return state.Gamepad.sThumbRY;} //returns a valuse between -3768 and +3768 so be careful! bool RightStickPressed(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) return true; else return false;} float LeftStickX(){return state.Gamepad.sThumbLX;} //returns a valuse between -3768 and +3768 so be careful! float LeftStickY(){return state.Gamepad.sThumbLY;} //returns a valuse between -3768 and +3768 so be careful! bool LeftStickPressed(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) return true; else return false;} //start and back buttons bool Start(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_START) return true; else return false;} bool Back(){if(state.Gamepad.wButtons & XINPUT_GAMEPAD_BACK) return true; else return false;} //for the rumble feature bool VibrateOn(int powerLeft, int powerRight){ if(powerLeft>0 && powerLeft<65535 && powerRight>0 && powerRight<65535){//vibration value must be between 0 and 65535 ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) ); //clear out the chuink of data to be safe vibration.wLeftMotorSpeed = powerLeft; // use any value between 0-65535 vibration.wRightMotorSpeed = powerRight; XInputSetState( 0, &vibration ); return true; } else return false; } void VibrateOff(){ //turns off the vibrations ZeroMemory( &vibration, sizeof(XINPUT_VIBRATION) ); //clear out the chunk of data to be safe vibration.wLeftMotorSpeed = 0; // use any value between 0-65535 vibration.wRightMotorSpeed = 0; XInputSetState( 0, &vibration ); } };
  • Advertisement
×

Important Information

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

GameDev.net 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!