I could use some help figuring out how to write a command parser.
I receive a string ex "/create Item Name 50" that creates 50 items specified, It also works off of ID's some names have spaces others don't and I'm curious how would I properly split up the Command name the Item Name / ID and the amount. I've tried commas between the args or quotes around the names but it just seems to aggravate the uses more then it helps. So is there any regex magic I can use or am I just basically screwed?
Edit:
Also the system tends to be rather dynamic like you can leave off the amount arg or for maps you can include a PortalID or x/y position
So i have some classes in the following format:
Game: Defined Update() and Draw() (The main XNA game class, i can't change the function names)
Engine: Inherits Update() and Draw() from Game (Needs to be named this to override)
Main: Inherits Update() and Draw() from Engine and does all the actual drawing. (Would prefer if there's somehow a way i can still call them Update and Draw)
I need a way to stop those functions in Main being called from Engine (When there's an unhandled exception i want the game to stop updating and drawing and handle the crash screen from the engine), and i haven't been able to figure out a way without changing them to different functions
[QUOTE=anthonywolfe;41754605]I could use some help figuring out how to write a command parser.
I receive a string ex "/create Item Name 50" that creates 50 items specified, It also works off of ID's some names have spaces others don't and I'm curious how would I properly split up the Command name the Item Name / ID and the amount. I've tried commas between the args or quotes around the names but it just seems to aggravate the uses more then it helps. So is there any regex magic I can use or am I just basically screwed?
Edit:
Also the system tends to be rather dynamic like you can leave off the amount arg or for maps you can include a PortalID or x/y position[/QUOTE]
If you're using Python, there's a module that can do that.
Otherwise [url=http://stackoverflow.com/a/554068/1874964]here[/url]'s a regex.
[QUOTE=Goz3rr;41756068]So i have some classes in the following format:
Game: Defined Update() and Draw() (The main XNA game class, i can't change the function names)
Engine: Inherits Update() and Draw() from Game (Needs to be named this to override)
Main: Inherits Update() and Draw() from Engine and does all the actual drawing. (Would prefer if there's somehow a way i can still call them Update and Draw)
I need a way to stop those functions in Main being called from Engine (When there's an unhandled exception i want the game to stop updating and drawing and handle the crash screen from the engine), and i haven't been able to figure out a way without changing them to different functions[/QUOTE]
Does Main need to inherit from Engine? You could just use an Engine-member in Main otherwise, then your Update and Draw methods wouldn't override the Engines ones.
So now I have this problem:
When I try to send a chat message that contains >= 5 characters it crashes with this:
[CODE]Debug Assertion Failed!
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
Line: 1424
Expression: _pFirstBlock == _pHead[/CODE]
when sending sf::Packet with int (packet type) and std::string (message).
As I've said - it only happens when message contains more than 4 chars. When less it works as it should?
Can you help me with that? Or am I on my own?
[QUOTE=ZeekyHBomb;41756234]If you're using Python, there's a module that can do that.
Otherwise [url=http://stackoverflow.com/a/554068/1874964]here[/url]'s a regex.[/QUOTE]
Oops sorry, Guess I forgot to mention I was using C#, My bad. Guess whats what I get for posting at 1AM. Anyways the link helped a bunch thanks, I never really was able to wrap my head around regex..
[QUOTE=Sonic96PL;41758431]So now I have this problem:
When I try to send a chat message that contains >= 5 characters it crashes with this:
[CODE]Debug Assertion Failed!
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c
Line: 1424
Expression: _pFirstBlock == _pHead[/CODE]
when sending sf::Packet with int (packet type) and std::string (message).
As I've said - it only happens when message contains more than 4 chars. When less it works as it should?
Can you help me with that? Or am I on my own?[/QUOTE]
You should open a bug-report for SFML. Include information about your OS, compiler and if you know what a stack trace is, that too.
And a minimal, but complete test-case.
[QUOTE=ZeekyHBomb;41763533]You should open a bug-report for SFML. Include information about your OS, compiler and if you know what a stack trace is, that too.
And a minimal, but complete test-case.[/QUOTE]
So it's SFML bug? I thought that I'm doing something wrong.
[QUOTE=Sonic96PL;41763610]So it's SFML bug? I thought that I'm doing something wrong.[/QUOTE]
You might be; like zeeky said you should put together a [i]minimal[/i] test case to identify if its a problem with the library or some part of your own code.
[QUOTE=Sonic96PL;41763610]So it's SFML bug? I thought that I'm doing something wrong.[/QUOTE]
Stuffing an int and a std::string into a sf::Packet should be fine. Unless you're doing something funky, it's probably something that the SFML maintainer should take care of.
So I'm again contemplating switching my game to C#. Problem is that I use Linux a lot and I'm not sure how the support for .NET on Linux is going. Maybe I should ask this: if you were to start a 3d game project on Linux, what language and whatever would you use?
I'm using one shader for everything, and I've begun working on implementing normal maps. However, the things without a normal map look very weird and improperly shaded now. I tried to use a simple 1by1 texture that was of RGB value 0,128,0 so that the normal would be straight up as usual, however I am not sure that is what I am supposed to do. Anyone know how to deal with this?
Edit: I was wrong, in my idea and execution. The RGB value should be 0, 255, 0, as that would represent a normal of 0,1,0. However, this is incorrect, because when it is transformed and all is said and done, it results in incorrect normals. I instead used a boolean that is set whether or not the set of triangles has a normal map.
[QUOTE=WTF Nuke;41769257]I'm using one shader for everything, and I've begun working on implementing normal maps. However, the things without a normal map look very weird and improperly shaded now. I tried to use a simple 1by1 texture that was of RGB value 0,128,0 so that the normal would be straight up as usual, however I am not sure that is what I am supposed to do. Anyone know how to deal with this?
Edit: I was wrong, in my idea and execution. The RGB value should be 0, 255, 0, as that would represent a normal of 0,1,0. However, this is incorrect, because when it is transformed and all is said and done, it results in incorrect normals. I instead used a boolean that is set whether or not the set of triangles has a normal map.[/QUOTE]
Are you using tangent space normal mapping (Are your normal maps predominantly blue coloured)? If so, your default normal map should be (0, 0, 255) so that they point perpendicular to the surface.
Yes right sorry, I meant to say 0,0,255 but for some reason said the opposite. I did use that instead. It did not work. I have also run into another issue, even with this fix. Some parts of the sponza map don't light up at all. Here is a picture to illustrate my point
[img]http://i.imgur.com/TNuiDr7.jpg[/img]
The purple parts are the ones that don't use a bump map. I feel like it has something to do with my tangent and bitangent generation
[cpp]for(int i = 0; i <pointData.size(); i+=3){
glm::vec3 & v0 = vertices[pointData[i].x];
glm::vec3 & v1 = vertices[pointData[i+1].x];
glm::vec3 & v2 = vertices[pointData[i+2].x];
glm::vec2 & uv0 = textures[pointData[i].y];
glm::vec2 & uv1 = textures[pointData[i+1].y];
glm::vec2 & uv2 = textures[pointData[i+2].y];
glm::vec3 deltaPos1 = v1-v0;
glm::vec3 deltaPos2 = v2-v0;
glm::vec2 deltaUV1 = uv1-uv0;
glm::vec2 deltaUV2 = uv2-uv0;
float r = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV1.y * deltaUV2.x);
glm::vec3 tangent = (deltaPos1 * deltaUV2.y - deltaPos2 * deltaUV1.y)*r;
glm::vec3 bitangent = (deltaPos2 * deltaUV1.x - deltaPos1 * deltaUV2.x)*r;
for(int j =0; j < 3; j++){
tangents.emplace_back(tangent);
bitangents.emplace_back(bitangent);
}
}[/cpp]
However, it could also be my shaders.
This is the vert shader
[cpp]void main() {
PositionWorldSpace = (M * vec4(position,1.0)).xyz;
vec3 PositionCamSpace = (V*M*vec4(position, 1.0)).xyz;
vec3 LightDirCamSpace = (V*vec4(lightPos, 1.0)).xyz - PositionCamSpace;
gl_Position = MVP * vec4(position, 1.0 );
NormalCamSpace =(V*M *normalize(vec4(normal,0.0))).xyz;
vec3 TangentCamSpace =(V*M* normalize(vec4(tangent, 0.0))).xyz;
vec3 BitangentCamSpace = (V*M* normalize(vec4(bitangent, 0.0))).xyz;
mat3 TBN = mat3(1.0);
if(bumpToggle){
TBN = transpose(mat3(TangentCamSpace, BitangentCamSpace, NormalCamSpace));
}
LightDir = TBN * LightDirCamSpace;
EyeDir = TBN * (-PositionCamSpace);
UV = texture;
}[/cpp]
And the frag shader:
[cpp]void main() {
vec3 n;
if(bumpToggle)
n = normalize(texture2D(normalMap, uv ).rgb*2-1);
else
n = normalize(NormalCamSpace);
vec3 l = normalize(LightDir);
float cosTheta = clamp(dot(n, l),0,1);
vec3 E = normalize(EyeDir);
vec3 halfAng = normalize (l + E);
float cosAlpha = clamp(dot(n, halfAng),0,1);
cosAlpha = pow(cosAlpha, shineFactor);
cosAlpha = cosTheta==0?0:cosAlpha;
float lightPower = 3;
vec3 lightVec = lightPos-PositionWorldSpace;
float attenIntensity = 1/(1.0 +dot(lightVec, lightVec));
outColor =texture(difTex, uv).rgb* diffuseColor * lightPower* cosTheta *attenIntensity+
/*texture(specTex, uv).rgb**/ specularColor* lightPower* cosAlpha *attenIntensity+
texture(ambTex, uv).rgb* ambientColor* ambientIntensity;
}[/cpp]
[QUOTE=thf;41767682]So I'm again contemplating switching my game to C#. Problem is that I use Linux a lot and I'm not sure how the support for .NET on Linux is going. Maybe I should ask this: if you were to start a 3d game project on Linux, what language and whatever would you use?[/QUOTE]
Afaik Mono works pretty well.
I'd use C++.
C# is a good language, but I just can't bring myself to trust Microsoft enough. This is something you have to decide for yourself though.
Scala looks like a cool language (primarilty) for the JVM (there's also a CLR target I don't know the state of and an incomplete LLVM target), but last time I tried compilation was slower than C++ and I don't have a clear picture of the languages idioms - there are many ways to accomplish the same.
Rust also looks interesting, but the language is still in a state of change. You should probably only use it for experimentation with it.
[QUOTE=ZeekyHBomb;41770566]Afaik Mono works pretty well.
I'd use C++.
C# is a good language, but I just can't bring myself to trust Microsoft enough. This is something you have to decide for yourself though.
Scala looks like a cool language (primarilty) for the JVM (there's also a CLR target I don't know the state of and an incomplete LLVM target), but last time I tried compilation was slower than C++ and I don't have a clear picture of the languages idioms - there are many ways to accomplish the same.
Rust also looks interesting, but the language is still in a state of change. You should probably only use it for experimentation with it.[/QUOTE]
I kinda like C++ a bit but there's a lot of gotchas with it. Many of them are on Microsoft's compiler but I think thy stem from how C++ works.
It's just that so much stuff just works in C#. Reflection, functional stuff and so on. I don't want to use language that noone has used for games before.
[QUOTE=thf;41767682]So I'm again contemplating switching my game to C#. Problem is that I use Linux a lot and I'm not sure how the support for .NET on Linux is going. Maybe I should ask this: if you were to start a 3d game project on Linux, what language and whatever would you use?[/QUOTE]
Mono is very stable on Linux and OS X. If you're working on a 3d game, you'll be mostly fine performance-wise, since you're really just doing a small amount of math and sending everything to the GPU now. I'm currently working on a game in C# that (should) work on Windows, Linux, and OS X. There are a few things holding us back:
1) OpenTK has some issues with windowing on Linux and OS X (On OS X we receive no mouse input and keyboard input on some versions). A few of us are planning on fixing all of that on [url=https://github.com/andykorth/opentk]this GitHub repo[/url]
2) My friend who's working on networking decided to use a ECDiffieHellmanCng, which is only available on Windows for XP SP3 and above, and it's apparently just a thin wrapper around Windows's cryptography library, so we're going to replace that with something else.
3) My inability to get Bumblebee working on my laptop with an Optimus card. Minor, but annoying for testing.
On the plus side, you can use all of the really cool C# language features without worrying too much. Most of the code you write for a game isn't performance sensitive, so you can just steamroll through a lot of normally tedious tasks.
[QUOTE=robmaister12;41771217]Mono is very stable on Linux and OS X. If you're working on a 3d game, you'll be mostly fine performance-wise, since you're really just doing a small amount of math and sending everything to the GPU now. I'm currently working on a game in C# that (should) work on Windows, Linux, and OS X. There are a few things holding us back:
1) OpenTK has some issues with windowing on Linux and OS X (On OS X we receive no mouse input and keyboard input on some versions). A few of us are planning on fixing all of that on [url=https://github.com/andykorth/opentk]this GitHub repo[/url]
2) My friend who's working on networking decided to use a ECDiffieHellmanCng, which is only available on Windows for XP SP3 and above, and it's apparently just a thin wrapper around Windows's cryptography library, so we're going to replace that with something else.
3) My inability to get Bumblebee working on my laptop with an Optimus card. Minor, but annoying for testing.
On the plus side, you can use all of the really cool C# language features without worrying too much. Most of the code you write for a game isn't performance sensitive, so you can just steamroll through a lot of normally tedious tasks.[/QUOTE]
I'm sure it's all good when doing development on Windows and then just "testing" it a tiny bit on other platforms. But what about the day I switch to Linux? How is support for developing C# there? For that matter, what do you use yourself? Just Windows, or do you also develop on any other platform?
If you like specifically designed IDEs there's MonoDevelop.
If you're okay with general IDEs, Geany is cool. Not sure if QtCreater can do more than just C++. It's not too popular, but from the ones who know of it I've heard they like it.
Otherwise you can just use the command-line environment, setup Makefiles and all that.
[QUOTE=ZeekyHBomb;41771279]If you like specifically designed IDEs there's MonoDevelop.
If you're okay with general IDEs, Geany is cool. Not sure if QtCreater can do more than just C++. It's not too popular, but from the ones who know of it I've heard they like it.
Otherwise you can just use the command-line environment, setup Makefiles and all that.[/QUOTE]
I prefer a text editor in Linux and it just feels like C# isn't suited for that. On the other hand, maybe C++ isn't either.
I used Vim and Unix-y command-line tools fine for various languages, including C, C++, C#, Haskell, Java, Lua, Racket (Scheme-derivative, which is a Lisp-derivatve), sh, Python.
[QUOTE=ZeekyHBomb;41771524]I used Vim and Unix-y command-line tools fine for various languages, including C, C++, C#, Haskell, Java, Lua, Racket (Scheme-derivative, which is a Lisp-derivatve), sh, Python.[/QUOTE]
I prefer emacs but I'm sure there is some stuff for it then. I don't know, there is just something that doesn't feel good about it. It just feels like it's something you don't pick when starting a project on Linux. But why go by feelings really :v: I bet it is a really good option for me.
[QUOTE=WTF Nuke;41770088]Yes right sorry, I meant to say 0,0,255 but for some reason said the opposite. I did use that instead. It did not work. I have also run into another issue, even with this fix. Some parts of the sponza map don't light up at all. Here is a picture to illustrate my point
The purple parts are the ones that don't use a bump map. I feel like it has something to do with my tangent and bitangent generation
Code
However, it could also be my shaders.
This is the vert shader
code
And the frag shader:
code[/QUOTE]
The error of my ways was in the indexing, as I should subtract 1 from the index as .obj counts from 1 rather than 0. I still have to ask though, if a flat map of (0,0,255) should generate the same normals as no normal map at all.
Wait no, that didn't fix anything yet. This is a picture of alight source directly above the center of a square, with a texture that is fully blue.
[img]http://i.imgur.com/339HNng.png[/img]
I fixed the issue with the model display not working as intended, it had to do with handedness and how I forgot to subtract (again). I might change that, however I can't think of a non hacky way to check if the file uses textures or normals (unless I make it set a bool to true every time it reads a texture or normal, but that seems redundant to me). I think this comment will be sufficient:
[cpp]//REMEMBER SPONGEBOB
//RAVIOLI RAVIOLI
//DON'T FORGET THE SUBTRACTIOLI[/cpp]
I still question why a full blue normal map doesn't result in the normals not being altered. Anyone have insight on this?
Argh, the flat map shouldn't be 0,0,255, but rather 127,127,225. Because when the values are normaliezd they will be 0.5, 0.5, 1.0 and after they are altered they will become vec3(0,0,1). It works now!
[QUOTE=thf;41771258]I'm sure it's all good when doing development on Windows and then just "testing" it a tiny bit on other platforms. But what about the day I switch to Linux? How is support for developing C# there? For that matter, what do you use yourself? Just Windows, or do you also develop on any other platform?[/QUOTE]
I do some work on Linux, I use MonoDevelop, the latest versions have much better autocomplete now. It's definitely still a step down from using Visual Studio though. If OpenTK didn't have those windowing issues on Linux, I'd definitely be using it more.
As you mentioned in another comment, you prefer emacs. A quick search got me this: [url]https://github.com/sp3ctum/omnisharp-emacs[/url]
The general style of C# tends to prefer spelling things out over brevity, which means that autocomplete will actually speed you up quite a bit. OpenTK, for example, takes all the GL constants and puts them in enums with a descriptive name. If you have autocomplete, that means that you can write the enum type with a single key, then type "." and get a list of all the valid constants for that function.
I've actually recently started using vim and I'm enjoying it quite a bit, maybe I'll try out omnisharp myself.
[QUOTE=robmaister12;41775668]I do some work on Linux, I use MonoDevelop, the latest versions have much better autocomplete now. It's definitely still a step down from using Visual Studio though. If OpenTK didn't have those windowing issues on Linux, I'd definitely be using it more.
As you mentioned in another comment, you prefer emacs. A quick search got me this: [url]https://github.com/sp3ctum/omnisharp-emacs[/url]
The general style of C# tends to prefer spelling things out over brevity, which means that autocomplete will actually speed you up quite a bit. OpenTK, for example, takes all the GL constants and puts them in enums with a descriptive name. If you have autocomplete, that means that you can write the enum type with a single key, then type "." and get a list of all the valid constants for that function.
I've actually recently started using vim and I'm enjoying it quite a bit, maybe I'll try out omnisharp myself.[/QUOTE]
That's nice! I'll check out the newest versions of MonoDevelop. What a shame I can't find any language with the same semantics as C# but without all the verbosity.
hello! newbie question here
I'm in the middle of learning python right now and i started playing around with if, elif, and else statements but they don't seem to be working and i have no idea why.
[IMG]http://i40.tinypic.com/2lxzhqf.png[/IMG]
what am i missing?
raw_input gives you the number string instead of the number, so x is "10", not 10.
input evaluates the string, meaning number strings are turned into numbers.
[editline]10th August 2013[/editline]
A better way to fix it is probably int(raw_input("test")), which will convert the result from raw_input into an integer without letting the user run code.
[editline]10th August 2013[/editline]
If you use an IDE with debugger ([URL="http://pydev.org/"]PyDev[/URL] is good.), you can step through the program line by line and view variables after each step.
ok thanks for clearing that up!
i tried downloading PyDev but i couldn't get eclipse working. do you have any other ide you could recommend for python? i tried vim but it was too overwhelming and confusing for me.
-snip-
Nevermind..
What OpenGL library should I use for implementing OpenGL for my open source project, JA2 v1.13 3D? Open Scene Graph looks promising.
[QUOTE=E3245;41782469]What OpenGL library should I use for implementing OpenGL for my open source project, JA2 v1.13 3D? Open Scene Graph looks promising.[/QUOTE]
Which language? And are you looking for OpenGL bindings or a graphics library built on top of OpenGL?
Sorry, you need to Log In to post a reply to this thread.