They don't really "work". It's just a precisely ordered collection of numbers. They have some rules on how operations and made on them such as matrix-matrix multiplication or matrix-vector multiplication.
As to how it relates to what you need, you'll need to give more information on what you're doing.
[QUOTE=Darwin226;30416607]They don't really "work". It's just a precisely ordered collection of numbers. They have some rules on how operations and made on them such as matrix-matrix multiplication or matrix-vector multiplication.
As to how it relates to what you need, you'll need to give more information on what you're doing.[/QUOTE]
I am trying to use DebugView in connection with Farseer Physics. As arguments to the draw function it wants a ref Matrix projection, and a ref Matrix view. What are both of these things, and how do I make them?
There isn't documentation for this, I looked.
Try using the identity matrix for both view and projection:
[code][ 1 0 0 0 ]
[ 0 1 0 0 ]
[ 0 0 1 0 ]
[ 0 0 0 1 ][/code]
That should draw a position ( x, y ) in the world at the pixel position ( x, y ) in the window.
[QUOTE=bobthe2lol;30416669]I am trying to use DebugView in connection with Farseer Physics. As arguments to the draw function it wants a ref Matrix projection, and a ref Matrix view. What are both of these things, and how do I make them?
There isn't documentation for this, I looked.[/QUOTE]
Basically they are information on how to draw things. For the projection one, give it Matrix.Identity and the view, if it is Orthographic you create it using the Matrix.CreateOrthographicOffCenter or something like this, the height and width is the height and width of your window.
Well if it's what I think it is, the projection matrix describes how vertices are affected by their position from the camera.
Basically what it means is, in 2D, Z coordinate means nothing while X and Y are just added to the position of the object.
In 3D, objects further away from the camera are smaller and the matrix is defined in a way so that when the coordinates of the object are multiplied with it, the result is the correct position in the perspective of the camera.
I have no idea what a view matrix is... Maybe the width of the view angle and that stuff.
I can't get my basic SFML program to work. Working in Netbeans.
My current code is this:
[cpp]
/*
* File: main.cpp
* Author: T3hGamerDK
*
* Created on 12. juni 2011, 16:53
*/
#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
/*
*
*/
int main(int argc, char** argv) {
sf::RenderWindow App(sf::VideoMode(800,600), "Fuckin' Testing!");
while( App.IsOpened())
{
sf::Event Event;
while( App.GetEvent(Event) )
{
if( Event.Type == sf::Event::Closed)
App.Close();
}
App.Clear();
App.Display();
}
return 0;
}
[/cpp]
C++ Compiler configuration (using MinGW clean install)
[img]http://goo.gl/VQNga[/img]
Linker configurations
[img]http://goo.gl/VVMc7[/img]
Output
[code]
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Går til katalog '/cygdrive/c/Users/T3hGamerDK/Documents/NetBeansProjects/SFMLTest'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/sfmltest.exe
make[2]: Går til katalog '/cygdrive/c/Users/T3hGamerDK/Documents/NetBeansProjects/SFMLTest'
mkdir -p dist/Debug/MinGW-Windows
g++.exe -o dist/Debug/MinGW-Windows/sfmltest build/Debug/MinGW-Windows/main.o -L../../../Desktop/WORKSPACE/src/SFML-1.6/lib -dynamic -lsfml-graphics -lsfml-window -lsfml-system
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:17: undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:17: undefined reference to `sf::RenderWindow::RenderWindow(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:25: undefined reference to `sf::Window::Close()'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:22: undefined reference to `sf::Window::GetEvent(sf::Event&)'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:29: undefined reference to `sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:29: undefined reference to `sf::RenderTarget::Clear(sf::Color const&)'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:30: undefined reference to `sf::Window::Display()'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:19: undefined reference to `sf::Window::IsOpened() const'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:17: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:17: undefined reference to `sf::RenderWindow::~RenderWindow()'
C:\Users\T3hGamerDK\Documents\NetBeansProjects\SFMLTest/main.cpp:17: undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2: ld returned 1 exit status
make[2]: Forlader katalog '/cygdrive/c/Users/T3hGamerDK/Documents/NetBeansProjects/SFMLTest'
make[2]: *** [dist/Debug/MinGW-Windows/sfmltest.exe] Fejl 1
make[1]: *** [.build-conf] Fejl 2
make: *** [.build-impl] Fejl 2
make[1]: Forlader katalog '/cygdrive/c/Users/T3hGamerDK/Documents/NetBeansProjects/SFMLTest'
BUILD FAILED (exit value 2, total time: 6s)
[/code]
I'm not sure what I'm doing wrong.
Undefined references are linker errors
I found that the default sfml setup with code blocks didn't link the proper libraries
Heres the ones i use
-lmingw32
-lsfml-audio-s-d
-lsfml-graphics-s-d
-lsfml-network-s-d
-lsfml-window-s-d
-lsfml-system-s-d
-luser32
-lgdi32
-lwinmm
-ldxguid
-lglu32
-lglew32
-lopengl32
Edit:
These are the static libraries for sfml, i think you just remove a -s for the dynamic ones
[QUOTE=Icedshot;30417690]Undefined references are linker errors
I found that the default sfml setup with code blocks didn't link the proper libraries
Heres the ones i use
-lmingw32
-lsfml-audio-s-d
-lsfml-graphics-s-d
-lsfml-network-s-d
-lsfml-window-s-d
-lsfml-system-s-d
-luser32
-lgdi32
-lwinmm
-ldxguid
-lglu32
-lglew32
-lopengl32
Edit:
These are the static libraries for sfml, i think you just remove a -s for the dynamic ones[/QUOTE]
It's still spewing out those errors.
Although, at first, it couldn't find glew32, so I tried without it, I'll look into doing it WITH glew32 tomorrow.
[QUOTE=bobthe2lol;30416669]I am trying to use DebugView in connection with Farseer Physics. As arguments to the draw function it wants a ref Matrix projection, and a ref Matrix view. What are both of these things, and how do I make them?
There isn't documentation for this, I looked.[/QUOTE]
They obviously already a class for matrices (they are asking for a Matrix, that means that they have a Matrix class defined already), so I would assume you simply use functions provided by their class.
Matrices are used to transform points; rotation, translation, scaling can all be done through matrices.
The projection matrix defines a frustrum, a sort of demented cube:
[img]http://www.frustum.net/images/frustum.gif[/img]
This is used to transform points into screen coordinates. You can imagine that point in the picture as a camera.
The view matrix is defines where your "camera" is in the the 3d seen by storing transformations that put it where you want it. Well actually that was a lie. That's pretty much what happens, except instead of moving the "camera", you are moving the scene around the camera, or frustrum.
(Please anyone correct me if I've made a mistake.)
The OpenGL superbible has a pretty good explanation of matrices and the projection/modelview distinction.
Ok so I just started learning ActionScript 3 for Flash CS5, and I made this extremely simple flash to test collision detection.
[img]http://filesmelt.com/dl/as3collision.jpg[/img]
If you notice, it's saying that it detected a collision on the square and circle, even though they aren't actually touching.
How might I make the collision detection more accurate?
[code]
import flash.events.MouseEvent;
square1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
circle1_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
stage.addEventListener(MouseEvent.MOUSE_UP, drop);
function drag(e:MouseEvent):void
{
e.target.startDrag();
}
function drop(e:MouseEvent):void
{
stopDrag();
if (square1_mc.hitTestObject(circle1_mc))
{
trace("Collision detected!");
}
else
{
trace("No collision detected.");
}
}
[/code]
Find the closest point on the edge of the square to the circle, then find the distance of that point to the centre of the circle. If the distance is less than the radius of the circle then it is colliding.
[QUOTE=slayer20;30423045]Ok so I just started learning ActionScript 3 for Flash CS5, and I made this extremely simple flash to test collision detection.
[img]http://filesmelt.com/dl/as3collision.jpg[/img]
If you notice, it's saying that it detected a collision on the square and circle, even though they aren't actually touching.
How might I make the collision detection more accurate?[/QUOTE]
What the above post said. hitTestObject uses a bounding-box collision, so it thinks it's just two rectangles colliding.
[QUOTE=Robert64;30423306]Find the closest point on the edge of the square to the circle, then find the distance of that point to the centre of the circle. If the distance is less than the radius of the circle then it is colliding.[/QUOTE]
I'm bored so I'll do some pseudocode in case you need any more help.
[code]Function IsColliding( Rectangle, Circle )
// Quick AABB check to eliminate most cases
If( Rectangle.Left > Circle.Right Or Rectangle.Right < Circle.Left Or
Rectangle.Top > Circle.Bottom Or Rectangle.Bottom < Circle.Top ) Then
Return False
Else
XCoord := Clamp( Circle.Centre.X, Rectangle.Left, Rectangle.Right )
YCoord := Clamp( Circle.Centre.Y, Rectangle.Top, Rectangle.Bottom )
XDiff := Circle.Centre.X - XCoord
YDiff := Circle.Centre.Y - YCoord
Dist := Sqrt( XDiff * XDiff + YDiff * YDiff )
If Dist < Circle.Radius Then
Return True
Else
Return False
End If
End If
End Function[/code]
[QUOTE=Robert64;30426744][code]XCoord := Clamp( Circle.Centre.X, Rectangle.Left, Rectangle.Right )
YCoord := Clamp( Circle.Centre.Y, Rectangle.Top, Rectangle.Bottom )[/code][/QUOTE]
Holy shit, I never thought of doing it like that... that's far more simple than what I was thinking of to get the closest point on the square... clever bastard!
[QUOTE=Robert64;30426744]I'm bored so I'll do some pseudocode in case you need any more help.
[code] ...
XCoord := Clamp( Circle.Centre.X, Rectangle.Left, Rectangle.Right )
YCoord := Clamp( Circle.Centre.Y, Rectangle.Top, Rectangle.Bottom )
XDiff := Circle.Centre.X - XCoord
YDiff := Circle.Centre.Y - YCoord
Dist := Sqrt( XDiff * XDiff + YDiff * YDiff )
If Dist < Circle.Radius Then
...[/code][/QUOTE]
As above, really nice way of phrasing how to find the closest point.
A heads up to slayer though: you'll want to compute the Dist variable without using Sqrt, then compare against Circle.Radius squared.
[code]
public void CheckCollisions(Rectangle platform)
{
if (Boundaries.Right > platform.Left + 1 && Boundaries.Left < platform.Right - 1)
{
if (Boundaries.Bottom >= platform.Top && Boundaries.Bottom <= platform.Top + mGravity)
{
mPosition.Y = platform.Top - 40;
mFalling = false;
}
else if (Boundaries.Top <= platform.Bottom - mGravity && Boundaries.Top >= platform.Bottom - mGravity)
{
mPosition.Y = platform.Bottom;
mFalling = false;
}
}
if (Boundaries.Bottom > platform.Top + mGravity && Boundaries.Top < platform.Bottom - mGravity)
{
{
if (Boundaries.Right > platform.Left - 1 && Boundaries.Right < platform.Center.X / 2)
{
mPosition.X = platform.Left - 40;
}
}
}
if (!mFalling)
{
if (Boundaries.Top == platform.Top - 40 || Boundaries.Top == platform.Bottom)
{
if (Boundaries.Left > platform.Right)
mFalling = true;
}
}
}
[/code]
My collision code...
The problem - Falling is being a bitch, it won't work for multiple platforms in the same Y position due to the "if (!mFalling)" part
The solution - No idea.
Any help?
Repost because it still isn't fixed... Anybody need the project to help?
[b]I GIVE UP.[/b]
Dear ladies and gentlemen of the WDYNHW thread, I present to you the nightmare that is supposed to be my [b]SFML game engine[/b]. It contains all sorts of shitty programming techniques and errors, and I've been so entangled by them I can't even figure out what to ask help for first. In short, I'm putting the source up for download (Microsoft visual C++ 2008) in the hope that at least one of you could point out the flaws in my programming so I can redo the entire thing without making the same mistakes. Note that you will probably need something in the form of a Hazmat suit to get through my horrid code as the pure sight of it will probably rot your mind. I've commented on everything in the hope of giving you a clear image on what I'm trying to achieve, but frankly enough I don't even know it myself in 90% of the cases. To gain your interest, here is a quote from my input handling system:
[cpp]
//Graphics.cpp
bool GraphicsManager::CheckInput(sf::Key::Code inp)
{
const sf::Input & inpu = GraphicsManager::App.GetInput();
return inpu.IsKeyDown(inp);
}
//Main file
if (GraphMan.CheckInput(sf::Key::Left))
{
PlayerOne.SetX(PlayerOne.GetX()-1);
}
else if (GraphMan.CheckInput(sf::Key::Right))
{
PlayerOne.SetX(PlayerOne.GetX()+1);
}
if (GraphMan.CheckInput(sf::Key::Up))
{
PlayerOne.SetY(PlayerOne.GetY()-1);
}
else if (GraphMan.CheckInput(sf::Key::Down))
{
PlayerOne.SetY(PlayerOne.GetY()+1);
}
[/cpp]
Yeah, it's [b]that[/b] bad. So please consider helping me by downloading the big mess [url=http://www.mediafire.com/?bccq4cwanjkhgcx]here[/url] (2.56MB). Any input is appreciated, even if it's about a misspelled variable. Thank you all in advance!
SFML is no longer working for some reason. The code hasn't been changed since the last time I ran it, I run the makefile and it starts firing out errors about OpenGL functions and variables not being declared. The required libraries are installed and where they should be, but it seems like they don't want to be loaded for some reason. I'm not sure where to continue, but here's the makefile:
[code]
USE = -lsfml-system -lsfml-window -lGLU -lGL
OBJECTS = main.o Gen.o Graphics.o
maze : $(OBJECTS)
g++ -o maze $(OBJECTS) $(USE)
main.o Gen.o : Gen.h
Gen.o Graphics.o : Graphics.h
.PHONY : clean
clean :
rm -f maze $(OBJECTS)
[/code]
Two questions, both dealing with ActionScript.
Here's my code:
[code]
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
preloader_mc.stop();
var myLoader:Loader = new Loader();
var myURL:URLRequest = new URLRequest("image.jpg");
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
function loading(e:ProgressEvent):void
{
var nPercent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
preloader_mc.gotoAndStop(nPercent);
}
function loaded(e:Event):void
{
myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, loading);
myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loaded);
removeChild(preloader_mc);
addChild(myLoader);
}
myLoader.load(myURL);
[/code]
I've made a simple preloader that, when it finishes, it shows an image I have placed on my desktop. The image is larger than the size of the flash window, so my question is, can I scale the image down using ActionScript without actually touching the image itself?
My second question is, can I make it so loads a random image inside a certain folder?
For your first question, in actionscript 2; you could create a movieclip, place the image inside, then scale the movieclip via _width and _height parameters.
For your second question, the best way i know of is to use php to gather a list of all the images in the directory and send it to flash, flash would then pick a random image and use it.
Otherwise you could just name the images, "image1" "image2" and just use random() to select a number and put it in front of "image"
I would give you direct code snippets but actionscript 3 is quite different than actionscript2.
[QUOTE=Naelstrom;30444306]For your first question, in actionscript 2; you could create a movieclip, place the image inside, then scale the movieclip via _width and _height parameters.[/QUOTE]
You can do the same thing in AS3 if you place the image inside the stage. However, I'm loading the image from outside the stage.
I'm trying to use love's physics module, which uses Box2D.
I keep getting a strange error, "edge.LengthSquared() > 1.192092896e-07F * 1.192092896e-07F"
Anybody know what causes this?
Anyone know how a pass-through geometry shader for points should be? Currently I have this, but it doesn't work, whereas the program works without the shader:
[code]#version 330
precision highp float;
layout (points) in;
layout (points) out;
void main(void)
{
gl_Position = gl_in[0].gl_Position;
EmitVertex();
EndPrimitive();
}[/code]
[QUOTE=slayer20;30442419]
I've made a simple preloader that, when it finishes, it shows an image I have placed on my desktop. The image is larger than the size of the flash window, so my question is, can I scale the image down using ActionScript without actually touching the image itself?[/QUOTE]
[code]myLoader.content.width = stage.stageWidth;
myLoader.content.height = stage.stageHeight;[/code]
or change it's scaleX/scaleY.
[QUOTE=slayer20;30442419]
My second question is, can I make it so loads a random image inside a certain folder?[/QUOTE]
Not sure about doing that dynamically, could do a Google search on reading folders in AS3. I would just make an array of all the image paths and make it pick a random one from that.
Edit:
Actually if you publish it as an Adobe Air application you could do this:
[code]
import flash.filesystem.File;
...
var dir:File = File.applicationDirectory;
var fileList:Array = dir.getDirectoryListing();
var myURL:URLRequest = new URLRequest( fileList[ Math.ceil(Math.random()*fileList.length)-1 ].name );
[/code]
[QUOTE=Anthophobian;30435159]long quote snip[/QUOTE]
Alright, I was writing an answer yesterday, just when it was decided that Facepunch should get another short downtime and swallowed what I had written up along side it.
I'll try to remember what I wrote.
First, no need to package the binaries along with the source. You can cut several megabytes via this, leaving a bunch of kilobytes.
About the code:
Read up on header guards, references and const correctness.
It's widely regarded a bad practice to use globals.
Consider using a switch in the event-management.
Consider using a container, e.g. std::vector, in your GraphicsManager instead of the static arrays.
Instead of returning an index, typedef a handle-type, which could be either an iterator (look out for iterator invalidation) or the index would work just fine for random access containers (but typedef'ing it makes it easier to switch to a different container).
You should move some stuff of your GraphicsManager-class into a class called Game or something - like you already noted yourself, input-handling doesn't really fit in a class with that name.
Instead of having that manager-class, create a baseclass for all your graphical entities to inherit from. Instead of doing GraphicsManager::DoStuffForMe you can then just do LoadSprite(...) and override Draw.
Accessing stuff via ThisClass::Stuff seems ridiculous. If you want to be explicit about it, use this->Stuff.
You're close to writing portable code (as far as C++ and SFML go). Just change _tmain to main and _TCHAR to char, wrap the Windows-specific stuff (HideWindow) into #ifdefs and it should compile on Linux (didn't test).
Also, stdafx.h and targetver.h seem pretty useless. To replace targetvar.h, which could be useful for some stuff in the WinAPI, pass the macro as compiler flag.
I think that was all I had. I also just skimmed through the code, so any unclean details may have just passed by.
I want to use sqlite with MinGW, but I need to link it somehow. Unfortunately I can't figure out how to.
-lsqlite3?
[QUOTE=esalaka;30447761]-lsqlite3?[/QUOTE]
I don't have anything to link to. By downloading the DLL I get some .def file, but that's for VS, right?
I got it working. I just compiled sqlite myself into a static library and now it works perfectly and is in the correct format to be linked easily.
EDIT: Don't automerges work?
[QUOTE=sim642;30449905]EDIT: Don't automerges work?[/QUOTE]
One hour limit.
Sorry, you need to Log In to post a reply to this thread.