Placing emitter at touch location - viewport size smaller than screen - tutorial 12

View previous topic View next topic Go down

Placing emitter at touch location - viewport size smaller than screen - tutorial 12

Post  gezerk on Thu Apr 30, 2009 10:58 am

I am experimenting with tutorial 12. I am trying to get the emitter location to move to where I touch the screen. I am able to get the emitter to move with this code:

Code:

_SIO2emitter->_SIO2transform->loc->x = _SIO2window->touch[ 0 ].x;
_SIO2emitter->_SIO2transform->loc->y = _SIO2window->touch[ 0 ].y;

However, the emitter isn't visible after I do that. It appears the x,y location for the touch is outside the viewport (or otherwise off the screen).
Dividing the touch location by 100 will move the emitter from it's original location and make it visible (although it doesn't move to where I touched):

Code:

_SIO2emitter->_SIO2transform->loc->x = _SIO2window->touch[ 0 ].x/100;
_SIO2emitter->_SIO2transform->loc->y = _SIO2window->touch[ 0 ].y/100;

That makes me think the grid for SIO is smaller than the grid for the screen. I think I need to set the viewport to match the screen size for this to work. I looked for where the viewport gets set. I found this reference to the viewport, but I can't really tell what it does:

Code:

sio2WindowUpdateViewport( sio2->_SIO2window, 0, 0, backingWidth, backingHeight );

I am a complete newb, so I really appreciate your help. Please don't assume I know what to do, I just learned what a viewport was yesterday.

gezerk

Posts : 2
Join date : 2009-04-30

View user profile

Back to top Go down

Re: Placing emitter at touch location - viewport size smaller than screen - tutorial 12

Post  oioioi on Thu Apr 30, 2009 11:22 am

_SIO2window->touch[ 0 ] is just the position on your iphone's screen, not the position in your 3d world. Test tutorial 5 in the simulator and look at touch position, thats should give you an idea of _SIO2window->touch works

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Placing emitter at touch location - viewport size smaller than screen - tutorial 12

Post  gezerk on Wed May 06, 2009 8:56 pm

oioioi wrote:_SIO2window->touch[ 0 ] is just the position on your iphone's screen, not the position in your 3d world. Test tutorial 5 in the simulator and look at touch position, thats should give you an idea of _SIO2window->touch works


I took a look at tutorial 5. I understand the touch position is the screen position. What I don't understand is how that translates to the 3D world. Tutorial 5 didn't seem to help since all it does is display the touch position on the screen. I think I need to understand how the dimensions of the 3D world get set so I can either adjust the screen touch to fit 3D, or set 3D to match the screen.

gezerk

Posts : 2
Join date : 2009-04-30

View user profile

Back to top Go down

Re: Placing emitter at touch location - viewport size smaller than screen - tutorial 12

Post  sio2interactive on Wed May 06, 2009 9:23 pm

Check for sio2Project & sio2UnProject, they are acting the same way as gluProject and gluUnProject... with that you can do 2D -> 3D coordinate or 3D -> 2D coordinate conversion.

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Hi

Post  narender.mudgal on Sat Aug 08, 2009 4:49 pm

Can you be some more specific please
where can i find sio2Project working code.
I am very new to sio2 so I am not getting through these keywords
it will be a great help .
Thanks
Naren

narender.mudgal

Posts : 7
Join date : 2009-08-08

View user profile

Back to top Go down

Re: Placing emitter at touch location - viewport size smaller than screen - tutorial 12

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum