• What do you need help with? V. 3.0
    4,884 replies, posted
Whenever I try to remove data from a table I get an error [img]http://gyazo.com/0115c69b4db3fd16c5dab1858838cae0.png[/img] This is the entire line [lua] for k, v in ipairs(dep) do table.remove(shots, v) end[/lua] And the entire code if need be: [url]http://pastebin.com/tGqDxYrE[/url]
[QUOTE=awfa3;31162665]Hey, I'm reading 3D Math Primer for Graphics and Game Development right now and it is explaining everything greatly. However, when it got to the dot product, I got the Algebra part easy, (Add up the products of the corresponding components) however it then showed me a "Geometric Interpretation" with a picture like this: [IMG]http://i.imgur.com/N8h56.png[/IMG] Then, with no showing of how it got it whatsoever, it told me that the dot product of any 2 vectors is also the product of their magnitudes and the cosine of the angle in between them. (a*b=|a||b|cos(Theta)) I confirmed for myself that this works and I have used it to solve for the angle in between vectors but I don't know how they got it. If someone can walk me through it, I'm sure my understanding will be better on this.[/QUOTE] Is anyone going to help me?
[QUOTE=Wyzard;31174486]It looked like you may have actually been drawing one of the side faces instead. [b]From what I can tell, the face being drawn is definitely the top face[/b] Any chance of getting a pair of images from the same viewpoint? [b]I can try, I'll post back with images[/b] What are you using for glBlendFunc? (GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA are probably what you want.) [b]That's the one I'm using[/b] I'm not really familiar with Minecraft, but do water blocks actually work like blocks, where you can remove one from the middle of the ocean or plop one onto dry land? If not, and water should always be just a single flat surface, it'd be much simpler to draw that surface as a single big rectangle — maybe one per chunk, or one for the bounding rectangle of all chunks currently loaded. You can use polygon offset to avoid problems with Z-fighting between the water plane and top faces of blocks at sea level. [b]Water does act like blocks, you can plop one down on land and so on (it flows and stuff, but we don't need to worry about that for now)[/b][/QUOTE] Bolded my replies
[QUOTE=TheCloak;31175277]Whenever I try to remove data from a table I get an error [img]http://gyazo.com/0115c69b4db3fd16c5dab1858838cae0.png[/img] This is the entire line [lua] for k, v in ipairs(dep) do table.remove(shots, v) end[/lua] And the entire code if need be: [url]http://pastebin.com/tGqDxYrE[/url][/QUOTE] The documentation states, that remove expects a position, not a value. The last note of [url=http://lua-users.org/wiki/TableLibraryTutorial]this page[/url] suggests, that you should do [lua]shots[v] = nil[/lua]
[QUOTE=awfa3;31175392]Is anyone going to help me?[/QUOTE] the wikipedia article explains it well: [url]http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation[/url]
[QUOTE=ZeekyHBomb;31175447]The documentation states, that remove expects a position, not a value. The last note of [url=http://lua-users.org/wiki/TableLibraryTutorial]this page[/url] suggests, that you should do [lua]shots[v] = nil[/lua][/QUOTE] Thank you! Sorry for the silly question, I'm still very new to lua. [lua] for k, v in ipairs(shots) do if v.y < 0 then table.remove(shots, shots[v]) else v.y = v.y - 3 end end[/lua] Worked fine. [editline]17th July 2011[/editline] Oh no, when I shoot multiple bullets that code seems to remove all of the bullets. Any ideas? [editline]17th July 2011[/editline] Nevermind, I've fixed it.
Well, I'm not a Lua-coder at all :v: Try table.remove(shots, k)
[QUOTE=ZeekyHBomb;31175676]Well, I'm not a Lua-coder at all :v: Try table.remove(shots, k)[/QUOTE] Bah, I apologise for that. I should've gotten that.
[QUOTE=Chris220;31175432]From what I can tell, the face being drawn is definitely the top face[/QUOTE] You may find it helpful to draw just a single water block to see what it looks like. If you don't want to change your "world", just put a coordinate check in the water-drawing code to ignore all blocks except the one with a certain coordinate. Then walk around that block and look at it from all sides, with blending and without.
[cpp]char * somestring = new char[sizeof(somestring2)]; strcpy_s(somestring, sizeof(somestring), somestring2);[/cpp] How can something like this possibly fail with the buffer being to small? [IMG]http://cold.netburst.co.uk/file/Microsoft_Visual_C%2b%2b_Debug_Library-2011-07-17_20.48.03.png[/IMG]
[QUOTE=marcin1337;31173039]quick question, I have a HTTP Get request in my code [code] sprintf( buffer , "GET /site/pages/lol.html \r\n" ); send( HTTPServer , buffer , strlen( buffer ) , 0 ); sprintf( buffer, "Host: www.ecollege.ie \r\n" ); send( HTTPServer, buffer, strlen( buffer ) , 0 ); sprintf( buffer, "Connection: close\r\n" ); send( HTTPServer, buffer, strlen( buffer ) , 0 ); recv( HTTPServer, buffer, sizeof( buffer ), 0 ); cout << buffer << endl;[/code] it sends me the the index file and in that index file I have a function that finds all files, then I send GETs to get all the files. [code] sprintf( buffer , "GET /site/css/print.css \r\n" ); send( HTTPServer , buffer , strlen( buffer ) , 0 ); sprintf( buffer, "Host: www.ecollege.ie \r\n" ); send( HTTPServer, buffer, strlen( buffer ) , 0 ); recv( HTTPServer, buffer, sizeof( buffer ), 0 );[/code] for instance a css file I get the index but then I don't get any files I request for. do I need to close the socket and re init it after every GET or what?[/QUOTE] You have to close and re init if you don't pass "Connection: Keep-Alive". Keep-Alive declares that you are going to send multiple requests with a single connection. Also you have to check the responses header to make sure the sure the socket is still alive and not closed.
[QUOTE=ColdFusionV2;31176063]How can something like this possibly fail with the buffer being to small?[/QUOTE] You didn't include the declaration of somestring2, but I'm guessing it's a char* like somestring is. sizeof() on a char* doesn't give you the length of the string, it gives you the size of the pointer: 4 bytes in a 32-bit program, 8 bytes in a 64-bit program. Use strlen(), and add 1 to account for the null terminator. Or just use std::string.
[QUOTE=ColdFusionV2;31176063][cpp]char * somestring = new char[sizeof(somestring2)]; strcpy_s(somestring, sizeof(somestring), somestring2);[/cpp] How can something like this possibly fail with the buffer being to small? [IMG]http://cold.netburst.co.uk/file/Microsoft_Visual_C%2b%2b_Debug_Library-2011-07-17_20.48.03.png[/IMG][/QUOTE] sizeof(somestring2) will return the size of a pointer if it is not a static array. Use strlen. [editline]17th July 2011[/editline] :ninja:
[QUOTE=Wyzard;31176179]You didn't include the declaration of somestring2, but I'm guessing it's a char* like somestring is. sizeof() on a char* doesn't give you the length of the string, it gives you the size of the pointer: 4 bytes in a 32-bit program, 8 bytes in a 64-bit program. Use strlen(), and add 1 to account for the null terminator. Or just use std::string.[/QUOTE] [QUOTE=ZeekyHBomb;31176186]sizeof(somestring2) will return the size of a pointer if it is not a static array. Use strlen.[editline]17th July 2011[/editline]:ninja:[/QUOTE] I quote from MSDN "When the [B]sizeof[/B] operator is applied to an object of type [B]char[/B], it yields 1. When the [B]sizeof[/B] operator is applied to an array, [U]it yields the total number of bytes in that array, not the size of the pointer represented by the array identifier.[/U]" [URL="http://msdn.microsoft.com/en-us/library/4s7x1k91(v=vs.71).aspx"]http://msdn.microsoft.com/en-us/library/4s7x1k91(v=vs.71).aspx[/URL] Why isn't it behaving as expected?, is it because its defined as a char * and not a proper char array confusing the compiler?
It's not "confusing" the compiler, but yes, an array is different from a pointer. What's confusing [i]you[/i] is that [url=http://www.lysator.liu.se/c/c-faq/c-2.html]arrays "decay" into pointers[/url] automatically, so you can often use an array as if it were a pointer. But not the other way around, in this case.
sizeof is used to return the size of a specific data type or a variable or an array. If you use it on a "char *", it's gonna return the size of a "char *". Use strlen to get the length of a c-style string, or just use std::string which is what you really should be doing in the first place here.
[QUOTE=Chris220;31176344]sizeof is used to return the size of a specific data type or a variable or an array. If you use it on a "char *", it's gonna return the size of a "char *". Use strlen to get the length of a c-style string, or just use std::string which is what you really should be doing in the first place here.[/QUOTE] -snip- Nevermind.
So, im pretty stuck on how to convert coordinates that are relative to the cameras current position into clip space. Would someone mind explaining how you might (practically) go about transforming the vertex xyz? I understand what clip space *is*, just not how to get there
Here's the two views with blending on and off: (Right click -> View image for full size) [quote][img]http://i.imgur.com/JkcbH.png[/img][/quote] [quote][img]http://i.imgur.com/GUIVe.png[/img][/quote] And here's a water block being rendered by itself with blending turn on [quote][img]http://i.imgur.com/34ioG.png[/img][/quote] As you can see, the line between solid and translucent seems to be entirely independent of the block's faces - it "moves" when I move side to side.
For my game, I'm trying to make the bullets be able to go diagonal towards the mouse position ( or straight, depending on where the mouse is ), now, it sort of does this, but doesn't go diagonal exactly, it'll go straight then left or whatever to get to the position, and when it gets there, it spazzes out oddly. [lua]f v.x > v.destX then v.right = true if v.right == true then v.x = v.x - 3 else v.x = v.x + 3 end else v.x = v.x + 3 end if v.y > v.destY then v.up = true if v.up == true then v.y = v.y - 3 else v.y = v.y + 3 end else v.y = v.y + 3 end[/lua] That's the code for the direction. [url]http://pastebin.com/uDzepiT2[/url] - Full code. Any ideas?
[QUOTE=Chris220;31176814]As you can see, the line between solid and translucent seems to be entirely independent of the block's faces - it "moves" when I move side to side.[/QUOTE] Hmm, you're right, that boundary doesn't seem to be related to the faces of the cube. Is that "solid" part really solid, or is it translucent showing the sky behind it without the land in between? Change your sky color to something like red and see how it affects the water block. Your drawing order may have something to do with this: if the water block in the foreground is drawn first, the land blocks behind it will fail the depth test when they're drawn later, and consequently not be drawn at all. Translucent surfaces generally need to be drawn in farthest-to-nearest order, after all the opaque surfaces have been drawn. But if that's the problem, it's not quite clear why some of the land is being drawn before that water block, and the rest after.
Is anyone else having an issue starting threads on the MSDN XNA section?
I've been working at this for a bit and can't seem to figure out the issue. I'm just practicing programming in F# by calculating pi using the formula [img]http://upload.wikimedia.org/math/2/2/b/22b7522ff9aef6794f2342a8d1b65648.png[/img] and pi = 4/Z. The code I have currently is as follows. [code]#light let invert x = 4I/x let factorial x = Seq.fold(*) 1I [1I .. x] let pow x y = Seq.fold(fun acc i -> x * acc) 1I [1I .. y] let permutation n k = (factorial n) / factorial (n-k) let epi i = (((6I*i)+1I)*((permutation 3I i)/2I))/((pow 4I i)*(pow (factorial i) 3I)) let pi = Seq.fold(fun acc i -> acc + epi i) 0I { 0I .. 100I } |> invert printfn "%A"pi open System Console.ReadKey(true)[/code] It outputs 4 no matter what you change the upper limit for the fold to on line seven. I assume it has something to do with how I'm using the "I" typecast, but I'm really not too sure.
[QUOTE=Wyzard;31177199]Hmm, you're right, that boundary doesn't seem to be related to the faces of the cube. Is that "solid" part really solid, or is it translucent showing the sky behind it without the land in between? Change your sky color to something like red and see how it affects the water block. Your drawing order may have something to do with this: if the water block in the foreground is drawn first, the land blocks behind it will fail the depth test when they're drawn later, and consequently not be drawn at all. Translucent surfaces generally need to be drawn in farthest-to-nearest order, after all the opaque surfaces have been drawn. But if that's the problem, it's not quite clear why some of the land is being drawn before that water block, and the rest after.[/QUOTE] Aye, it's showing the sky through it. Depth test failure it is then... Dangit. I was trying to avoid having to sort everything back to front... is there a quick, easy method of doing it? Because I can't think of any. Surely there's some way I could use a depth buffer to do transparency though? Like... let's say the water is being drawn before the terrain behind it, each fragment is placed in a higher location in the depth buffer, then later on the terrain fragment is put in a deeper location. Once everything's done, I can blend all the alpha values together (because they're now in the correct order in the depth buffer) and draw that fragment. No idea how I'd go about that, but is it at least possible?
[QUOTE=Robbis_1;31170936]Well yeah, that's the output when I compiled it, I uploaded it to save you the trouble of doing it. But when you start CMake and open the folder, there's a list of things first time you press Configure. Did you change anything or did you just press configure and generate? Because I had to change some things before generating.[/QUOTE] I didn't really change anything no, I just did what the readme said. I set the source directory and build directory, clicked Configure... then it asked which version of Visual Studio am I using. I selected VS2010, clicked Configure once more and then clicked Generate. If I can't work out the problem I'll use your compiled libraries for the time being (thanks again for that :smile:), but I'd rather sort out my CMake issue.
[QUOTE=Chris220;31177682]Aye, it's showing the sky through it. Depth test failure it is then... Dangit. I was trying to avoid having to sort everything back to front... is there a quick, easy method of doing it? Because I can't think of any. Surely there's some way I could use a depth buffer to do transparency though? Like... let's say the water is being drawn before the terrain behind it, each fragment is placed in a higher location in the depth buffer, then later on the terrain fragment is put in a deeper location. Once everything's done, I can blend all the alpha values together (because they're now in the correct order in the depth buffer) and draw that fragment. No idea how I'd go about that, but is it at least possible?[/QUOTE] The technique you've described is close to the one detailed on [url=http://www.yakiimo3d.com/2010/07/19/dx11-order-independent-transparency/]this page[/url]. It stores a linked list per fragment, and performs depth sorting and blending at a later stage. It's quite expensive and requires DX11 hardware though. There are other techniques which go some way to achieve order independent transparency such as depth peeling, however each tends to have it's own drawback. I think it's most common for games to implement an old fashioned depth sort though.
[QUOTE=Jookia;31167362]I forgot, you're not suppose to use the right tool for the job, even if doing so sacrifices compiler optimizations and code readability.[/QUOTE] Doesn't sacrifice the compiler optimizations at all. Unless the compiler is an idiot, it should convert the for loops to while loops. [editline]17th July 2011[/editline] thus, actually decreasing the compilers load by a bit
[QUOTE=Map in a box;31178662]Doesn't sacrifice the compiler optimizations at all. Unless the compiler is an idiot, it should convert the for loops to while loops. [editline]17th July 2011[/editline] thus, actually decreasing the compilers load by a bit[/QUOTE] The compiler can unroll for-loops though, increasing the performance. Note: Never try to out-smart the compiler. And code readability still gets lost.
[QUOTE=bean_xp;31178162]The technique you've described is close to the one detailed on [url=http://www.yakiimo3d.com/2010/07/19/dx11-order-independent-transparency/]this page[/url]. It stores a linked list per fragment, and performs depth sorting and blending at a later stage. It's quite expensive and requires DX11 hardware though. There are other techniques which go some way to achieve order independent transparency such as depth peeling, however each tends to have it's own drawback. I think it's most common for games to implement an old fashioned depth sort though.[/QUOTE] Hes using openGL tho
sort the rendering of blocks by depth, so that you render the entire world without water and then render the water on top of that. I have a feeling you're drawing the water before the world (at least in some direction)
Sorry, you need to Log In to post a reply to this thread.