I'm in the Matrix for a living.
Perception neuron mocap suit + htc vive
pouet
Posted by theDaftDev on 17 November 2015 - 05:10 PM
I'm in the Matrix for a living.
Perception neuron mocap suit + htc vive
Posted by theDaftDev on 09 January 2015 - 12:13 PM
It happend roughly ten minutes from the place I study at.
I barely even feel concerned about France most of the time, but these events were dramatic.
There has been this heavy and surreal atmosphere all the week long.
Three terrorists who were involved in the killing got neutralized and killed a hour ago.
One of them is still on the run, a woman, according to the police.
One of my friends was stuck in his house all the afternoon, since he lives where shootings took place, followed by hostages being held in a store.
He already had a hard time handling all this shit, so that kinda sucks. It's a relief that all this shit is now over. It's been a stressing week.
shit shit shit.
Posted by theDaftDev on 27 August 2014 - 10:37 PM
I'm not sure if this is the place it should go but I need some help. I'm 17 and I really want to learn about computers and programming. Where do I start? Everything is so overwhelming. Can any of you give me some tips? It would be greatly appreciated.
It relies on what you would like to do.
Do you want to make websites, webapps, games, reverse engineering.. etc?
As an introduction, I'd suggest you to get started with web languages, such as html, css and eventually js or php, which mean that you would start by building websites.
Posted by theDaftDev on 21 July 2014 - 01:12 AM
Posted by theDaftDev on 13 July 2014 - 07:12 AM
Posted by theDaftDev on 11 June 2014 - 07:52 PM
uniform vec2 frag_LightOrigin; // The light's position uniform vec3 frag_LightColor; // Its colour uniform float frag_LightAttenuation; // We could call this its luminosity uniform vec2 frag_ScreenResolution; // We need this because SFML reverses the Y axis. Note: we could just be using a single float for the Y resolution. void main() { vec2 baseDistance = gl_FragCoord.xy; // Storing our pixel's position baseDistance.y = frag_ScreenResolution.y-baseDistance.y; // Fixing the reversed Y axis vec2 distance=frag_LightOrigin - baseDistance; // Getting the distance between our light and the pixel, as a 2D vector float linear_distance = length(distance); // Getting the linear distance through a normalization float attenuation=1.0/( frag_LightAttenuation*linear_distance + frag_LightAttenuation*linear_distance); // The closer our pixel is to the light source, the smaller the light attenuation will be. vec4 lightColor = vec4(frag_LightColor, 1.0); vec4 color = vec4(attenuation, attenuation, attenuation, 1.0) * lightColor; // We multiply our light's colour with the attenuation vector, which will give us the final 'luminosity' of our pixel. gl_FragColor=color; // We give our pixel its final colour. }
#include <SFML/Graphics.hpp> #define DEFAULT_WIDTH 800 #define DEFAULT_HEIGHT 600 class Entity; class World { public: static World& getInstance(); // We get the unique instance void run(); // We run the game loop void applyShader(sf::RenderStates); // We apply a shader passed through render states private: World(); ~World(); void draw(); // The draw loop void update(float frametime); // We update our entities sf::RenderWindow myWindow; sf::RenderTexture myRenderTexture; sf::Sprite mySprite; std::vector<Entity> myEntities; // Note: for a real game, a std::list is more relevant };
#include "World.hpp" #include "Entity.hpp" World::World(){} World::~World(){} World& World::getInstance() { static World myself; return myself; } void World::draw() { myWindow.clear(); // We clear the window myRenderTexture.clear(); // We clear the render texture for(int i(0); i<myEntities.size(); i++) { myEntities[i].draw(myRenderTexture); // We 'stack' our sprites on the texture, eventually shaders will be applied. } myRenderTexture.display(); // We're done drawing on the RenderTexture myWindow.draw(mySprite); // We draw it on the RenderWindow myWindow.display(); // We display the window } void World::update(float frametime) { for(int i(0); i<myEntities.size(); i++) { myEntities[i].update(frametime); // We update our entities, based on the frametime, to avoid different behaviours because of the framerate. } } void World::run() { myWindow.create(sf::VideoMode(DEFAULT_WIDTH, DEFAULT_HEIGHT, 32), "SFML - Shaders", sf::Style::Close); myRenderTexture.create(DEFAULT_WIDTH, DEFAULT_HEIGHT); // Don't forget to create the RenderTexture, like you would do for the window. mySprite.setTexture(myRenderTexture.getTexture()); // We get the texture and link it to our sprite. sf::Event event; sf::Clock clock; bool isRunning = true; sf::Texture texture; // We make sure to load the same texture only once, so we don't set it as an Entity class attribute. texture.loadFromFile("texture.png"); // And we load it here. // We add entities, and place it some where on the screen. for(int i(0); i<3; i++) { myEntities.push_back(Entity()); myEntities.back().setTexture(texture); myEntities.back().setPosition( (i+1)*200,300 ); myEntities.back().setCurrentColor(i); } while(isRunning) { while(myWindow.pollEvent(event)) { switch(event.type) { case sf::Event::Closed: isRunning=false; break; } } update(clock.restart().asSeconds()); draw(); } } void World::applyShader(sf::RenderStates states) { myRenderTexture.draw(mySprite, states); // We apply our shader on the current render }
#include <SFML/Graphics.hpp> class Entity { public: Entity(); ~Entity(); void draw(sf::RenderTarget& target) const; void update(float frametime); void setTexture( const sf::Texture& texture ); void setPosition(float x, float y); void setCurrentColor( int color ); private: sf::Sprite mySprite; std::vector<sf::Vector3f> colors; // Array of 3 colors we will be using int currentColor; // This stores the current id of our color float colorTimeUpdate; // This variable is used to 'stack' the time, and see when we can change our color };
#include "Entity.hpp" #include "World.hpp" #include "ShadersManager.hpp" Entity::Entity() { // We store the colors we will be displaying colors.push_back(sf::Vector3f(255,0,0)); // Red colors.push_back(sf::Vector3f(0,255,0)); // Green colors.push_back(sf::Vector3f(0,0,255)); // Blue currentColor = 0; colorTimeUpdate = 0; /* Here we both "pre-load" our shader, so it doesn't need to slow our game when loading while the world is running, and set the resolution variable so we don't have to bother with it later */ ShadersManager::getShader("shader.frag")->setParameter("frag_ScreenResolution",sf::Vector2f(DEFAULT_WIDTH, DEFAULT_HEIGHT)); } Entity::~Entity(){} void Entity::draw(sf::RenderTarget& target) const { target.draw(mySprite); // First, we draw our sprite /* So here are the parameters we need to set: uniform vec2 frag_LightOrigin; // The light's position uniform vec3 frag_LightColor; // Its colour uniform float frag_LightAttenuation; // We could call this its luminosity Note: We already set the resolution. */ sf::Shader* shader = ShadersManager::getShader("shader.frag"); shader->setParameter("frag_LightOrigin", mySprite.getPosition()); shader->setParameter("frag_LightColor", colors[currentColor]); shader->setParameter("frag_LightAttenuation", 10); sf::RenderStates states; // We prepare our render states states.shader = shader; // We give the render states our shader states.blendMode = sf::BlendAdd; // We set the blendMode to Add so that our changes are overlaying the other shader, not erasing them. World::getInstance().applyShader(states); // We apply the shader on the whole texture } void Entity::update(float frametime) { colorTimeUpdate+=frametime; // We update the time if(colorTimeUpdate>=2) // We check if it is higher than 2 seconds { currentColor++; // If so, we swap for the next color if(currentColor>colors.size()-1) // We check that currentColor doesn't reach out the last color currentColor=0; // If it happens we restart the cycle colorTimeUpdate=0; // and we reset the update variable for another 2 seconds cycle } mySprite.rotate(10*frametime); // We rotate our sprite cuz yolo. } void Entity::setTexture( const sf::Texture& texture) { mySprite.setTexture(texture); mySprite.setOrigin(mySprite.getTextureRect().width/2, mySprite.getTextureRect().height/2); // We set the origin to the middle of the sprite } void Entity::setPosition(float x, float y) { mySprite.setPosition(x,y); } void Entity::setCurrentColor(int color) { if(color<colors.size() && color>0) currentColor = color; }
#include <SFML/Graphics.hpp> #include <map> class ShadersManager { public: static sf::Shader* getShader(const std::string& path); private: class ShaderHolder { public: ShaderHolder(); ~ShaderHolder(); sf::Shader* getShader() const; // We get a pointer on the shader bool loadShaderFromFile(const std::string& path); // Loads the shader from the path, and returns true if succeed. // Note: we could also add other functions to load shaders from different streams. private: sf::Shader* myShader; }; typedef std::map<std::string, ShaderHolder> ShadersMap; static ShadersMap myShaders; };
#include "ShadersManager.hpp" #include <iostream> ShadersManager::ShadersMap ShadersManager::myShaders; // We don't forget to init the static shaders map sf::Shader* ShadersManager::getShader(const std::string& path) { ShadersMap::iterator it = myShaders.find(path); if(it != myShaders.end()) return it->second.getShader(); // We search for the shader, and if it exists, we return it // The shader has not been loaded yet, we load & return it. if(!myShaders[path].loadShaderFromFile(path)) std::cout << "An error occured while loading the following shader:" << path << std::endl; // Note: In a real video game, you want to handle this error. return myShaders[path].getShader(); } ShadersManager::ShaderHolder::ShaderHolder() { myShader = NULL; } ShadersManager::ShaderHolder::~ShaderHolder() { if(myShader) delete myShader; } sf::Shader* ShadersManager::ShaderHolder::getShader() const { return myShader; }; bool ShadersManager::ShaderHolder::loadShaderFromFile(const std::string& path) { if(!myShader) myShader=new sf::Shader; return myShader->loadFromFile(path, sf::Shader::Fragment); }
#include "World.hpp" int main() { World::getInstance().run(); return 0; }
Posted by theDaftDev on 10 June 2014 - 05:01 AM
Posted by theDaftDev on 07 June 2014 - 04:00 AM
At least I now won't have to get you one for your birthday.
Everytime I see your avatar when I'm scrolling down, I know I have to take a deep breathe. Thank you.
Posted by theDaftDev on 07 June 2014 - 03:57 AM
This totally deserves the news.
Posted by theDaftDev on 06 June 2014 - 01:15 PM
I don't even have a reply for that
that's just cool
Much serenity.
Posted by theDaftDev on 06 June 2014 - 01:06 PM
Posted by theDaftDev on 04 June 2014 - 12:21 PM
^ I almost died on this one ^
Posted by theDaftDev on 03 June 2014 - 01:18 AM
Also, I'm not actually mad; just yell-y. Blame JonTron.
We can still have a high five, you .
Posted by theDaftDev on 02 June 2014 - 05:20 PM
How am I still alive.. I CAN'T BREATHE.
Posted by theDaftDev on 01 June 2014 - 02:51 PM
This got me laughing so hard that I seriously thought about making a whole thread out of it.
EXCELLENT.