Jump to content
  • Advertisement

Prog101

Member
  • Content Count

    197
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Prog101

  • Rank
    Member
  1. i am having a little trouble finding the X and Y positon on a Circle, the centre of the circle is 256 x and 256 y the radius of the circle is 150 i have 3 points i need to work out the 1st is p0 = 256x 256y the 2nd is p1 = 256x 406y the 3rd is p2 = ?x ?y the angle between p1 and p2 = 45 degrees does anyone know howi can work out the x and y of p2?
  2. thanks Codeka that is what i wanted, i wanted to calculate the time between two cars, i.e. how far car is position 1 is from the car in position 2. so with that:- float Car_GetTimeOfCarInfront(_Car *pMyCar, _Car *pCarInFront) { float LengthOfTrack = 2.5f; float mySpeed = TO_MPH(pMyCar->speedForwards);// speed in miles per hour /* the full distance around the track is between 0-1 , but the track distance is 2.5 miles */ float distance = pCarInFront->lapDistance - pMyCar->lapDistance; /*Between 0 - 1*/ distance *= LengthOfTrack;// distance between you and the other car, in miles float time = distance/mySpeed; // time in hours return time * 3600.0f; // time in seconds } [Edited by - Prog101 on February 18, 2009 4:23:59 AM]
  3. Hi guys i'm trying to get the time in seconds of the car in front but this dont seem right float Car_GetTimeOfNextCar(_Car *pCurrentCar, _Car *pNextCar) { float dist, speed, time, NextCarSpeed, CurrentCarSpeed; /* calculate speed */ CurrentCarSpeed = TO_MPH(pCurrentCar->speedForwards);/* in mph */ NextCarSpeed = TO_MPH(pNextCar->speedForwards);/* in mph */ /* Get the difference in speed between the 2 cars */ if (NextCarSpeed > CurrentCarSpeed) { speed = NextCarSpeed - CurrentCarSpeed; } else if(CurrentCarSpeed > NextCarSpeed) { speed = CurrentCarSpeed - NextCarSpeed; } else { speed = 0; } /* calculate distance */ dist = pNextCar->lapDistance - pCurrentCar->lapDistance; /*Between 0 - 1*/ dist *= pCurrentTrack->laplength; /*miles*/ /* calculate time */ /* Time = Distance / Speed */ time = dist/speed; /* Secs */ time*=1000.f; return time; } [Edited by - Prog101 on February 17, 2009 2:58:16 PM]
  4. Prog101

    help with a pulse colour

    i see how you are using the sin but i am a bit confussed as to how i would implement it in he code?
  5. hi guys need a quick hand, in the menu i want the selected menu item to pulse (i.e. the colour graduate from one colour up to another and then back down) i call the colour like so, what is the best way to do this , textColour = colourMake(190, 190, 190, 255); i do have a timer in my menu too which is gMenuTimer using windows xp. directX9 and Visual studio in cpp.
  6. using c and directX and windows i am adding sound to my game, i know how to add an effect to a event but i want to only add the effect to a channel FMOD_EVENT* Event; FMOD_REVERB_PROPERTIES prop = FMOD_PRESET_ARENA; FMOD_EventSystem_SetReverbProperties(gFModEventSystem, &prop); is it possible to add the preset arena sound to just a channel not the whole event?
  7. Prog101

    rendering a mirrored image

    got it for (i = 0;i < 4; i++) { pSpritePrim->Vertices.u = 1 - pSpritePrim->Vertices.u; }
  8. Using c++ and DirectX i am trying to render the mirror'd image (Left to Right) but i am failing to do so at the moment can anyone help /* wanting to mirror an imgage the Width and Height is the size of the image */ pSpritePrim->Vertices[0].u = 1; pSpritePrim->Vertices[1].u = 0; pSpritePrim->Vertices[2].u = 1; pSpritePrim->Vertices[3].u = 0; pSpritePrim->Vertices[0].x = x; pSpritePrim->Vertices[1].x += Width; pSpritePrim->Vertices[2].x = x; pSpritePrim->Vertices[3].x += Width; [Edited by - Prog101 on June 5, 2008 11:55:39 AM]
  9. So could i use Platform SDK, so would the exe work on any windows environment
  10. Hi guys , i am using DirectX and i want to make a WebCam game, since directShow is not part of the SDK what can i use instead?
  11. Hi Evil steve I see what you mean but i am struggling trying to implement it, _Bool BjGetTextureFromMem(IDirect3DTexture9 *pOutTexture, BYTE *pInData) { D3DLOCKED_RECT rect; HRESULT hResult; UINT i; hResult = IDirect3DDevice9_CreateTexture(pDirect3DDevice, 1280, 720, 1, 0, D3DFMT_A8R8G8B8, 0,&pOutTexture, NULL); if(FAILED(hResult)) { return FALSE; } hResult = IDirect3DTexture9_LockRect(pOutTexture,0,&rect, NULL, 0); if(FAILED(hResult)) { return FALSE; } for(i = 0; i < 720; ++i) { // Get a pointer to this "row" of pixels BYTE* pBits = (BYTE*)rect.pBits + i*rect.Pitch; memcpy(pOutTexture, pBits, 1280*4); // Again, assume 32-bit } IDirect3DTexture9_UnlockRect(pOutTexture,0); return TRUE; } how do i use pInData to set up pOutTexture [Edited by - Prog101 on February 17, 2008 5:17:23 PM]
  12. If i can get the data from a pTexture to pData, how can i get data from pData to pTexture? Shown below is a function that gets a data from the texure and puts the raw data into pData, _Bool SaveTexToMem(IDirect3DTexture9 *pTexture, BYTE* pData) { // Get the surface description for the texture, to determine size D3DSURFACE_DESC desc; D3DLOCKED_RECT rect; UINT i; HRESULT hResult; hResult = IDirect3DTexture9_GetLevelDesc(pTexture, 0, &desc); if(FAILED(hResult)) { return FALSE; } // Lock the first mip-level of the texture to get access to it's bits hResult = IDirect3DTexture9_LockRect(pTexture,0,&rect, NULL, D3DLOCK_READONLY); if(FAILED(hResult)) { return FALSE; } // Allocate output buffer - Assumes 32-bit (4 bytes per pixel) textures. pData = (BYTE *)malloc(desc.Width * desc.Height * 4 * sizeof(BYTE),MF_NONE); // Read data from locked rect for(i = 0; i < desc.Height; ++i) { // Get a pointer to this "row" of pixels BYTE* pBits = (BYTE*)rect.pBits + i*rect.Pitch; memcpy(pData, pBits, desc.Width*4); // Again, assume 32-bit } // Unlock the texture IDirect3DTexture9_UnlockRect(pTexture,0); return TRUE; }
  13. Prog101

    Saving a texture to memory

    that seems to work fine i had to play with it because it is in C, but how do i get the bpp fom the D3DFORMAT of the texture instead of hardcoding the 32 bit? bool SaveTexToMem(IDirect3DTexture9 *pTexture, BYTE* pData) { // Get the surface description for the texture, to determine size D3DSURFACE_DESC desc; D3DLOCKED_RECT rect; UINT i; HRESULT hResult; hResult = IDirect3DTexture9_GetLevelDesc(pTexture, 0, &desc); if(FAILED(hResult)) { DebugMessage("SaveTexToMem:: Can't GetLevelDesc"); return FALSE; } // Lock the first mip-level of the texture to get access to it's bits hResult = IDirect3DTexture9_LockRect(pTexture,0,&rect, NULL, D3DLOCK_READONLY); if(FAILED(hResult)) { DebugMessage("SaveTexToMem:: Can't LockRect"); return FALSE; } // Allocate output buffer - Assumes 32-bit (4 bytes per pixel) textures. pData = (BYTE *)malloc(desc.Width * desc.Height * 4 * sizeof(BYTE),MF_NONE); // Read data from locked rect for(i = 0; i < desc.Height; ++i) { // Get a pointer to this "row" of pixels BYTE* pBits = (BYTE*)rect.pBits + i*rect.Pitch; memcpy(pData, pBits, desc.Width*4); // Again, assume 32-bit } // Unlock the texture IDirect3DTexture9_UnlockRect(pTexture,0); return TRUE; }
  14. Prog101

    Saving a texture to memory

    Hi Evil steve thanks for your reply is it possible if you could gve me a quick example of what you mean and what aray data tye i would save the raw information in?
  15. Prog101

    Saving a texture to memory

    I know that the textures are already in memory in that LPDIRECT3DTEXTURE9 is a pointer. What i want to do is when i save the game data , i also save the texture in raw data, not create a image file type i.e. png. the texture that is passed is valid as it renders to the screen now i just want to create an array that holds the raw data so i can then load the raw data when i need to as a texture and display it. the errror i get is that the buffer that i save the texture to is invalid, what am i doing wrong, if anyone can help?
  • 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!