SFML community forums

Help => General => Topic started by: Fierce_Dutch on December 28, 2010, 05:07:32 am

Title: How do I create my own GetPosition() Function?
Post by: Fierce_Dutch on December 28, 2010, 05:07:32 am
Well I am working with OpenGL now and I want to return the position of the 3DRect like this. GetPosition().x or GetPosition.y or GetPosition().z. So how would I do this?

Also on a side note. How do I rotate around a local origin and not a world origin. Like rotate in place?
Title: Edit: Deleted.
Post by: Kobie on January 01, 2011, 05:54:22 am
Edit: Deleted.
Title: How do I create my own GetPosition() Function?
Post by: Terrydil on January 01, 2011, 09:48:38 pm
If you are using pure OpenGL I think what you want to do is pushmatrix->translate to where your object is->rotate->draw->popmatrix.

Are you trying to get coordinates of an object or of the mouse?  The object should know its own coordinates (if its drawing its own vertexes), the mouse you could get window coords and offset by the view offset.
Title: How do I create my own GetPosition() Function?
Post by: Fierce_Dutch on January 02, 2011, 07:04:39 am
Quote from: "Terrydil"
If you are using pure OpenGL I think what you want to do is pushmatrix->translate to where your object is->rotate->draw->popmatrix.

Are you trying to get coordinates of an object or of the mouse?  The object should know its own coordinates (if its drawing its own vertexes), the mouse you could get window coords and offset by the view offset.


Well I am trying to be able to do this GetPosition().x or GetPosition().y
Title: How do I create my own GetPosition() Function?
Post by: Lupinius on January 02, 2011, 02:36:40 pm
When the GetPosition function returns an object that has an x and an y member variable you can use is that way. The SFML Vector classes have attributes like that.
Title: How do I create my own GetPosition() Function?
Post by: Fierce_Dutch on January 02, 2011, 10:18:29 pm
Quote from: "Lupinius"
When the GetPosition function returns an object that has an x and an y member variable you can use is that way. The SFML Vector classes have attributes like that.


Ok so I have to return a class and then do the . for its variables?
Title: How do I create my own GetPosition() Function?
Post by: Lupinius on January 03, 2011, 12:20:04 am
Yes.
You can access the members of a returned value like you would with a value you stored in a variable.
Title: How do I create my own GetPosition() Function?
Post by: Fierce_Dutch on January 03, 2011, 06:11:59 am
Quote from: "Lupinius"
Yes.
You can access the members of a returned value like you would with a value you stored in a variable.


Thanks!
I am just returning maps for fun now lol. it looks quite funny.
Return()["var1"];
lol I get the picture now thanks!