2d click to 3d point/object

View previous topic View next topic Go down

2d click to 3d point/object

Post  sodapunk on Tue Sep 30, 2008 10:17 pm

after getting the x and y of a touch using sio2->_SIO2window->_SIO2windowtap I want to get the object and the point on that object that the person touches.

I've been researching into doing this, but I couldn't find anything concrete.

Could anyone help me out on this or point me in the right direction?

sodapunk

Posts : 7
Join date : 2008-09-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  sio2interactive on Wed Oct 01, 2008 12:08 am

Hummm tutorial06 show you how to implement picking... just double tap on an object...
avatar
sio2interactive

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

View user profile http://sio2interactive.com

Back to top Go down

Re: 2d click to 3d point/object

Post  sodapunk on Wed Oct 01, 2008 12:56 pm

sio2interactive wrote:Hummm tutorial06 show you how to implement picking... just double tap on an object...

thanks for that, I hadn't realized it was called 3d picking. I have it working great now

cheers

sodapunk

Posts : 7
Join date : 2008-09-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  bwalker on Sun Aug 09, 2009 11:25 pm

Okay, I'm looking at the picking code in Tutorial 6, and integrated it into my app, but it's failing with EXC_BAD_ACCESS at the line
Code:
_SIO2physic->_btSoftRigidDynamicsWorld->rayTest( camPos, rayTo, rayCallback );
in the sio2PhysicPick method. Now, I'm doing it a little differently because I have no need for physics support. I just need to be able to click on a 3D object and be able to grab its name. So, I'm basically calling this code directly from the templateScreenTap method. Is this why it's failing?

bwalker

Posts : 10
Join date : 2009-07-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  bwalker on Tue Aug 11, 2009 4:23 am

Okay, I fixed the BAD_ACCESS problem. But now selection is always null as the return value for the sio2PhysicPick method. I see in the debugger that rayTo has values, but rayFrom does not, so I'm guessing it is creating the ray into the world, but the ray is not hitting any objects. So I'm not sure what I'm doing wrong at this point, as I am clicking on a cube when this occurs.

As an aside, this functionality probably should be rolled into a higher-level method within the engine, as it seems like something a lot of people need to do, and right now it's a bit confusing for people like me who don't have a deep knowledge of 3D engines.

bwalker

Posts : 10
Join date : 2009-07-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  sio2interactive on Tue Aug 11, 2009 4:29 am

Use 1.4 and check tutorial062... it'll make your life alot easier... I already do all the dirty work for you, you simply have to use it Wink

_________________
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 : 37
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: 2d click to 3d point/object

Post  bwalker on Tue Aug 11, 2009 9:37 am

Yeah... I am. But like I said before, I don't need to use physics in my app, so I'm not grabbing the entire 62 codebase; just what I thought I needed. (I'm not sure why all the object click code is located in the physics libraries in the first place. Seems to me like an unnecessary code dependency.)

bwalker

Posts : 10
Join date : 2009-07-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  goldfrapp0x0309 on Tue Aug 11, 2009 11:24 pm

OpenGL (on iphone) doesn't have a depth buffer. So accessing "clicked vertex" is impossible unless you track the vertices on ram... which ultimately is a waste of resources since bullet already takes care of that. Also, read about bullet SDK and you'll see how it only loads what is used to the memory. You can load meshes for collision and picking into the physics engine without using the "physics" part of it and all is good.

Gd luck!
avatar
goldfrapp0x0309

Posts : 43
Join date : 2009-02-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  sio2interactive on Wed Aug 12, 2009 12:28 am

OpenGL (on iphone) doesn't have a depth buffer.

>> You mean no GL_DEPTH_COMPONENT...


bwalker: If you don't want to use physic picking check the technique demonstrated in tutorial061.

_________________
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 : 37
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: 2d click to 3d point/object

Post  bwalker on Wed Aug 12, 2009 12:31 am

Alright, well apparently I'm an idiot.

So I wasn't aware that the 61 tutorial demonstrated color picking (and honestly only became aware today that color picking existed in SIO2). So I don't have to use the physics raycasting method after all. Great!

Got it implemented in my app already; works great. Thanks for the assistance.

bwalker

Posts : 10
Join date : 2009-07-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

Post  bwalker on Wed Aug 12, 2009 12:32 am

sio2interactive wrote:
bwalker: If you don't want to use physic picking check the technique demonstrated in tutorial061.

haha, well finally we arrived at the same conclusion. Smile

bwalker

Posts : 10
Join date : 2009-07-28

View user profile

Back to top Go down

Re: 2d click to 3d point/object

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