• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=dingusnin;41665735]Hi, I need a bit of help on a concept: I am currently experimenting on vertices and maths. I currently need help working out how to have a camera and how I would draw what the camera would see. Right now, I am able to rotate a camera around an origin with user input from a 2d plane with a click and drag system, However, I need a camera that can move around, And look around. I don't know if I should move the world around the camera (which i can do, But will remove a lot of functionality like sky dispersion shader), Or move the camera though the world, At which point I wouldn't be able to calculate which planes need drawing unless I did an extensive vertex connection system. What I am asking is how have other people done this in the most efficient way possible.[/QUOTE] How are you doing the visibility testing at the moment?
[QUOTE=thf;41671927]How are you doing the visibility testing at the moment?[/QUOTE] Right now, I have a zoom set up so when rotating around the origin, All vertices will be in frame, And to decide which planes to draw, I test each normal against my view vector, And checking the dot product to see if the plane should be drawn.
I'm having quite the weird problem coding with C++ and SDL. I have an integer that grabs the return value from a function that initializes SDL, and then a part below where I show an error message depending on the problem during initializing. If I have an 'std::cout' that displays the error integer in between the integer-modifier and the error message part it works fine, if I remove it, it shows an error. Here's the entire code that produces the error with all unrelated parts cut out and a simple blitted test.bmp added for demonstrative purposes. [code] #include <SDL/SDL.h> #include <iostream> #include "Windows.h" //MessageBox SDL_Surface* displaysurface; SDL_Surface* test; int ErrorInteger; enum { SDLINITFAIL = 1, SDLSETVIDEOMODEFAIL, }; int VideoInit() { if((SDL_Init (SDL_INIT_EVERYTHING)) != 0) { return SDLINITFAIL; } if ((displaysurface = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF)) == NULL) { return SDLSETVIDEOMODEFAIL; } } int main (int argc, char* args[] ) { ErrorInteger = VideoInit(); if (ErrorInteger == SDLINITFAIL) { MessageBox(0, "SDLINITFAIL Error Goes Here", "Fuck", MB_OK ); return 1; } if (ErrorInteger == SDLSETVIDEOMODEFAIL) { MessageBox(0, "SDLSETVIDEOMODEFAIL Error Goes Here", "Shit", MB_OK ); return 1; } test = SDL_LoadBMP( "test.bmp" ); SDL_BlitSurface( test, NULL, displaysurface, NULL ); SDL_Flip(displaysurface); SDL_Delay (2000); SDL_FreeSurface(test); SDL_FreeSurface(displaysurface); SDL_Quit(); } [/code] [img]http://i.imgur.com/75SHNbV.png[/img] If I add this part it works fine: [code] ... int main (int argc, char* args[] ) { ErrorInteger = VideoInit(); [highlight][b]std::cout << "ErrorInteger: " << ErrorInteger << std::endl;[/b][/highlight] if (ErrorInteger == SDLINITFAIL) { MessageBox(0, "SDLINITFAIL Error Goes Here", "Fuck", MB_OK ); return 1; ... [/code] [img]http://i.imgur.com/vLRy7hm.png[/img] I have no idea how this even makes sense, even though adding the 'std::cout' somehow works fine I'm sure this will be the cause of a problem sooner or later, so I'd be glad if someone helped me out explaining how this works.
Definitely weird. Do you know how to use a debugger? If not, what tools are you using to program (just to see which debugger you would use then)?
Make sure you're using SDL 2.0, but otherwise try making the ErrorInteger value non-global. My compiler complains when I have non-static declarations like that in the global scope. It shouldn't be the problem because you've set it right before anything else, but it's acting with undefined behavior. Especially when you change the code ever so slightly. So that's what I think the problem is. :u
That code is not SDL 2.0. Although it is not considered good practice, that global variable should work fine. There's no undefined behavior (in the library there might be, but not in the piece of code shown). [editline]1st August 2013[/editline] (hope this auto-merges) A note about the compiler-warning: -Wmissing-variable-declarations? Declare it as extern first.
Thanks ZeekyHBomb!
If this is your first programming language, then I can recommend "Teach Yourself C++ in One Hour a Day" (formerly "Teach Yourself C++ in 21 Days"), that worked for me. I've seen a couple of others recommend "Accelerated C++", but I have not read it. As an intermediate book, "Effective C++" is great. It does expect you to be able to write C++ code, but it has great tips and gives you a better understanding of some common C++ implementations that you can use to write better code. And this: [QUOTE=ZeekyHBomb;41619043]General recommendations for the book: Look that it's not too old, only a couple of years. Languages and idioms change. Then look for reviews. Not just if it's good or bad: different authors will employ different learning styles. Pick something that suits you. And of course make sure it's a book targeted at beginners. You probably won't understand much if it's a book for intermediates. [...] [editline]28th July 2013[/editline] Oh, and in general when learning a programming language, play around with it. Trial and error is a fine way to aid learning. Knowing what error-messages mean and how to deal with them is important. Try doing stuff a little differently than in the book. Try to search the internet for a solution if necessary, although don't drift too far away or get discouraged when it doesn't work the way you want it to. You can also post here if you're getting errors you don't understand :smile:[/QUOTE]
I'm having some issues with regex in my c++ dice roller program; I can't seem to get an integer from a string properly.. My pattern is "(\\d+)d(\\d+)", and the input string should be in the format XdX. I'm using regex_search and it's capturing the two values correctly, but I can't seem to get them as integers and there doesn't seem to be any way to cast them explicitly.. [code] std::string input; std::tr1::regex pattern( "(\\d+)d(\\d+)" ) std::tr1::smatch results; std::cin >> input; if( std::tr1::regex_search( input, results, pattern ) ) { std::cout << results[ 1 ]; // int numRolls = ( int )results[ 1 ]; /* this errors saying there's no suitable conversion to integer */ // for loop for dice rolling } [/code] The std::cout shows the correct value, (eg if I type 4d6 it prints 4 to the console) but I have no way of getting that value as an integer so I can actually use it..
[QUOTE=Falcqn;41675219]I'm having some issues with regex in my c++ dice roller program; I can't seem to get an integer from a string properly.. My pattern is "(\\d+)d(\\d+)", and the input string should be in the format XdX. I'm using regex_search and it's capturing the two values correctly, but I can't seem to get them as integers and there doesn't seem to be any way to cast them explicitly.. [code] std::string input; std::tr1::regex pattern( "(\\d+)d(\\d+)" ) std::tr1::smatch results; std::cin >> input; if( std::tr1::regex_search( input, results, pattern ) ) { std::cout << results[ 1 ]; // int numRolls = ( int )results[ 1 ]; /* this errors saying there's no suitable conversion to integer */ // for loop for dice rolling } [/code] The std::cout shows the correct value, (eg if I type 4d6 it prints 4 to the console) but I have no way of getting that value as an integer so I can actually use it..[/QUOTE] [URL=http://en.cppreference.com/w/cpp/regex/match_results/str]results[1].str()[/URL] should give you a string of it.
Got it working now! Zeh Matt pointed me in the direction of stoul() :)
[QUOTE=Naelstrom;41672965]Make sure you're using SDL 2.0, but otherwise try making the ErrorInteger value non-global. My compiler complains when I have non-static declarations like that in the global scope. It shouldn't be the problem because you've set it right before anything else, but it's acting with undefined behavior. Especially when you change the code ever so slightly. So that's what I think the problem is. :u[/QUOTE] I am using SDL 1.2 and I won't be switching over for a while seeing as SDL 2.0 is just recently released and there's not as many resources available for it as 1.2. Making ErrorInteger local to main causes the error to occur even with the std::cout, so I guess that kind of makes it less odd? But then I don't see why it wouldn't work properly. [QUOTE=ZeekyHBomb;41672724]Definitely weird. Do you know how to use a debugger? If not, what tools are you using to program (just to see which debugger you would use then)?[/QUOTE] I don't know how to use one and I'm using Code::Blocks with MinGW at the moment, I also have Visual Studio 2012 available. Also, I'm not quite sure how the returns inside the VideoInit function are actually triggered, if I comment them out, it runs fine. But if I put something before the return statement it doesn't get executed.
Code::Blocks should be fine. [url]http://wiki.codeblocks.org/index.php?title=Debugging_with_Code::Blocks[/url] You'll want to break on the top of the VideoInit function. The breakboint marker marks the line to break before it is executed. Then run the program with the debugger, the breakpoint should hit. Continue by pressing F7 to step over each line. You can examine which return is hit and back in main when the "current line"-indicator (yellow triangle) points to the line after the VideoInit-call you can examine the value in ErrorInteger, I think by hovering over it with the cursor.
Having trouble with Ogre and c++, trying to make my objects in different classes , i cant initialise instances of a class from my base class ogre app wizard generated.i'm probably using a bad design pattern or approach, please advise how i can fix this! :)
I'm not sure I understand you right. You have a base class, let's call that Base, and a couple of derived classes inheriting from base, let's call them Derived0, Derived1. You're trying to initialize instances of Derived0 and Derived1 in Base? You can break that circular dependence via pointers, heap memory and forward declaration, but it's probably better to think of another approach. You should try to avoid circular dependencies.
What Visual studio should I use for a Source mod for Source 2007?
[url=https://developer.valvesoftware.com/wiki/Compiler_Choices]Pick your poison[/url] :wink:
Is there a guide on how to code something like this in C++? [IMG]http://www.slowdays.org/mortis/reviews/fallout1/fallout1-05-uglysonofabitch.jpg[/IMG] The dialog, I mean. I'll try to explain the best I can. When you click a dialog in the box, it brings you to the next line, something to that matter. I want to know how to code this.
I don't know the traditional approach, but in my eyes, they're essentially like FSMs. FSM stands for Finite-State Machine. Basically you have a bunch of states, a starting state, several ending states, where the machine can finish, and define transitions between the states. For a kind of scripting language for this, you then want to have names for the states, sentences the NPCs can say, answer-possibilities that point to other states, conditional state-switches and modification of game-state (such as giving the player an item). A mock up how it could look like: [code]START // starting state { [npc.pissed] PISSED // if pissed goto PISSED [not player has towel] FRIENDLY_NO_TOWEL // not pissed and player has no towel -> goto FRIENDLY_NO_TOWEL [] FRIENDLY_TOWEL // not pissed, but player has towel -> goto FRIENDLY_TOWEL } PISSED { say // the NPC will say these when entering the state { "..." // could be more strings with equal probability to be chosen for variety // or maybe just in order for less chance of repetition } [] END // unconditionally ends the conversation } FRIENDLY_NO_TOWEL { say { "Hello there stranger. Nice day we're having." } answers // are displayed for selection by the user { [player.skills.talking >= 2] "Quite jolly indeed, Sir!" ANS_POLITE // only available if player has talking-skill >= 2 [] "Fuck you and you're mother!" ANS_MEAN } } FRIENDLY_TOWEL { say { "Are you already making use of my marvelous towel?" } [] END } ANS_POLITE { say { "Have this towel, my friend. Towels are very useful." } action // actions are for modifying state { give player towel } [] END } ANS_MEAN { say { "Dear lord, what foul language! I shall never talk to you again." } action { set npc.pissed true } [] END }[/code]
[QUOTE=ZeekyHBomb;41684273][FSMs][/QUOTE] Another thing to note is that they are usually written either as [URL="http://www.moddb.com/engines/fonline-engine/images/dialog-editor"]dialogue tree[/URL], [URL="http://www.burgzergarcade.com/blogs/liquide-blue/chat-mapper-dialog-editor-games"]flow chart[/URL] (with an editor, don't mind the second one being commercial, it's just an example) or as [URL="http://www.renpy.org/doc/html/menus.html"]script[/URL] (doesn't need a special editor and the files are more readable).
Take a look at the scripting language of something like Ren'Py if you'd like another idea of how it could be done in a visual novel environment.
[QUOTE=ZeekyHBomb;41622728]According to [url=http://docs.python.org/3.3/library/subprocess.html#popen-constructor]the reference[/url] it does.[/QUOTE] Works on my laptop but not my desktop, weird.
Perhaps a bug in some Python version?
Hmm... I see then. So, should I make an external file that contains the dialog trees like how Fonline is set up and have a script inside the program that parse the external file, instead of having many scripts inside my program?
You mean instead of somehow hard-coding each dialog? There are a lot of benefits in using some form of external scipt. In some languages you could also come up with a DSL, but then you'd also have to re-compile it everytime you change a line (if you're using non-interpreted language). The example I posted can be represented with nested arrays (for the overall structure) and function objects (for conditions and actions).
has anyone tried to set up stuff such that git works over your own btsync network? I'm completely new to git, only ever used github for retrieval of shit
So I decided to start using FreeImage instead of SOIL for loading my textures. However, a problem has randomly appeared which I can't figure out why happens. This is my loadHeightMap function in my terrain class, using the SOIL functions to load: [code] void Terrain::loadHeightMap( std::string sPath ) { int width, height, channels; unsigned char* image = SOIL_load_image( Utils::contentPath( sPath ).c_str(), &width, &height, &channels, SOIL_LOAD_RGB ); _terrain = (float*) malloc( sizeof( float ) * width * height * 3 ); _normals = (float*) malloc( sizeof( float ) * width * height * 3 ); if( image == NULL ) { printf( "ERROR! HeightMap file could not be loaded. (Did you make sure the path is correct?)\n" ); return; } for( int z = 0; z < MAP_Z; z++ ) { for( int x = 0; x < MAP_X; x++ ) { _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 0 ] = float( x ) * MAP_SCALE; _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 1 ] = (float) image[ ( z * MAP_Z + x ) * 3 ]; _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 2 ] = -float( z ) * MAP_SCALE; } } SOIL_free_image_data( image ); _initialize(); } [/code] and this is the code that I use for loading with FreeImage: [code] void Terrain::loadHeightMap( std::string sPath ) { FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; FIBITMAP* dib(0); fif = FreeImage_GetFileType( Utils::contentPath( sPath ).c_str(), 0 ); if( fif == FIF_UNKNOWN ) fif = FreeImage_GetFIFFromFilename( Utils::contentPath( sPath ).c_str() ); if( fif == FIF_UNKNOWN ) { printf( "ERROR! Failed to figure out the filetype of height map." ); return; } if( FreeImage_FIFSupportsReading( fif ) ) dib = FreeImage_Load( fif, Utils::contentPath( sPath ).c_str() ); else { printf( "ERROR! Failed to load height map." ); return; } BYTE* bDataPointer = FreeImage_GetBits(dib); int test = FreeImage_GetWidth( dib ) ; int test2 = FreeImage_GetHeight( dib ) ; _terrain = (float*) malloc( sizeof( float ) * test * test2 * 3 ); _normals = (float*) malloc( sizeof( float ) * test * test2 * 3 ); for( int z = 0; z < test; z++ ) { for( int x = 0; x < test2; x++ ) { _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 0 ] = float( x ) * MAP_SCALE; _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 1 ] = (float) bDataPointer[ ( z * MAP_Z + x ) ]; _terrain[ ( z * 3 * MAP_Z + x * 3 ) + 2 ] = -float( z ) * MAP_SCALE; } } //FreeImage_Unload( dib ); _initialize(); } [/code] So this code works, atleast I believe so. However, the problem is that as soon as I start using this function instead of the one using SOIL ( which works fine ), my FreeType font loading code randomly breaks, giving me an Access Violation exception at: msvcr100d.dll!_lock_file(_iobuf * pf) Line 237 C. These seems completely unrelated and totally random, so is due to a stack overflow error stemming somewhere from my FreeImage code? I've never had to deal with something such as this before, so I have no idea where to start.
Look for something like valgrind for MSVS. If you are unable to find anything you can try to compile with clang (gcc might have gotten this too, I'm not sure though) and use the AddressSanitizer feature. [QUOTE=Em See;41698392]has anyone tried to set up stuff such that git works over your own btsync network? I'm completely new to git, only ever used github for retrieval of shit[/QUOTE] [code]cd $BTSYNC_DIR mkdir repo cd repo git init cd $PROJECTS_DIR git clone $BTSYNC_DIR/repo[/code] Then whenever btsync syncs, you can git-pull it into your working copy and when you git-push, it gets synced with btsync.
I am having a small problem with rendering normal text (non signed-distance). I am using nearest filtering. At some resolutions, the text looks squashed or has other oddities. Here's an example; OK [img]http://i.imgur.com/k7Apbba.png[/img] BAD [img]http://i.imgur.com/rFc6qkh.png[/img] I thought it was caused by vertex positions and texcoords which weren't pixel-aligned (so to say), but I could not fix this. Does anyone have any advice or solutions? Thanks. [editline]4th August 2013[/editline] Nevermind! Fixed it by using a different method of alignment. It might help someone, although it is sorta case specific; [code]float biasX = frac( ( ( posX * scaleX ) * 2 - 1 ) * screenWidth ); biasX /= screenWidth; float biasY = frac( ( ( posY * scaleY ) * 2 - 1 ) * screenHeight ); biasY /= screenHeight;[/code] Send these to your shader, and subtract it from the vertex position in the vertex shader.
Sorry guys, I'm not a programmer by any means, but am apart of a team that is developing low-level police database interface software. We've came to a stalemate on how to get the best security not only for transmission of the data, but the actual database itself. We already Salt passwords and are getting a SSL certificate, but we need to be able to have assurance that our SQL database itself is not susceptible to attacks and if it were, how to protect the data inside without them being able to read it in plain english. Any tools, techniques, open-source projects out there that can encrypt/secure a database?
Sorry, you need to Log In to post a reply to this thread.