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

Author Topic: How do I create my own GetPosition() Function?  (Read 3602 times)

0 Members and 1 Guest are viewing this topic.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
How do I create my own GetPosition() Function?
« 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?

Kobie

  • Guest
Edit: Deleted.
« Reply #1 on: January 01, 2011, 05:54:22 am »
Edit: Deleted.
« Last Edit: December 21, 2012, 12:39:05 am by anonymous191 »

Terrydil

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
How do I create my own GetPosition() Function?
« Reply #2 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.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
How do I create my own GetPosition() Function?
« Reply #3 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

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
How do I create my own GetPosition() Function?
« Reply #4 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.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
How do I create my own GetPosition() Function?
« Reply #5 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?

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
How do I create my own GetPosition() Function?
« Reply #6 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.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
How do I create my own GetPosition() Function?
« Reply #7 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!