• What do you need help with? Version 5
    5,752 replies, posted
  • Avatar of Lord Ned
  • [QUOTE=Richy19;35872991] If in OpenGL(2.1) I have a scene like the left, therefore the user views the right. Does the cube actually get rendered? [IMG]http://i.imgur.com/T6FK8.png[/IMG] The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?[/QUOTE] The GPU renders exactly what you tell it to, regardless of position. You'd have to devise your own culling method to reduce objects/faces/etc.
  • Avatar of Layla
  • [QUOTE=Richy19;35872991]The reason im asking is because in a voxel game(like minecraft for example) would it be necesairy to actually call or not call the draw for sides of cubes that are connected to other cubes?[/QUOTE] So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?
  • Avatar of darkrei9n
  • [code] float d; int v; float a; float b; float c; for(int p = 0; p < 1; p++) { v = rand(); a = sin(v); b = cos(v); d = sqrt(pCols*pCols + pRows*pRows); c = (rand() / RAND_MAX) * d - d/2; for(int i = 0; i < pCols * pRows; i++) { if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0) { vertexLoad[i].position.y += 1; } else { vertexLoad[i].position.y -= 1; } } } [/code] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.
  • Avatar of Richy19
  • [QUOTE=layla;35874570]So you're asking if you should draw faces that are hidden by other faces that are touching? No, obviously not, why would you?[/QUOTE] It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them
  • Avatar of dajoh
  • [QUOTE=darkrei9n;35874815] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.[/QUOTE] Most likely a floating point exception.
  • Avatar of darkrei9n
  • [QUOTE=dajoh;35874950]Most likely a floating point exception.[/QUOTE] Access Violation.
  • Avatar of Layla
  • [QUOTE=Richy19;35874928]It was more, does the GPU automatically not render them due to there being something infront of them, so the user doesnt see them[/QUOTE] No, you're still drawing faces that you don't need, just don't add them.
  • Avatar of Ziks
  • Is there a standard way in my .NET (C#) application of telling nVidia to use the main graphics card on laptops with both an integrated crap card and main powerful one? I've been doing it manually through the nVidia control panel but it would be nice if users wouldn't have to.
  • Avatar of Protocol7
  • [QUOTE=darkrei9n;35874815][code] float d; int v; float a; float b; float c; for(int p = 0; p < 1; p++) { v = rand(); a = sin(v); b = cos(v); d = sqrt(pCols*pCols + pRows*pRows); c = (rand() / RAND_MAX) * d - d/2; for(int i = 0; i < pCols * pRows; i++) { if(a*vertexLoad[i].position.x + b*vertexLoad[i].position.z - c > 0) { vertexLoad[i].position.y += 1; } else { vertexLoad[i].position.y -= 1; } } } [/code] For some reason this causes an unhandled exception. The thing is, that if I increase p to 100, it will work perfectly all the way up the last pass then fail. So I don't know what the fuck is wrong with it. If I remove the offending line (d = sqrt(pCols*pCols + pRows*pRows);) the next line down causes the same error, and if I remove that cos(v) causes it.[/QUOTE] Debug it, see what the variables are set to when it throws an error.
  • Avatar of darkrei9n
  • [QUOTE=Protocol7;35877398]Debug it, see what the variables are set to when it throws an error.[/QUOTE] Already figured it out. Had some code after it that was causing it. I do not know why it threw the error there though. [code] for(int y = 0; y < pCols*pRows; y++) { vertexLoad[i].color = RED; } [/code] I was using i instead of y.
  • Avatar of WTF Nuke
  • I am trying to get threads to work, and have a few questions. Firstly, I am trying to get a thread to use a function in a class(the thread is being created in a class as well). How can I get the function to cause the thread to sleep? I have this right now: [cpp]boost::this_thread.sleep(boost::posix_time::millisec(80));[/cpp] But the compiler says that "this_thread" is illegal use of namespace identifier in expression. Secondly, will a thread delete itself once it's finished running a function? And if a thread goes out of scope, will it get deleted even if the thread is still running? If so, what kind of pointer would I use for the thread to exist until it is done running. Edit: I accidentally used .sleep instead of ::sleep. Now, how can I use a function defined in a class to pass to a thread? Do I have to make the function static? I used boost::bind to make it work.
  • Avatar of Maksim
  • Can anyone help me with this? I'm making a simple minecraft launcher (Extra features, ect) and I go to try it on my friends computer, and the launcher comes up fine, but when he logs in to start minecraft, it doesn't work. Here is the snippet of code that starts it (works fine by me) [code] Dim process As New Process Dim info As New ProcessStartInfo Dim jarPath As String = "C:\Users\Dylan\AppData\Roaming\.minecraft\bin\minecraft.jar" info.FileName = "javaw" info.CreateNoWindow = True info.Arguments = "-cp " & Chr(34) & jarPath & ";%APPDATA%\.minecraft\bin/lwjgl.jar;%APPDATA%\.minecraft\bin/lwjgl_util.jar;%APPDATA%\.minecraft\bin/jinput.jar;" & Chr(34) & " " & Chr(34) & "-Djava.library.path=%APPDATA%\.minecraft\bin\natives" & Chr(34) & " -Xmx1024M -Xms512M net.minecraft.client.Minecraft " + player + " " + result(3) info.Arguments = info.Arguments.Replace("%APPDATA%", GetFolderPath(SpecialFolder.ApplicationData)) process.StartInfo = info process.Start() End[/code] Edit: I'm an idiot..... Dim jarPath As String = "C:\Users\[highlight]Dylan[/highlight]\AppData\Roaming\.minecraft\bin\minecraft.jar"
  • Avatar of elih595
  • [url]http://pastebin.com/PVbfMQG8[/url] I'm trying make the player collide with the wall. The wall is a 31x31 cube but I can only make the player collide on the left face of the cube. I can't figure out how to add more sides without them overriding each other.
  • [QUOTE=Richy19;35872991]If in OpenGL(2.1) I have a scene like the left, therefore the user views the right. Does the cube actually get rendered?[/QUOTE] The vertex transformations and whatnot will always occur. The GPU will try to create fragments for every polygon, but the actual shading may or may not occur depending on the results of depth testing. This is why a lot of games do early-z passes or render front-to-back; it saves on shading overhead in forward renderers. Effectively, you may save on some fragment shading, but you still have to actually process the primitives. This is why we have visibility testing and occlusion queries in games.
  • Avatar of smeismastger
  • Hello again folks, I require assistance once again in Visual basic 2010. I wouldn't ask this if I hadn't committed hours trying to solve it myself. But I need to get this nifty little simulation give somewhat logical numbers instead of astronomical coordinates and infinite decimals. Here's what I have trouble with in my nuclear strike simulator. There's a certain percentage of people from the total population of the city in certain range, and certain percent of those people in those ranges die. [code]Public Class Form1 Dim Oulu As Integer = 150000 ' Population of this city Dim Oulun_pinta_ala As Double = (1000 * 1410.17) ^ 2 'Area of whole city turned from square kilometers(1410.17) to meters Dim Oulun_asukastiheys As Integer = Oulu / Oulun_pinta_ala 'population density Dim Asukkaita_1140m_säteellä As Double = (1140 * 1140) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters Dim Asukkaita_3050m_säteellä As Double = (3050 * 3050) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters Dim Asukkaita_6200m_säteellä As Double = (6200 * 6200) * 3.14 / Oulun_pinta_ala * Oulu 'population in this range in meters[/code] [code] Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If lblAsukasmaara.Text = "0" Then MsgBox("Valitse Kaupunki") End If If lblAsukasmaara.Text = Oulu Then kuollut1 = (100 - 88) / 100.0 * Asukkaita_1140m_säteellä 'death toll in these ranges kuollut2 = (100 - 33) / 100.0 * Asukkaita_3050m_säteellä kuollut3 = (100 - 11) / 100.0 * Asukkaita_6200m_säteellä yht = kuollut1 + kuollut2 + kuollut3 tulo1 = kuollut1 tulo2 = kuollut2 tulo3 = kuollut3 [/code] But I get results like this (note that "kuollut", "kuolleita" etc means "dead") [code]Kuolleita 1140 metrin säteellä: 0,0369376203597919 Kuolleita 3050 metrin säteellä: 1,47622462665414 Kuolleita 6200 metrin säteellä: 8,10310283100606 Kuolleita yhteensä: 9,61626507801999[/code] please forgive my stupidity :c
  • Avatar of Commando123
  • Hey everyone. I am in c++ programming in college and I could use a little help with a final project. This is my project; [code] Your programming assignment is to develop a program to find out the winner of the gymnastics competition. The winner is the gymnast with the highest score. Each gymnast will receive a score from seven (7) judges. The highest and lowest score will be thrown out. The remaining five scores will be averaged to determine the gymnast final score. The output will list each gymnast with their final score followed by the overall winner. Your input will come from a file with the name - OLYMPICS.TXT and have the data listed as follows OLGA KORBUT 8.8 7.8 3.4 8.9 10.0 6.5 9.9 MARY LOU RETTON 5.6 5.5 6.5 7.5 4.8 2.1 4.5 NADIA COMANECI 9.9 8.9 9.4 9.3 9.6 8.8 9.2 The number of Gymnasts in the file will vary. The results will be written to a file called - FINAL.TXT and have the format of Gymnast Score OLGA KORBUT 8.38 MARY LOU RETTON 5.38 NADIA COMANECI 9.28 The winner is NADIA COMANECI[/code] I am having trouble with this concept. All we have learned this year is basic stuff. This one has to do with loops and files. I am not sure how to go about this. I have tried doing some code for the past few days and cant figure this out correctly. Any tips or help will be greatly appreciated. What I know I should do is create a loop that inputs all the values and creates a high low type deal. I am not sure how to go about that correctly.
  • Avatar of darkrei9n
  • [code] case WM_MOUSEMOVE: mousePT.x = (int)LOWORD(lParam); mousePT.y = (int)HIWORD(lParam); dx = mousePT.x - gOldPos.x; dy = mousePT.y - gOldPos.y; Camera().onPitch(dx); Camera().onYaw(dy); gOldPos = mousePT; break; [/code] Ran into an issue with using the Win API for input, for some reason this does not work at all in moving the camera. (Camera Code) [code] void Camera::onPitch(float angle) { D3DXMATRIX R; D3DXMatrixRotationAxis(&R, &gRight, angle); D3DXVec3TransformNormal(&gUp, &gUp, &R); D3DXVec3TransformNormal(&gLook, &gLook, &R); } void Camera::onYaw(float angle) { D3DXMATRIX R; D3DXMatrixRotationY(&R, angle); D3DXVec3TransformNormal(&gRight, &gRight, &R); D3DXVec3TransformNormal(&gUp, &gUp, &R); D3DXVec3TransformNormal(&gLook, &gLook, &R); } void Camera::onRoll(float angle) { D3DXMATRIX R; D3DXMatrixRotationZ(&R, angle); D3DXVec3TransformNormal(&gUp, &gUp, &R); D3DXVec3TransformNormal(&gRight, &gRight, &R); } [/code]
  • Avatar of Naelstrom
  • [QUOTE=Commando123;35900096]Hey everyone. I am in c++ programming in college and I could use a little help with a final project. This is my project; [code] Your programming assignment is to develop a program to find out the winner of the gymnastics competition. The winner is the gymnast with the highest score. Each gymnast will receive a score from seven (7) judges. The highest and lowest score will be thrown out. The remaining five scores will be averaged to determine the gymnast final score. The output will list each gymnast with their final score followed by the overall winner. Your input will come from a file with the name - OLYMPICS.TXT and have the data listed as follows OLGA KORBUT 8.8 7.8 3.4 8.9 10.0 6.5 9.9 MARY LOU RETTON 5.6 5.5 6.5 7.5 4.8 2.1 4.5 NADIA COMANECI 9.9 8.9 9.4 9.3 9.6 8.8 9.2 The number of Gymnasts in the file will vary. The results will be written to a file called - FINAL.TXT and have the format of Gymnast Score OLGA KORBUT 8.38 MARY LOU RETTON 5.38 NADIA COMANECI 9.28 The winner is NADIA COMANECI[/code] I am having trouble with this concept. All we have learned this year is basic stuff. This one has to do with loops and files. I am not sure how to go about this. I have tried doing some code for the past few days and cant figure this out correctly. Any tips or help will be greatly appreciated. What I know I should do is create a loop that inputs all the values and creates a high low type deal. I am not sure how to go about that correctly.[/QUOTE] Use sscanf to parse the data for each line, then loop through the numbers to find the highest and lowest score to discard them. Then get the remaining five scores and average them. It'd look something like this: [code]std::ifstream File; File.open("path/to/file.txt"); while (File.good()) { char FirstName[32]; char LastName[32]; float Scores[7]; char Buffer[256]; File.getline(Buffer,256); sscanf(Buffer,"%s %s %f %f %f %f %f %f %f",FirstName,LastName,&Scores[0],&Scores[1],&Scores[2],&Scores[3],&Scores[4],&Scores[5],&Scores[6]); float Min =10; float Max = 0; for (unsigned int i=0;i<7;i++) { if (Scores[i]>Max) { Max = Scores[i]; } if (Scores[i]<Min) { Min = Scores[i]; } } float Average = 0; for (unsigned int i=0;i<7;i++) { if (Scores[i] != Min && Scores[i] != Max) { Average += Scores[i]; } } Average/=5; std::cout << FirstName << " " << LastName << " average score is " << Average << "\n"; }[/code] Sorry for the lack of formatting, chrome won't let me tab.
  • Avatar of Commando123
  • Would you be able to do it with like simple looping and basic file i/o? We have not done arrays. I am completely lost. I am very new to this stuff and we only covered basic input, basic control structures, and functions.. lol Basically where I am thrown off in the file is how to get the names first then loop through the 7 numbers, knock off high and low, then move on to the next one infinitely. I'm not sure how to go about that. I understand your code but we are not to that level yet and I need to write it in more simpler terms.. The professor would not like me using arrays when he has not even hit them. I made myself a basic High Low code but I dont know where to go from here. [code] #include <fstream> using namespace std; int main() { ifstream scores; ofstream winners; int number, high, low; scores.open("scores.txt"); winners.open("winners.txt"); scores >> number; low = number; high = number; while (number >= 0) { if (number > high) high = number; if (number < low) low = number; scores >> number; } winners << "the highest number in the list is " << high << endl << endl; winners << "the lowest number in the list is " << low << endl << endl; scores.close(); winners.close(); return(0); } [/code] I just made the input file a string of numbers.
  • Avatar of darkrei9n
  • [QUOTE=Funley;35916119]In XNA, is 'matrix.Backward' the same as '-matrix.Forward'?[/QUOTE] I do not think it is. The order of matrix calculations does matter.
  • I made a game using code::blocks and sfml, but how do I build the release version without the "terminal" window and including variables, imgs, sounds, etc.. in the .exe file? thanks in advance
  • Avatar of Naelstrom
  • [QUOTE=Commando123;35909208]Would you be able to do it with like simple looping and basic file i/o?[/QUOTE] It seems really pointless to avoid useful tools and abilities of the language. Your teacher shouldn't punish you for going above and beyond
  • Avatar of Protocol7
  • Stringstream can help you when you have 3 names. Or one. So instead of parsing a first and last name you can just cin into a string. Also, write a function to split up a string with space delimiters, and return a string vector full of it. Then use a stringstream to test if the vector index is a string or a double ( istringstream >> int won't do anything if the stringstream can't be converted to int) and then do stuff accordingly.
  • Avatar of Richy19
  • I keep getting this: [quote]|36|undefined reference to `SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys)'|[/quote] I have it declared as: [cpp] namespace SOGLF { class Keyboard { enum Keys{...}; static inline bool IsKeyDown(SOGLF::Keyboard::Keys key); }; } [/cpp] and defined in a cpp file as: [cpp] bool SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys key) { bool result = false; switch (key) { .... } return result; } [/cpp]
  • Avatar of Layla
  • So I needed a position to screen method which is pretty much gluProject, so I wrote that: [cpp]bool Renderer::Project(const Vector3f& position, const Vector2i& windowSize, Vector2f& result) const { Vector4f in(position.x, position.y, position.z, 1.0f); in = m_projection * (m_modelView * in); if (in.w == 0.0f) { return false; } in.x /= in.w; in.y /= in.w; in.z /= in.w; in.x = in.x * 0.5f + 0.5f; in.y = in.y * 0.5f + 0.5f; in.z = in.z * 0.5f + 0.5f; result.x = in.x * windowSize.x; result.y = windowSize.y - (in.y * windowSize.y); return true; } [/cpp] The only problem is that the screen position is still on the screen when the position I'm projecting is behind the near clipping plane. So in that situation, I either need a way to make it return a position thats outside the screen (so I can clamp sprites to the edge to see what direction something is in) or find out if the point is behind the near clipping plane. [editline]13th May 2012[/editline] It seems I can just return out if the w component is less than 0.001, seems to work and that's what the source engine does, so whatever, it's good enough for me.
  • Avatar of HeroicPillow
  • [QUOTE=Richy19;35925323]I keep getting this: I have it declared as: [cpp] namespace SOGLF { class Keyboard { enum Keys{...}; static inline bool IsKeyDown(SOGLF::Keyboard::Keys key); }; } [/cpp] and defined in a cpp file as: [cpp] bool SOGLF::Keyboard::IsKeyDown(SOGLF::Keyboard::Keys key) { bool result = false; switch (key) { .... } return result; } [/cpp][/QUOTE] You should define inline functions within the header file. Also, make sure you actually want/need an inline function. [url]http://www.parashift.com/c++-faq-lite/inline-functions.html#faq-9.7[/url] [quote]It's usually imperative that the function's definition (the part between the {...}) be placed in a header file. If you put the inline function's definition into a .cpp file, and if it is called from some other .cpp file, you'll get an "unresolved external" error from the linker.[/quote]
  • Avatar of ben1066
  • Time to ask for help at Facepunch too I guess. I'm trying to add physics to my 3D game engine however the mesh is ending up horribly mis-aligned. [IMG]http://dl.dropbox.com/u/11197643/offsetmesh2.png[/IMG] [IMG]http://dl.dropbox.com/u/11197643/offsetmesh.png[/IMG] I'm using Jitter since it seems quite nice and it doesn't want to do everything for you. I'm trying to build a compound shape of convex hulls, one for each mesh in the model. Currently however the different hulls are being transformed incorrectly, resulting in a misaligned mesh. [url]http://pastebin.com/PNkWVfsz[/url] is my current physics entity class. Any help is much appreciated.
  • Avatar of AlienCat
  • [QUOTE=elih595;35880934][url]http://pastebin.com/PVbfMQG8[/url] I'm trying make the player collide with the wall. The wall is a 31x31 cube but I can only make the player collide on the left face of the cube. I can't figure out how to add more sides without them overriding each other.[/QUOTE] You could save the movement direction of the player and move it back with the reversed speed. Else you do something like this inside the block collision test: [code] if((playerX+26 >= wallX)and(playerX <= wallX+26)and(playerY+26 >= wallY)and(playerY <= wallY+26))then if(playerX+13 <= wallX+13) then //Move player to left else then //Move player to right end end [/code] I could be wrong with those values, I basically are trying to determinate if the player is to the right/left of the block. [QUOTE=Mete;35916573]I made a game using code::blocks and sfml, but how do I build the release version without the "terminal" window and including variables, imgs, sounds, etc.. in the .exe file? thanks in advance[/QUOTE] Did some searching and found this, pretty much what you ask about the terminal: [url]http://en.sfml-dev.org/forums/index.php?topic=595.0[/url] Baking images and sounds in the exe is NOT recommended since it will make the exe file giant. Instead, encrypt your resources or make them to binary or something if you want to protect them. However I found this: [url]http://en.sfml-dev.org/forums/index.php?topic=7089.msg46783#msg46783[/url]
  • Avatar of JohanGS
  • (In C#) How do I create a menu in which I can choose between different options? [IMG]http://f2.braxupload.se/v1r8oz.alternativ.png[/IMG] ^like that