• Advertisement

spiralmonkey

Member
  • Content count

    68
  • Joined

  • Last visited

Community Reputation

206 Neutral

About spiralmonkey

  • Rank
    Member
  1. Fast (but approximate) cartesian to polar coord conversion

    Thanks Emergent, does (o-p) need to be normalized for that to work?
  2. I was hacking around trying to develop a faster way to convert cartesian to polar coordinates without needing to use and expensive atan2(x,y) and sqrt(x*x + y*y) to get the angle and distance and came up with this fast approximation. I use it for collision avoidance so it doesn't need to be completely accurate. Accuracy is acceptable for my purposes with an accuracy of +/- 1 degree for the angle and +/- 6 percent for the distance. Would be curious is people can find further optimizations, or if anyone finds it useful. Wonder if the 'ifs' could be eliminated somehow... /* FAST, approximate cartesian to polar conversion Accurate to +/- 1 degree in angle and 6% for distance by Alan Kapler, 2009 */ #define ANGLE_FUDGE 1.0472 // to radians = 3.1415929/3 to degrees = 60 // setting this to 1 will eliminate a // multiplication from the conversion float vectToAngleAndDist(float TX, float TY, float &dist) { if(TY>TX) { if(TY>-TX) { // top dist = fabs(.3333*TX)+TY; return ANGLE_FUDGE * (TX/dist); } else { // left dist = fabs(.3333*TY)-TX; return ANGLE_FUDGE * (TY/dist-1.5); } } else { if(TY>-TX) { // right dist = TX+fabs(.3333*TY); return ANGLE_FUDGE * (1.5-TY/dist); } else { // the ass dist = fabs(.3333*TX)-TY; if (TX<0) { return ANGLE_FUDGE * (-3-TX/dist); } else if (TX>0) { return ANGLE_FUDGE * (3-TX/dist); } } } return 0; }
  3. Hi, I have a program which renders D3D graphics to 2 monitors (fullscreen mode, vsync on) but each of the monitors seem to have slightly different refresh rates. They're running on the same graphics card (NVidia). I have been unable to solve the problem of stuttering of playback that seems happen from the differences between frame rates. I have one D3D device for each monitor, and use the IDirect3DSwapChain9::Present() function to advance the frames. I decoupled the drawing and present()ing between the 2 monitors, but nothing seemed to help the rough playback. Finally i got desperate and as a test created 2 separate threads, one for each monitor/device, each thread merely doing an extremely simple moving graphic followed with a present(). Each thread looked something like this: for (int i=0; i<500; i++) { pd3dDevice->BeginScene(); pd3dDevice->DrawSomeGraphicToJudgeMotion(); pd3dDevice->EndScene(); pd3dSwapChain->Present(NULL, NULL, NULL, NULL, 0); } If i run each thread individually the animation on it's monitor is totally smooth, but if i run both threads simultaneously - pulsing and stuttering playback on both monitors. Can anyone offer an insight as to why i can't decouple the present()ing of the 2 devices? I tried the same thing in OpenGL and GL seems to do it fine - no stuttering problems, so I know it's possible. Thanks.
  4. Further investigation reveals that the filerequester works successfully after every 2nd pd3dDevice->Present() call. That's why it seems to be working randomly about half the time. After 1 present() it will fail to hide the window, but after the 2nd Present() it will work fine. Anyone have an idea why this might be?
  5. I could, but will that not affect my app's performance? I want to keep my wait for vsync and be able to run at the maximum refresh rate with as much efficiency as possible. Is there not a way to make sure my D3D window can be temporarily stowed away while a user uses the file requester? Or is there a way to make the file requester place nice as a child of the D3D window? Surely it's possible because half the time it does seem to work fine.
  6. Hi All, I'm having a frustrating problem. I have a virtual aquarium called Dream Aquarium that runs in double-buffered fullscreen D3D, and I'm having problems adding a file requester to it. I open a file requester with GetOpenFileName(&ofn) but it is only visible about HALF the times i attempt to open it (my graphics drawing stops when the function is called because it's all one thread). The other half of the time it seems the file requester window did not pop to the front or was drawn on top of. So i tried other things. I tried doing a ShowWindow(myD3Dwindow, SW_HIDE) to hide my D3D window, exposing the desktop to show the file requester... which again worked only HALF the time. The other half of the time I just had a frozen aquarium image while somewhere in the background the file requester waited. I can see my mouse cursor is responding to the file requester, but it's covered by the D3D image. I even tried calling SW_HIDE several times, with Sleep() functions in between. I've tried SW_MINIMIZE, with the same results. Everything I try only seems to stow the aquarium away randomly half the time. Does this have to do with double-buffering? I'm using Direct3D 8.1 on XP if that's any help. Any suggestions?? Would there be a proper method to adding a filerequester to this type of D3D window? (free aquarium for anyone who can help!) Thanks very much, Alan [Edited by - spiralmonkey on July 29, 2008 4:30:41 PM]
  7. I'm designing a directx app that's to run on most non-sucking graphics cards from say 2000 and beyond, and i'm wondering what people have found the general support is for certain directx practices. - is it okay to specify a SPECULAR component, but not a DIFFUSE component, or am i asking for trouble by not having a diffuse, even if i can guarantee the args in my first texstate won't be D3DTA_CURRENT - is it okay to have a TEX2 without having a TEX1? - what is the general support across cards for the D3DTA_TEMP argument? Am i limiting myself by using it? Thanks in advance
  8. Texturing dilemma

    Hi, i'm working on texturing fish for my virtual aquarium, using the old-school non-pixel shader method, and i've hit a problem i'm having trouble figuring out. I'm applying 3 maps - a diffuse map (modulated by point color), and the fish's reflection map which should be reflecting a 3rd environment map. Seems standard. The thing that's throwing me off is i want my diffuse map to be double the brightness (MODULATE2X). The problem is, because i have 2 maps that need to modulate each other (The reflectivity map must modulate the environment map), i need to do those first, yes? SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); // fish reflectivity SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_SPECULAR ); SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); // environment SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT ); SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE ); now i would normally use a D3DTOP_MULTIPLYADD to add the diffuse component (modulated by point color) but i don't see how i can add it at DOUBLE the value. There's only MODULATE2X, no MULTIPLYADD2X Can anyone help me with this? Is there something i'm missing? Thanks in advance da [Edited by - spiralmonkey on August 15, 2006 1:12:18 PM]
  9. Know anything about Free Promo CDs?

    You're right, that's a typo (fixed now). Yes, i looked them up before and saw the lawsuit. They seem annoying to their target market. Regardless they may be a good route to get my product out there, though they told me this CD would only be marketed to Latvia and Estonia - not sure what kind of market there is for screensavers out there! However, i'm more interested if this ends up posing any danger to me and my business to associate with them. Is there any danger to publishers to be included on these CDs, or can it only be a good thing?
  10. I was contacted by someone from a company called International Masters Publishers about including the free trial version of my screensaver in one of their 'free Cds'. Does anyone know anything about this kind of marketing and should i be apprehensive about doing this? The fact that THEY are approaching ME about it makes me nervous somehow. I guess i've seen this kind of thing before with the free Cds included in magazines. What's in it for them to do this, and can it possibly bite me in the ass? -alan [Edited by - spiralmonkey on May 4, 2006 11:48:44 AM]
  11. Rare http problem

    quite right hplus, my bad - that worked its way in only as i was 'distilling' my code. I've fixed it in my OP. So other than that the code looks like it's legal and should work? I suppose i need to look into proxies (which i know ABSOLUTELY nothing about) and the tools you've mentioned (ditto) thanks for the help so far, alan
  12. Licensing of software technology

    Actually, after talking more the deal isn't quite what i thought. Turns out they'd probably want ME to create the content (fishtank) or just use what i have. Boils down more to a licensing fee plus time worked on it. So my question becomes, what would a reasonable licensing fee be, and what's to stop them from just buying a copy for $20 and playing it in their lobby?
  13. Licensing of software technology

    Thanks all for your good advice. Looks like i'm getting a lawyer. This project, if it goes through, will actually be for a major Las Vegas hotel! I just found that out. Las Vegas - where their motto itself is an agreement of non-disclosure. :) alan
  14. Rare http problem

    Hey all, I'm experiencing a seldom-occuring problem with my auto-updater. I have a lot of users and the code below seems to work for 99% of people. However, for the odd user, it doesn't. Consistently they say they use Norton Firewall (perhaps just coincidence) but have either turned it off or allowed all programs to go through, but my code still fails for them. They seem fairly knowledgable about internet issues, and say they don't have problems with other software, so i assume the problem is on my end. Note i've boiled this code down to just the basic internet-related calls. It seems to be SendRequest() that fails with a "The system cannot find the file specified" I'm really wondering, am i doing something illegal or improper? I realize i'm a hack at this stuff and don't know much about internet protocols. Is it luck this code even works at all? Thanks in advance! --------------------------------------------------------------------------- CInternetSession session(“Some_Name”, 1, PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, 0); httpServer = session.GetHttpConnection(“www.mysite.com”, 0); try { CHttpFile* pFile; pFile = httpServer->OpenRequest( CHttpConnection::HTTP_VERB_GET, “cgi-bin/myCommand.cgi”); pFile->SendRequest(); pFile->QueryInfoStatusCode(errorcode); } catch (CInternetException* pEx) { here it catches an exception saying "The system cannot find the file specified" } [Edited by - spiralmonkey on May 3, 2006 4:59:58 PM]
  15. Hey all, I've just been approached by an individual about licensing some technology i've created. I've been working on a virtual aquarium for 1.5 years and this individual wants to use it to create a 12-screen wide super-panoramic virtual aquarium for a company lobby. Sounds cool. Here's the agreement i was thinking of: I'm no lawyer, but I'm thinking I would grant them the rights to use my existing software in exchange for exclusive rights to the content (aquatic environments) that they create for this lobby - that i would own and sell these aquatic environments as part of my product. As well i would get an hourly fee for any programming required to accomodate their project. Does that sound reasonable or realistic, or perhaps stupid? Does anyone have experience in how much a project like this would be worth, and if i should charge some kind of licensing fee for my technology, and how much that might be worth? You can check out my virtual aquarium here: www.dreamaquarium.com thanks, any advice would be much appreciated. alan kapler
  • Advertisement