_Sauce_

Members
  • Content count

    246
  • Joined

  • Last visited

Community Reputation

116 Neutral

About _Sauce_

  • Rank
    Member
  1. [quote name='Narf the Mouse' timestamp='1351464036' post='4994851']This is a form of endless loop. Any loop that does not have a 100% valid, viable and usable exit condition is [i]very bad.[/i][/quote] Technically this would be recursion, and you would overflow the stack long before you run out of memory allocating [font=courier new,courier,monospace]Menu[/font] objects, unless [font=courier new,courier,monospace]Menu[/font] allocates hundreds of megabytes of data in addition to each child [font=courier new,courier,monospace]Menu[/font].
  2. [quote name='MJP' timestamp='1340648112' post='4952726'] Your vertex shader outputs homogeneous coordinates in clip space. When you divide XYZ by W, you get "normalized device coordinates" where X = -1 is the left side of the viewport, x = 1 is the right side, Y = -1 is the bottom, Y = 1 is the top, Z = 0 is the near clip plane, and z = 1 is the far clip plane. Any coordinates outside of these bounds will be clipped. After that comes the viewport transform, which looks like this: [code] X = (X + 1) * Viewport.Width * 0.5 + Viewport.TopLeftX Y = (1 - Y) * Viewport.Height * 0.5 + Viewport.TopLeftY Z = Viewport.MinDepth + Z * (Viewport.MaxDepth - Viewport.MinDepth) [/code] At this point the Y-axis is flipped such that (0, 0) is the top left, and (Viewport.Width, Viewport.Height) is the bottom right. [/quote] Thanks MJP, that helps a lot.
  3. I held off for 4 days on creating this thread, exhausting every option I could think of, and not even 10 minutes after I posted did I find the solution. [source lang="cpp"]const int windowWidth = 800, windowHeight = 600; D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(vp)); vp.TopLeftX = 0; //Change these two lines vp.TopLeftY = 0; // vp.Width = (float)windowWidth; vp.Height = (float)windowHeight; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; g_pImmediateDeviceContext->RSSetViewports(1, &vp);[/source] MSDN says what the possible values for the D3D11_VIEWPORT structure are but it doesn't clearly explain what those values mean. I wrongly assumed the top left corner would be the minimum possible value given the conventions used for texture addressing and window layouts. Can anyone offer an in-depth explanation of the interpretation of these values?
  4. I'm learning DirectX 11 and I'm having trouble with the perspective divide. Specifically, the perspective transform is resulting in all my vertices getting clipped before rasterisation. I'm testing with a 200x200 cube centered at the origin. You can see an image of the problem in PIX below [img]http://img849.imageshack.us/img849/4861/prevs.jpg[/img] [img]http://img837.imageshack.us/img837/7189/postvs.jpg[/img] After the the w-divide my vertices lie wholly outside of clip space, but I can't see anything wrong with the matrices I'm passing to my shaders. Setting up the viewport [source lang="cpp"]const int windowWidth = 800, windowHeight = 600; D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(vp)); vp.TopLeftX = D3D11_VIEWPORT_BOUNDS_MIN; vp.TopLeftY = D3D11_VIEWPORT_BOUNDS_MIN; vp.Width = (float)windowWidth; vp.Height = (float)windowHeight; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; g_pImmediateDeviceContext->RSSetViewports(1, &vp);[/source] Building the matrices [source lang="cpp"] VSConstants VSConstData; D3DXMatrixIdentity(&VSConstData.world); D3DXMatrixLookAtLH(&VSConstData.view, &eye, &lookAt, &up); D3DXMatrixPerspectiveFovLH(&VSConstData.projection, toRadians(90.0f), (float)windowWidth / (float)windowHeight, 0.01f, 1000.0f); VSConstData.worldViewProjection = VSConstData.world * VSConstData.view * VSConstData.projection; D3DXMatrixInverse(&VSConstData.invWorldViewProjection, 0, &VSConstData.worldViewProjection); g_pImmediateDeviceContext->UpdateSubresource(g_pVSConstants, 0, 0, &VSConstData, 0, 0);[/source] and here is the contents of the constants buffer as reported by PIX [img]http://img163.imageshack.us/img163/1633/constantsbuffer.jpg[/img] Vertex & pixel shaders [source lang="cpp"]float4x4 world; float4x4 view; float4x4 projection; float4x4 worldViewProjection; float4x4 invWorldViewProjection; Texture2D g_texture; SamplerState defaultSampler { MipFilter = LINEAR; MinFilter = LINEAR; MagFilter = LINEAR; }; struct VSInput { float4 position : POSITION; float3 normal : NORMAL; float2 texcoord : TEXCOORD0; }; struct PSInput { float4 position : SV_POSITION; float3 normal : NORMAL; float2 texcoord : TEXCOORD0; }; PSInput VSDefault(VSInput input) { PSInput result; result.position = mul(input.position, world); result.position = mul(result.position, view); result.position = mul(result.position, projection); result.normal = input.normal;//mul(input.normal, invWorldViewProjection); result.texcoord = input.texcoord; return result; } float4 PSDefault(PSInput input) : SV_TARGET { return g_texture.Sample(defaultSampler, input.texcoord); }[/source] I have a feeling the problem is to do with my viewport settings as the post-vs output looks fine. It is only after clipping that I lose everything. Unfortunately I can't find much information on the appropriate values for the D3D11_VIEWPORT structure and trial and error has proven unsuccessful. Any idea what I'm doing wrong?
  5. Strange C++ Problem

    [quote name='Telios' timestamp='1323872621' post='4893845'] [quote name='_Sauce_' timestamp='1323871956' post='4893842'] FYI, returning a const [font="Courier New"]big_integer[/font] by value is technically meaningless. If it were a reference or pointer then it would make sense. [/quote] Habit... It stops being doing things like: big_integer a, b, c; (a + b) = c; By accident. [/quote] I've never seen const used this way but that's a fair point. I still feel like I'm not seeing the actual code responsible for your crash so I'm afraid I have no further suggestions. I'll be interested to hear what the cause was if you figure it out.
  6. Strange C++ Problem

    [font="Courier New"]return ...[/font] will call the copy constructor again because you are passing the result by value. This is the expected order of execution, which VC9 demonstrates. [font="Courier New"]operator - copy constructor operator -= copy constructor [/font]I couldn't reproduce the crash, so either you're doing something funky in operator -= that you're not showing us, or the problem lies in your driver program. FYI, returning a const [font="Courier New"]big_integer[/font] by value is technically meaningless. If it were a reference or pointer then it would make sense.
  7. Monte carlo path tracing

    [quote name='Saghi' timestamp='1323353013' post='4891784'] Hi, I'm trying to implement Monte Carlo path tracing with importance sampling by dividing the equation into 2parts : direct illumination and indirect illumination. I'm using phong BRDF sampling for importance sampling. The problem that I have is with the glossy objects, all of them have a black line in the border. and it seems that the refraction is not completely correct and doesn't give the feeling of glass. Do you have any idea what the problem can be? [/quote] I've never implemented refraction in a raytracer before, but i'll take a stab in the dark and pose the question anyway; have you offset the position of the refracted rays by epsilon to prevent self-intersection at the ray's origin?
  8. Adaptive music in RTS games

    [quote name='Jay Taylor' timestamp='1314237160' post='4853487'] Hi guys. I was thinking, not all that many RTS games seem to have very interactive music. TBH though I have not played alot of RTS besides Starcraft. Do you think interactive music would alot to RTS games (I think so) and can you think of some games which does it particularly well? What RTS has well thought out adaptive music? [/quote] Many of the command & conquer games have this feature. I know for certain that C&C Generals and C&C3: Tiberium Wars do. Company of Heroes is another RTS game that does this extremely well and in my opinion it adds a lot to the atmosphere of the game - company of heroes is the most atmospheric RTS I know and it has a great cinematic feel
  9. If you don't like the idea of indexing into a 1D texture that sweeps over the spectrum (why not?) then you can first map your float value into the [url="http://en.wikipedia.org/wiki/HSV_colour_space"]HSV[/url] colour space, with a saturation and value of 1, and hue of 60..360 (you'll want to ignore the first 60 degrees otherwise you'll end up with red at both the low and high end of the scale). Then you simply convert HSV to RGB. There are [url="http://en.wikipedia.org/wiki/HSV_colour_space#Converting_to_RGB"]plenty of resources[/url] on this so I won't go into details. There's really nothing wrong with the texture lookup approach - it will be much simpler in a shader (only severaly lines of your chosen shader language), though you might find the HSV->RGB approach better suited if you're doing this on the CPU.
  10. PIX Error on experiment startup

    [quote name='brasslips2' timestamp='1308129061' post='4823547'] For some reason the above doesn't work to add the quotes... instead I get: warning C4129: 'D' : unrecognized character escape sequence warning C4129: 'T' : unrecognized character escape sequence Any 1337 macro programmers know how to fix this?[/quote] The reason you get these two warnings is because the MY_SOLUTIONDIR expands to a path with backslashes (\) instead of forward slashes (/). Backslashes will be treated as the beginning of an escape sequence and, depending on the character following it, may be interpreted as some other random character (\\, \t, \r, \n are common ones) Solution: #define MY_SOLUTIONDIR "C:\\Users\\***\\Desktop\\***\\TestProject\\Debug\\" or... #define MY_SOLUTIONDIR "C:/Users/**/Desktop/***/TestProject/Debug/" or you can do what MJP said Neither of these are great solutions to the problem though. Your application should be capable of finding its resources regardless of the location it is run from. You can set the current working directory (on windows) to the executable directory using [url="http://msdn.microsoft.com/en-us/library/ms683197%28v=vs.85%29.aspx"]GetModuleFileName()[/url] and [url="http://msdn.microsoft.com/en-us/library/aa365530%28v=vs.85%29.aspx"]SetCurrentDirectory()[/url] so that your relative paths function correctly. If you're targetting the 360 (XNA) then obviously you don't have to worry about any of this, and you can use one of the previous suggestions.
  11. point cloud to triangular mesh

    If you're looking for an existing implementation then you can try [url="http://meshlab.sourceforge.net/"]meshlab[/url]. It has several surface reconstruction filters you can choose from and it supports the .ply format (among many others).
  12. Rendering and interacting with an UI

    There are GUI libraries out there that can do most of the work for you if you don't want to reinvent the wheel. CEGUI comes to mind (Personally, I'm not a huge fan - the current default skins are ghastly, but there is work being done on modern skins which look very nice)
  13. Have you called AnimatedSprite::Load() before calling AnimatedSprite::Update()? The most likely problem is that sprite is NULL. It wouldn't hurt to modify AnimatedSprite::Update() as follows; [code] #include <cassert> void Update(float DeltaTime) { assert(sprite); //... }[/code]
  14. Regarding Legality

    [quote name='Hodgman' timestamp='1302485169' post='4796895'] If you take a copyrighted work and duplicate/redistribute it without the owners permission, you're infringing their rights. That's just as true for pictures, words or sounds. It doesn't matter if you drastically change the original work so that it's only used as a base, even if you distort it beyond being recognisable, it's still technically infringement. [url="http://www.templetons.com/brad/copymyths.html"]http://www.templeton.../copymyths.html[/url] [/quote] Men at Work were sued 28 years after the release of "Down Under" for copyright infringement. I think it makes a good example in this situation. [quote]The flute part of the recording of the song is allegedly based on the children's rhyme "[url="http://en.wikipedia.org/wiki/Kookaburra_%28song%29"]Kookaburra[/url]", written by Marion Sinclair for a Girl Guides competition in 1935. Sinclair died in 1988[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-aa34-1"][2][/url][/sup] and the rights to the Kookaburra song were deemed to have been transferred to publisher [url="http://en.wikipedia.org/wiki/Larrikin_Records"]Larrikin Music[/url] on 21 March 1990.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-15"][16][/url][/sup] In the United States, the rights are administered by Music Sales Corporation in New York City. In June 2009, 28 years after the release of the recording, Larrikin Music sued Men At Work for copyright infringement, alleging that part of the flute riff of "Down Under" was copied from "Kookaburra". The counsel for the band's record label and publishing company (Sony BMG Music Entertainment and EMI Songs Australia) claimed that, based on the agreement under which the song was written, the copyright was actually held by the Girl Guides Association.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-16"][17][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-17"][18][/url][/sup] On 30 July, Justice Peter Jacobson of the Federal Court of Australia made a preliminary ruling that Larrikin did own copyright on the song, but the issue of whether or not Hay and Strykert had plagiarised the riff was set aside to be determined at a later date.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-18"][19][/url][/sup] On 4 February 2010, Justice Jacobson ruled that Larrikin's copyright had been infringed because "Down Under" reproduced "a substantial part of [i]Kookaburra[/i]".[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-19"][20][/url][/sup] When asked how much Larrikin would be seeking in damages, Larrikin's lawyer Adam Simpson replied: "anything from what we've claimed, which is between 40 and 60 per cent, and what they suggest, which is considerably less."[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-20"][21][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-21"][22][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-22"][23][/url][/sup] In court, Larrikin's principal Norman Lurie gave the opinion that, had the parties negotiated a licence at the outset as willing parties, the royalties would have been between 25 and 50 per cent.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-FCA698-23"][24][/url][/sup] On 6 July 2010, Justice Jacobson handed down a decision that Larrikin receive 5% of royalties from 2002.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-FCA698-23"][24][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-24"][25][/url][/sup] Until this high-profile case, "Kookaburra"'s standing as a traditional song combined with the lack of visible policing of the song's rights by its composer had led to the general public perception that the song was within the public domain.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-25"][26][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-mudcat.org-26"][27][/url][/sup] The revelation of "Kookaburra"'s copyright status, and more-so the pursuit of royalties from it, has generated a negative response among sections of the Australian public.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-27"][28][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-28"][29][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-29"][30][/url][/sup][sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-30"][31][/url][/sup] In response to unsourced speculation of a Welsh connection, Dr Rhidian Griffiths pointed out that the Welsh words to the tune were published in 1989 and musicologist Phyllis Kinney stated neither the song's metre nor its lines were typical Welsh.[sup][url="http://en.wikipedia.org/wiki/Down_Under_%28song%29#cite_note-mudcat.org-26"][27][/url][/sup][/quote] Source: [url="http://en.wikipedia.org/wiki/Down_Under_%28song%29"]Wikipedia[/url] [media]http://www.youtube.com/watch?v=MeG-hNXXy6I[/media] Personally, I don't even see the resemblance of the flute section of the song with the children's rhyme
  15. [quote name='nobodynews' timestamp='1298271002' post='4776940'] Native code is not allowed on the Xbox with XNA Creators Club so you will need to port said library. [/quote] Thanks