I've used TortoiseGit for using git on Windows. Unfortunately it has no portable version that i could put on a USB drive. Is there a portable program for using git on Windows?
I've used TortoiseGit for using git on Windows. Unfortunately it has no portable version that i could put on a USB drive. Is there a portable program for using git on Windows?
You can install Linux on the usb drive, then boot up into Linux whenever you need git.
I'm actually pretty serious; I was sick of dealing with school computers so I just bring my own OS to develop in on them. It feels nice knowing all of your work is saved on git as well as in your pocket, leaving the host computer untouched.
I found out that GitForWindows has a portable version so I'm going to use that currently.
I guess someone is not feeling adventurous today. :(
When building the model matrix, what is the correct order to do the rotation, scaling, translation?
Also if I what to rotate 2 axis by different degrees in glm I need to perform 2 different rotations, does it matter what order I rotate them?
My matrices are generated like this:
Code:glm::mat4 Pos = glm::translate(glm::mat4(),Position); glm::mat4 Ang = glm::rotate(glm::mat4(),Angle.z,glm::vec3(0,0,1)); Ang = glm::rotate(Ang,Angle.y,glm::vec3(0,1,0)); Ang = glm::rotate(Ang,Angle.x,glm::vec3(1,0,0)); glm::mat4 Sca = glm::scale(glm::mat4(),Scale); Matrix = Pos*Ang*Sca;
It depends on if you're using row-major or column-major. Whatever it is in DirectX (D3DXMATRIX) is backwards from whatever it is in OpenGL/GLM (glm::mat4)
How do you mean? I know GLM mat4 are mat4[column numb][row numb]
With GLM it's: Translation * Rotation * Scale
With DirectX: Scale * Rotation * Translation
In the shader, on DirectX:
output.Position = mul(float4(input.Position, 1), gWorldMatrix);
output.Position = mul(output.Position, gProjViewMatrix);
It may be a different order on OpenGL (multiply by ProjView first, then World)
Yea glsl is: gl_Position = MVP * vec4(Position, 1.0f);
Edited:
Thanks for clearing up the Model matrix stuff :)
You clearly have not used Git for Windows
Trying to create a method that returns an array but its just not being as easy as I want it too. I tired googling this problem but none seem to fit my situation.
Entity * GameObjectManager::getInt(Entity::entityName name) { std::map<int, Entity*>::const_iterator results = _gameObjects.begin(); static Entity * r[10]; int index = 0; if(results->second->name == name) { r[index] = results->second; index++; } return r; }
Return a vector.
This has to be a super hacky way of doing this but I cannot think of any other way to do this.
std::map<int, Entity*> GameObjectManager::getGroup(Entity::entityName name) { std::map<int, Entity*>::const_iterator itr = _gameObjects.begin(); std::map<int, Entity*> temp; while(itr != _gameObjects.end()) { if(itr->second->name == name) { temp.insert(std::pair<int,Entity*>(itr->second->getID(),itr->second)); } itr++; } return temp; std::for_each(temp.begin(),temp.end(),GameObjectDeallocator()); }
std::map<int, Entity*> tempArray = Main::GetGameObjectManager().getGroup(Entity::entityName::entityBullet); std::map<int, Entity*>::const_iterator itr = tempArray.begin(); while(itr != tempArray.end()) { if(itr->second->GetBoundingRect().intersects(GetBoundingRect())) { SetPosition(0,0); Main::GetGameObjectManager().Remove(itr->second->getID()); } itr++; }
Give it a reference instead to avoid copying the std::map.
void GameObjectManager::getGroup(Entity::entityName name, std::map<int, Entity*> &list) { list.clear(); std::map<int, Entity*>::const_iterator itr = _gameObjects.begin(); while(itr != _gameObjects.end()) { if(itr->second->name == name) { list.insert(std::pair<int,Entity*>(itr->second->getID(),itr->second)); } itr++; } std::for_each(list.begin(),list.end(),GameObjectDeallocator()); }
std::map<int, Entity*> tempArray; Main::GetGameObjectManager().getGroup(Entity::entityName::entityBullet, tempArray); std::map<int, Entity*>::const_iterator itr = tempArray.begin(); while(itr != tempArray.end()) { if(itr->second->GetBoundingRect().intersects(GetBoundingRect())) { SetPosition(0,0); Main::GetGameObjectManager().Remove(itr->second->getID()); } itr++; }
Either I'm being slow or I just don't understand this but how does the updated "tempArray" get passed back from getGroup method to the function that wants it? Or it is because your passing it a pointer and not an object?
Notice the &-sign? That means you're passing in a reference, which works kind of like a pointer.std::map<int, Entity*> &list
It means you're passing in the actual object instead of a copy of it.
So i am mucking around with the Farseer Physics Engine. I'm running into issues loading content with Debug View.
When this code is run, i get "Error loading "font". File not found."Code:DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
How should i fix this? I assume that ScreenManager.Content is empty or something and it's attempting to load a font that doesn't exist or something.
This sort of thing is a bit beyond my understand right now, but basically I am doing some bit twiddling. However, I am not sure if my pack function is correct, it seems to work properly but I am just not sure and would like insight from a more experienced programmer.
http://pastebin.com/v1dsdWnH
Also, I am aware that the function names are poop.
It looks fine to me.
I've been programming for quite some time now (five courses in 2.5 years, one introductory course taught in C++ which I finished during my first year, in a week. I had two C++ and two Java courses during my second and third year), with excellent grades. I know much of learning to program is to just practice and experiment by yourself, and that I have done, but I feel like I'm not advancing any more in C++.
I have a good grasp of classes and pointers in C++ and I've been doing some 2d work in SDL and SFML. I've started nosing about with templates in C++ but I haven't found anything interesting to use them with, yet (finding them quite hard to understand right now, actually) Suggestions? and what should I try to focus on doing after that?
so I'm trying to find a method to optimize drawing with rectangles, using the least amount of rects possible. I got it to check horizontally:
but no matter how hard I try, I can't get it to check vertically as well. The code is really ugly, but the logical steps behind how I did it are like this:
I don't even know if the rectangles are just getting overlapped, because LOVE sucks with debuggingCode:at pixel (x, y) check horizontally if the colors are the same repeat at (x + 1, y) else check downwards for the whole rectangle if all the colors are the same repeat at (x, y + 1) else back up, store the rectangle end end end
is there a better way to do this? or an example I can look at?
I've been stuck with this for a while, I'm hoping that WDYNHW will be my savior.
I've been trying to make a 2D platformer forever, one similar to SMB or Megaman. I know how to draw everything and get moving, but how would I make it so if it collided with a certain area (such as a wall) it would stop jumping, stop moving, or whatever. I can't figure this one out.
How do big devs handle things like entity systems? I know they are usually component based and before I start writing code I want to plan this out, lest I get awful and incomprehensible code that I just don't want to deal with. Like what does gamebryo do?
This one is actually really easy on yourself, considering things with the source engine.
Just get the source code for modding, and look at the entity cpp and header files.
Nothing that you want to replicate.
As long as you define components by functionality and not by the type of an object, you really can't go that wrong with a component based entity system. Before I implemented that type of system for the first time, I kept on thinking that it would be really complicated and that it would be hard to build the proper framework around it, etc. Then at some point I just started writing some code and realized that a lot of the complications I thought of were non-issues and a lot of things worked themselves out.
The only planning you really need to do right now before you write code:
-What data is shared between all components and should be a part of Entity? (hint: position)
-How will components communicate with one another? (In my implementation all components store a reference to their parent Entity, and you can request other components through the Entity. Other implementations do things like a message passing interface. Depends on what you need.)
-how will I store all the components and update them? (Usually this involves a ComponentManager or something similar. In my implementation it only accepts Entities, but internally stores them as separate components separated by type.)
Once you have a plan for those three things, start writing some code and you'll see that a lot of it will start to fall in place.
Having a problem with "'Particle' : base class undefined" after lots of google search it appears its causes by an issue with 2 classes having the same header file but this is not the case with mine.
#pragma once #include "Particle.h" class blueParticle :public Particle { public: blueParticle(int x, int y, float dirx, float diry); virtual ~blueParticle(); protected: };
#pragma once #include "Entity.h" #include "Main.h" class Particle : public Entity { public: Particle(int x, int y, float dirx, float diry); virtual ~Particle(); virtual void Update(float frametime); protected: float life_time_; sf::Vector2f direction; float timeAcc; };
Does Main.h or Entity.H include blueParticle.h/Particle.h?
I don't see any reason for your Particle class to include "Main.h" either.
Does anyone know what are some good values for perlin noise?
Im using these values:
PerlinNoise p; p.Set( 2.25, //Persistance 4.0, //Frequency 0.50, //Amplittude 6, //Octaves 5555); //Seed glGenTextures( 1, &tex ); glBindTexture( GL_TEXTURE_2D, tex ); int imgSize = 512; glm::vec3 img[imgSize*imgSize]; for(int y = 0; y < imgSize; y++) { for(int x = 0; x < imgSize; x++) { int id = x + (y * imgSize); img[id] = glm::vec3(p.GetHeight(x, y)); } } glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, imgSize, imgSize, 0, GL_RGB, GL_FLOAT, img ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glGenerateMipmap( GL_TEXTURE_2D );
But it gives this ugly thing:
![]()
Tried setting up a basic opengl window with glut and then binding a shader to it with glew, for some reason the shader doesn't do anything, does anybody have any idea why ?
Source : http://dl.dropbox.com/u/28926055/EmpiresOpenGL.rar
You should add shader error checking. You're blindly compiling and linking the shader without actually checking if it succeeded or not.
You can use my engine's shader object for reference if you'd like, but it's a little messy: https://github.com/naelstrof/Astrost...rc/NShader.cpp
Yea, I figured that much, so I added it in and this was the error :
http://dl.dropbox.com/u/28926055/juulbitch.png
But the vertex and fragment shader are both really simple, can't find anything that could cause this.
- Edit -
Managed to fix the error by removing the #version 150 but now it doesn't error and still just displays a white cube instead of a yellow one.
Currently messing around with SAT (Separating Axis Theorem), But failing miserably to produce a decent collision response.
Does anyone have any examples or old code to share and learn from?
Can anyone see anything wrong with this perlin class, I cant get the desired output.
#include "PerlinNoise.hpp" PerlinNoise::PerlinNoise() { persistence = 0; frequency = 0; amplitude = 0; octaves = 0; randomseed = 0; } PerlinNoise::PerlinNoise(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed) { persistence = _persistence; frequency = _frequency; amplitude = _amplitude; octaves = _octaves; randomseed = 2 + _randomseed * _randomseed; } void PerlinNoise::Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed) { persistence = _persistence; frequency = _frequency; amplitude = _amplitude; octaves = _octaves; randomseed = 2 + _randomseed * _randomseed; } double PerlinNoise::GetHeight(double x, double y) const { return amplitude * Total(x, y); } double PerlinNoise::Total(double i, double j) const { //properties of one octave (changing each loop) double t = 0.0f; double _amplitude = 1; double freq = frequency; for(int k = 0; k < octaves; k++) { t += GetValue(j * freq + randomseed, i * freq + randomseed) * _amplitude; _amplitude *= persistence; freq *= 2; } return t; } double PerlinNoise::GetValue(double x, double y) const { int Xint = (int)x; int Yint = (int)y; double Xfrac = x - Xint; double Yfrac = y - Yint; //noise values double n01 = Noise(Xint-1, Yint-1); double n02 = Noise(Xint+1, Yint-1); double n03 = Noise(Xint-1, Yint+1); double n04 = Noise(Xint+1, Yint+1); double n05 = Noise(Xint-1, Yint); double n06 = Noise(Xint+1, Yint); double n07 = Noise(Xint, Yint-1); double n08 = Noise(Xint, Yint+1); double n09 = Noise(Xint, Yint); double n12 = Noise(Xint+2, Yint-1); double n14 = Noise(Xint+2, Yint+1); double n16 = Noise(Xint+2, Yint); double n23 = Noise(Xint-1, Yint+2); double n24 = Noise(Xint+1, Yint+2); double n28 = Noise(Xint, Yint+2); double n34 = Noise(Xint+2, Yint+2); //find the noise values of the four corners double x0y0 = 0.0625*(n01+n02+n03+n04) + 0.125*(n05+n06+n07+n08) + 0.25*(n09); double x1y0 = 0.0625*(n07+n12+n08+n14) + 0.125*(n09+n16+n02+n04) + 0.25*(n06); double x0y1 = 0.0625*(n05+n06+n23+n24) + 0.125*(n03+n04+n09+n28) + 0.25*(n08); double x1y1 = 0.0625*(n09+n16+n28+n34) + 0.125*(n08+n14+n06+n24) + 0.25*(n04); //interpolate between those values according to the x and y fractions double v1 = Interpolate(x0y0, x1y0, Xfrac); //interpolate in x direction (y) double v2 = Interpolate(x0y1, x1y1, Xfrac); //interpolate in x direction (y+1) double fin = Interpolate(v1, v2, Yfrac); //interpolate in y direction return fin; } double PerlinNoise::Interpolate(double x, double y, double a) const { double negA = 1.0 - a; double negASqr = negA * negA; double fac1 = 3.0 * (negASqr) - 2.0 * (negASqr * negA); double aSqr = a * a; double fac2 = 3.0 * aSqr - 2.0 * (aSqr * a); return x * fac1 + y * fac2; //add the weighted factors } double PerlinNoise::Noise(int x, int y) const { int n = x + y * 57; n = (n << 13) ^ n; int t = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff; return 1.0 - double(t) * 0.931322574615478515625e-9;/// 1073741824.0); }
ActionScript 3, pretty much my first game ever.
I want the game to go to scene 2 and play after scorer1 reaches 200. scorer1 is the instance name of the text box displaying the score. I know how to modify numeral values when they are a stringbut I don't know how to detect when a string has become a certain value.
Learning AS3 at school as first programming language. I'll be moving onto harder stuff next year. Sorry my coding isn't as grand as that noise-simulator thingy made in Perl above :/
Your shaders use very old deprecated OpenGL features, so GLSL 1.50 is definitely not suited for you.
Using a glGetError() I found that glUseProgram was causing a GL_INVALID_VALUE error. To see why this happens, let's have a look at shader creation:
shader = Shader("Shaders\\vertexshader.shader", "Shaders\\pixelshader.shader");
What happens here is that a shader object is created and loads the shaders you specified. It is then assigned to the shader variable and finally it destroys itself because it is no longer necessary. This destruction causes the shaders to be unloaded and they will no longer be usable by your program.
To circumvent this, you need to implement your own assignment operator:
Shader& Shader::operator=( Shader& shader ) { shader_vp = shader.shader_vp; shader_fp = shader.shader_fp; shader_id = shader.shader_id; shader.shader_id = 0; return *this; }
And tell the destructor to not do anything if no shader program is set:
Shader::~Shader(void) { if ( shader_id == 0 ) return;
And of course initialise it to be 0:
Shader::Shader() { shader_id = 0; }
This will result in a correctly drawn cylinder.
Really though, the OpenGL code used here is depressing. If you want to use glut, fair enough, but using fixed pipeline properties in shaders? Ugh. If you have some pride, either ditch shaders or switch to full programmable mode.
Is there any easier way than putting all my .lua files with main.lua on top in a .zip, change it to a .love and execute it everytime I make a small change?
Lua + Love2D.
In unity I'm trying to figure out how to change a texture at runtime in C#. I have the file name of the texture in a string, but I dont know how to set the texture from a path.
here's one way at least
using System.IO; private Texture2D loadTexture(string name){ byte[] png = File.ReadAllBytes(name); //name is a full path Texture2D temp; //= new Texture2D(1,1); //i don't remember if you need to initialize it beforehand temp.LoadImage(png); temp.filterMode = FilterMode.Point; //pixelated by default (use whichever mode you'd like) temp.wrapMode = TextureWrapMode.Clamp; //don't repeat the texture return temp; }