• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=Abbers100;32818510]I need help with making a cell shader for a future mod for HL2. How would I set about doing this?[/QUOTE] ...Do you happen to mean a shader that achieves a cell shading -esque look?
Okay, using Code::Blocks with the included MinGW compiler here. I've been trying to compile Ogre3D here for the past month or so, but couldn't. I've started fresh for what, the 7th time now? So okay, CMake now works perfectly, but when I try to compile the the project, I get this: [cpp]Using makefile: Makefile [ 0%] Generating OgreWin32Resources.rc.obj The system cannot find the path specified. mingw32-make.exe[2]: *** [OgreMain/OgreWin32Resources.rc.obj] Error 1 mingw32-make.exe[1]: *** [OgreMain/CMakeFiles/OgreMain.dir/all] Error 2 mingw32-make.exe: *** [all] Error 2 Process terminated with status 2 (0 minutes, 0 seconds) 0 errors, 0 warnings [/cpp] What do? I don't even know what it can't find, it just spits that out at me. [b]Edit:[/b] Why is this funny? :saddowns:
I'm using netbeans to create a java desktop application (with a GUI) and I want to know how I can make the window spawn on a specific location on the screen. Windows specific solutions are fine too.
You could try using setBounds(): [code] public class Frame extends JFrame { Frame() { super(); int x = (your desired x position); int y = (your desired y position); this.setBounds(x,y,this.getWidth(),this.getHeight()); } public static void main(String[] args) { new Frame(); } } [/code] (Of course if you use this you'll need to have set the frame height/width before you call setBounds()) If you're using the GUI builder in netbeans, edit the source and create a new method which sets the bounds to whatever you like, then call it in the constructor OR if you're creating an instance of your GUI from a different class you can just call setBounds() from that instance. i.e. in some class: [code] JFrame frame = new JFrame(); frame.setBounds(x,y,w,h); [/code] You can also set a frame to be in the middle of the screen: [code] JFrame frame = new JFrame(); frame.setLocationRelativeTo(null); [/code]
Does converting pixel measurement to something else, such as meters, matter that much in 2D - if so, how would I do that.
[QUOTE=NotoriousSpy;32837825]Does converting pixel measurement to something else, such as meters, matter that much in 2D - if so, how would I do that.[/QUOTE] It all depends on your project.
I'm working on an assignment in C++, and the course has honestly been pretty poor, over the last week they've introduced us to C++ really poorly and I have a pretty vague understanding of classes and inheritance, but they never really explained the syntax properly. The assignment requires I use classes and functions etc that were in pre-made header files, I write the functions/constructors etc and stick with the basic "plan" that they outlined with the headers, which is pretty difficult because they haven't commented any of it. Anyway, that's just background, the issue I'm having is I have a class, TicTacToeView: [code]class TicTacToeView { public: virtual void printBoard() = 0; virtual void declareWinner( const Player& aPlayer) = 0; }[/code] And a class TicTacToeConsoleView that inherits from the first class: TicTacToeConsoleView.h [code] class TicTacToeConsoleView : public TicTacToeView { //Ommitted all the data types/functions etc. public: TicTacToeConsoleView( TicTacToe* aModel ); }[/code] In my cpp file for ConsoleView, I've written the constructor function: [code] #include "TicTacToeConsoleView.h" TicTacToeConsoleView::TicTacToeConsoleView(TicTacToe* aModel) { //Line 4 //Constructor code ommitted. }[/code] But my compiler gives me the error "Undefined reference to 'vtable for TicTacToeConsoleView', pointing to line 4 of my cpp file. Obviously it's some syntax error or whatever, but I can't for the life of me figure it out, I've been googling it for an hour and I still can't figure it out. I asked my tutor but he told me to rewrite my constructor function. Rewriting the same code in the same syntax, obviously didn't result in any change in the problem. Help me oh great gods of the programming section :(
[QUOTE=NotoriousSpy;32837825]Does converting pixel measurement to something else, such as meters, matter that much in 2D - if so, how would I do that.[/QUOTE] You can use any measurement unit you want, but you'll have to convert them back to pixels for drawing anyway. This is only useful if you are doing something where numbers can get so big that the decimal precision starts to be a problem, things like physics.
[QUOTE=Empty_Shadow;32838826]But my compiler gives me the error "Undefined reference to 'vtable for TicTacToeConsoleView', pointing to line 4 of my cpp file.[/QUOTE] Add definitions for the two virtual functions and that error should go away. A class's virtual table is the information used to look up virtual functions at runtime. IIRC, GCC puts it into whatever object file contains the definition of the class's first virtual function, which is printBoard() in your case. Since nothing in your code defines that function, nothing causes GCC to output the vtable, so it's not there when the linker goes looking for it.
Ohhhhhh. That's weird I guess, I thought the compiler read from top to bottom so if it hit an error like that it wouldn't matter what's defined after it. Works now. <3
Well, that was a link error, not a compile error. Those happen after the compiler has already compiled all your source files (into .obj or .o, depending on platform), and is trying to combine those into an executable (.exe or no extension, again depending). When you define a function in foo.cpp, and call it from code in bar.cpp, the compiler puts a sort of note called an "unresolved external reference" into bar.obj, with the name of the function that was called. That's all it can do at that point, because it can't "see" the actual definition of the function at that time. (Each .cpp file is compiled separately and independently from the others.) Later, when the linker combines foo.obj and bar.obj into an .exe file, it can "see" both the undefined reference in bar.obj, and the definition that it refers to in foo.obj. So when it copies all the code into the .exe, it replaces the undefined reference with the address of the function. Matching up references in one place with definitions in another is why it's called a "linker". An "undefined reference" error happens when the linker goes looking for a definition and can't find it in [i]any[/i] of the .obj files after all your code is compiled. Usually it's a reference to a function you forgot to write, or a variable you forgot to define, so you see the name and say "oops" and go back and fix your code. A missing vtable message seems more confusing because that's not something you ever explicitly define in your source code, but now you know how to make sure the compiler produces it.
And that's how facepunch taught me more than 3 weeks of C++ lectures.
Oh, and I should add: the reason why the linker said the error was in your constructor is because the constructor is what contained the reference to the vtable. Constructors are special: the compiler inserts some invisible code at the beginning to do things like call base-class constructors and initialize vtables before running the constructor code that [i]you[/i] wrote.
-snip, dumb question i figured out myself-
Anyone used SFML's networking functionality? I'm having weird issues with it. [code] // Connect to server sf::TcpSocket* sock = new sf::TcpSocket(); if (sock->Connect(address, port)==sf::Socket::Done) { error("Connected to server"); this->clientConnected(sock); sock->Send("fuck",4);[/code] [code] void Network::clientConnected(sf::TcpSocket* client) { NetClient* c = new NetClient(client); c->address = client->GetRemoteAddress(); c->port = client->GetRemotePort(); this->addClient(c); if (!server) WorldManager::localPlayer = c; std::cout << "Connection established: " << c->address.ToString() << ":" << c->port << std::endl; } [/code] sf::TcpSocket.Connect always seems to be returning sf::Socket::Done - It shouldn't be connecting here as no server is running. Even when it is, the server end doesn't see anything either as you can see below so I guess it's not working at all. What gives? [img]http://img.meteornet.net/uploads/f7rkdjws/ss.png[/img]
What I've got is a top-down dual-stick shooter for multiple players. It works on a tilEd tile-based map, but units can move freely. I'm trying to get some AI up and running so that I can have loads of units populating each level, engaging each other and the players battlefield-style. I'm unsure as to how I should set up pathfinding and AI for around 100-200 units, though. I've been researching A* and thinking about navigation meshes and that kind of thing, but I'm a bit lost. Can anyone help? I'm using Java with Slick2d if anyone's interested.
How large is your grid going to be? At larger sizes, it is important to pick a pathfinding algorithm that responds well to lots of nodes.
[QUOTE=thomasfn;32845628]How large is your grid going to be? At larger sizes, it is important to pick a pathfinding algorithm that responds well to lots of nodes.[/QUOTE] At the moment it's 15x50 tiles.
[QUOTE=Nigey Nige;32845720]At the moment it's 15x50 tiles.[/QUOTE] You'll have problems if units block each other (ie, collide) but assuming you don't mind that their paths cross over, you could get away with using an A* algorithm as long as you be smart about choosing when to calculate the path (ie, not every frame).
[QUOTE=thomasfn;32846012]You'll have problems if units block each other (ie, collide) but assuming you don't mind that their paths cross over, you could get away with using an A* algorithm as long as you be smart about choosing when to calculate the path (ie, not every frame).[/QUOTE] Yeah, I'm thinking about only calculating the path at the start of each journey, then creating a path of waypoints for them to follow, maybe using flocking behaviours to prevent too much overlap. That way they'll be able to return to the path once flocking is complete. Something like: if !blocked go to next; else flock around; check if blocked; [editline]18th October 2011[/editline] Am I making sense?
[QUOTE=esalaka;32818584]...Do you happen to mean a shader that achieves a cell shading -esque look?[/QUOTE] Something along those lines. Possibly a true cell shader, but one which gives a similar effect would also work. I've been able to do it with brushes, but it just doesn't look as good as the real thing.
[QUOTE=high;32816945]How do you wait until a signal with boost? I want to have a thread wait until a value is set and then have the thread process it.[/QUOTE] Found out how to using boost::condition. Works the same way as Monitor.Wait/Pulse for .net.
I have a question about infinite loops in C++. The professor is requiring me to use input validations so that the user can not input negative numbers. He requires that the input validation be in the form of a while loop. I tested the program, and it works if I enter in a negative number. But then I accidentally put in something that is not a number, and it got thrown into an infinite loop. How do I fix that so that it doesn't accept letters either and it would be seen as an invalid input instead of resulting in an infinite loop? Here is the code. [cpp] // Written by Leon Ling #include <iostream> using namespace std; int main() { int speed, hour, hour_limit; cout << "What is the speed of the vehicle in MPH?\n"; cin >> speed; while (speed < 0) { cout << "INVALID INPUT!\n"; cout << "You may not have a negative speed, please check your number and try again!\n"; cout << "What is the speed of the vehicle in MPH?\n"; cin >> speed; } cout << "How many hours has it traveled?\n"; cin >> hour_limit; while (hour_limit < 1) { cout << "INVALID INPUT!\n"; cout << "You may not enter in a number less than 1, please check your number and try again!\n"; cout << "How many hours has it traveled?\n"; cin >> hour_limit; } cout << endl; cout << "Hour\t\tDistance Traveled\n"; cout << "------------------------------------------\n"; for (hour = 1; hour <= hour_limit; hour++) cout << hour << "\t\t" << hour * speed << endl; return 0; } [/cpp] Sorry if the wording is bad, thanks.
Does anyone know of a better method in OpenGL 3+ to draw 2dQuad then just drawing 3d objects without a depth-buffer?
[QUOTE=OldFusion;32848179]Does anyone know of a better method in OpenGL 3+ to draw 2dQuad then just drawing 3d objects without a depth-buffer?[/QUOTE] You write vertex shader that outputs rectangles with no matrix transformations and z=0?
[QUOTE=Leonmyster;32847578]I have a question about infinite loops in C++. The professor is requiring me to use input validations so that the user can not input negative numbers. He requires that the input validation be in the form of a while loop. I tested the program, and it works if I enter in a negative number. But then I accidentally put in something that is not a number, and it got thrown into an infinite loop. How do I fix that so that it doesn't accept letters either and it would be seen as an invalid input instead of resulting in an infinite loop? Here is the code. Sorry if the wording is bad, thanks.[/QUOTE] You'd have to try parsing the value entered as an integer.
[QUOTE=Zazibar;32850726]You'd have to try parsing the value entered as an integer.[/QUOTE] Err, I have no idea what you mean. I am still mostly a beginner.
[QUOTE=Nigey Nige;32845720]At the moment it's 15x50 tiles.[/QUOTE] Again, I'm 99% sure Slick2D has a a* implementation.
Ok guys, I have just started learning Lua using Love2d and I can't get my mousex and mousey being output in love.graphics.print After doing some research I have found [URL="http://love2d.org/wiki/Tutorial:Using_Input"]this [/URL]tutorial but even if I copy-paste all the code from there the program wouldn't compile What am I trying now (already using some code from that tutorial): [CODE]function love.load() love.graphics.setBackgroundColor (51,255,204) mouse_x=love.mouse.getX test="" end function love.update() test=mouse_x end function love.draw() love.graphics.print(test, 300, 300) end [/CODE] I get "string excpected got function" error , and I can't find any information on how to convert data types in Lua [editline]19th October 2011[/editline] Just randomly put tostring(mouse_X) and it worked Looks like love.mouse.getX doesn't output the thing I have wanted it to, though -edit- How could I miss that in the official Lua tutorial, it is basically in the beginning of it
I've got an abstract base class in C++ named Random. In this class, I'd like to keep a couple of references to two 'default' implementations I'll provide myself. One will be a Mersenne Twister, the other using standard C++ random functions. The header looks like this: [cpp] class Random { public: static Random* const Standard; static Random* const MersenneTwister; Random(); Random(unsigned long seed); virtual ~Random() {} void seed(unsigned long s); double randDouble(); double randDouble(double min, double max); int32_t randInt(); int32_t randInt(int32_t min, int32_t max); private: virtual void doSeed(unsigned long s) = 0; virtual double doRandDouble() = 0; virtual double doRandDouble(double min, double max) = 0; virtual int32_t doRandInt() = 0; virtual int32_t doRandInt(int32_t min, int32_t max) = 0; }; [/cpp] I later create a StandardRandom class in my cpp file and I'm now attempting to set Random::Standard to point to an instance of this object. I've achieved a similar objective elsewhere in a Matrix class, but that wouldn't work here because of the pure virtual members. For reference, here is how I did it in the Matrix class: [cpp] // Header class Matrix { public: static const Matrix identityMatrix; // code etc }; // Source const Matrix Matrix::identityMatrix = Matrix(true); [/cpp] How can I do what I want? I'm kinda loathe to put the StandardRandom and MersenneRandom classes into the header instead of the source file, there's no real point having access to them specifically later when all I want is access to the general base they share.
Sorry, you need to Log In to post a reply to this thread.