Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - OniLinkPlus

Pages: 1 ... 28 29 [30] 31 32 ... 34
436
Graphics / sf::Shape::GetPosition() returns nan
« on: December 14, 2009, 03:28:45 pm »
Well, you didn't ask for minimal, so:
Code: [Select]
#include <SFML/Graphics.hpp>
#include <vector>
#include <iostream>
#include <cmath>

class Particle{
    private:
        double myMass;
        double myRadius;
        sf::Shape myShape;
        sf::Vector2f myVelocity;
    public:
        Particle(double newX = 0.f, double newY = 0.f, double newMass = 2.f*3.14159265358979) :
        myMass(newMass),
        myRadius(newMass/(2.f*3.14159265358979)),
        myShape(sf::Shape::Circle(newX, newY, myRadius, sf::Color(255, 255, 255, 255))),
        myVelocity(sf::Vector2f(0.f, 0.f)){
        }
        double GetMass() const{
            return myMass;
        }
        double GetRadius() const{
            return myRadius;
        }
        const sf::Shape *GetShape() const{
            return &myShape;
        }
        sf::Vector2f GetVelocity() const{
            return myVelocity;
        }
        void Move(sf::Vector2f Delta){
            myVelocity += Delta;
        }
        void Update(){
            myShape.Move(myVelocity);
        }
        ~Particle(){
        }
};

std::vector<Particle> Particles;
sf::RenderWindow Window;

int main(){
    Window.Create(sf::VideoMode(512, 512, 32), "Solar System Simulator", sf::Style::Close, sf::ContextSettings(24, 8, 0, 3, 2));
    Window.SetFramerateLimit(50);
    srand(time(NULL));
    for (int i = 0; i < 100; i++){
        Particles.push_back(Particle(rand()%512, rand()%512));
    }
    while (Window.IsOpened()){
        sf::Event Event;
        while (Window.GetEvent(Event)){
            if (Event.Type == sf::Event::Closed || (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape))
                Window.Close();
        }
        Window.Clear();
        for (unsigned int s = 0; s != Particles.size(); s++){
            for (unsigned int t = s+1; t != Particles.size(); t++){
                double DeltaX = Particles.at(t).GetShape()->GetPosition().x - Particles.at(s).GetShape()->GetPosition().x;
                std::cout << Particles.at(t).GetShape()->GetPosition().x << '\n';
                double DeltaY = Particles.at(t).GetShape()->GetPosition().y - Particles.at(s).GetShape()->GetPosition().y;
                double Distance = DeltaX*DeltaX + DeltaY*DeltaY;
                double Mass = Particles.at(s).GetMass() * Particles.at(t).GetMass();
                double Newtons = (6.67428/100000000000.f)*Mass/Distance;
                double Direction = atan2(DeltaY, DeltaX);
                Particles.at(s).Move(sf::Vector2f(-cos(Direction)*Newtons/Particles.at(s).GetMass(), -sin(Direction)*Newtons/Particles.at(s).GetMass()));
                Particles.at(t).Move(sf::Vector2f(cos(Direction)*Newtons/Particles.at(t).GetMass(), sin(Direction)*Newtons/Particles.at(t).GetMass()));
            }
        }
        for (unsigned int i = 0; i != Particles.size(); i++){
            Particles.at(i).Update();
            Window.Draw(*Particles.at(i).GetShape());
        }
        Window.Display();
    }
    return EXIT_SUCCESS;
}

Stupid particle simulations. I don't see what the problem could be, as I have checked over my code several times, so if it is my fault, it's probably a really dumb mistake.

437
Graphics / sf::Shape::GetPosition() returns nan
« on: December 14, 2009, 05:33:23 am »
Ahhhh.
I'm trying to get the distance between two sf::Shapes in the latest SVN Build, but when I construct an sf::Shape, set its position, then try to get its x position with GetPosition().x, it gives nan, completely screwing up my simulation. HALP!

438
Feature requests / Vertex Shaders
« on: December 11, 2009, 04:46:09 am »
So you have Pixel Shaders working pretty well, I think that you should go ahead and allow us to write our own Vertex Shaders now. It would increase the Flexibility without needing too much to be changed. I am positive someone can find an use for Vertex Shaders in 2D, and if nobody can, then at least we can use gl* 3D Functions with 100% Custom Shaders!

439
General discussions / Hidden SFML functionality
« on: December 04, 2009, 06:27:06 pm »
Quote from: "Tank"
Acceleration sensors?
Yes, an accelerometer.

440
Graphics / Processor gets hot and motherboard beeps
« on: November 29, 2009, 03:05:33 am »
The heating up is supposed to happen. Motherboards should be able to withstand somewhere around 70-80C. Not sure about the beeping though. Does the console give you any error messages?

441
Audio / Fixed audio crashes at startup
« on: November 28, 2009, 01:07:22 am »
This update has created a problem when compiling Audio:
../../extlibs/headers/sndfile.h|308|error: ‘__int64’ does not name a type|
This leads to several more errors caused by this. Any ideas on what went wrong? It only happens when compiling the Windows version, through both TDM MinGW and stable MinGW.

Fix: Delete the Build Directory and then SVN Update

442
Window / Build 1291 sf::Utf8 error when compiling
« on: November 27, 2009, 08:10:46 am »
Linux/WindowImplX11.cpp: In member function ‘bool sf::priv::WindowImplX11::ProcessEvent(XEvent)’:
Linux/WindowImplX11.cpp:702: error: ‘Utf8’ has not been declared

I get that when I try to compile the latest build on Linux. I ran make clean then make sfml, and it fails to compile libsfml-window.so with that error.

Fixed by replacing this line:
#include <SFML/System/Unicode.hpp>
with this line:
#include <SFML/System/Utf.hpp>

443
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 20, 2009, 04:25:53 am »
Quote from: "Laurent"
Quote
I got the debug binaries working. Blackness when I use RenderImage. Nothing in stderr, either.

What about the Shader sample? Does it work?
Yes. It's probably a problem with sf::RenderImage, as that is where my problem is at.

444
General / Compiling SFML2 binaries using build.bat
« on: November 20, 2009, 04:24:05 am »
sfml-main is not in build.bat, I don't think. Also, if you are on Linux, you don't need sfml-main.
For linking with static libraries, add -lGL to your Linker options for Linux, and -lopengl32 for Win32.

445
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 19, 2009, 03:25:20 am »
I got the debug binaries working. Blackness when I use RenderImage. Nothing in stderr, either.

446
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 18, 2009, 04:19:51 pm »
Quote from: "Laurent"
No, it's the same. What's wrong?
I run make sfml DEBUGBUILD=yes, and even try setting DEBUGBUILD=yes in the makefile manually, but only the release binaries are built.

447
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 18, 2009, 03:01:59 am »
Has the DEBUGBUILD=yes/no changed since SFML1.x? I can't seem to get it to compile debug.

448
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 18, 2009, 12:24:36 am »
Quote from: "Laurent"
Weird. Do you run in debug mode? Is there any message in the standard error output?
Nothing in stderr, I use Release.

449
SFML website / Duplicated phrase :P
« on: November 17, 2009, 03:36:32 pm »
Shouldn't that "of" be an "or"?

450
General discussions / New Shader class in SFML 2 to replace PostFx
« on: November 17, 2009, 03:35:34 pm »
Quote from: "Laurent"
What does RenderImage::IsAvailable() return?
True.

Pages: 1 ... 28 29 [30] 31 32 ... 34