Detecting which side touched in openGLES 3dbox in iphone - iphone

i am working on a project that contains a 3d box that rotated by user touch and opens revelant page when clicked on a side. each side has link to another view so i need to know which side is clicked on the program.
i am using Brad Larson's wonderfull example in my app and i can rotate the cube with touch, thanx to his code and time.
( the code is linked in here: Where to start openGL ES to create and rotate a cube in an iPhone? )
now i need to know how to detect whick side is clicked on the box. normally i develop view based applications, i really have no idea on openGL or things like that.
i've searched the site but couldnt find a good answer (at least something that i can understand with my opengl knowledge)
P.S: Here, the 3dCube code from Brad Larson: http://www.sunsetlakesoftware.com/sites/default/files/CubeExample.zip

Take a look here: http://www.3dkingdoms.com/selection.html
In the OpenGL world, I think they refer to this as "picking". The utility function gluunproject will help you. Intersecting the picking ray with your model's faces should not be hard for a cube.

Related

Simple Cocos2d Iphone Game. Just some basic questions

I'm making an app, where the sprite has to run across the screen pressing buttons and jumping and ducking. Kind of like line runner. Anyways, I'm using cocos2d. Is this what i should be using. If it is, how would i make it. Im not asking for all the code, just the basic objectives and what i should do! thanks so much!
Cocos2d is one of the best platform to make game i think what you want to do can be done by cocos2d and you need to know how to move object(sprite) across the scene and how to detect the collation.
there is lots of way to move the sprite across the screen you can also move then by the cocos2d built in methods.
search for move method which will help you.
I would definitely advise you to use Cocos2d for this purpose and also Box2d if you need real physics simulation in your game.
Regarding of writing your game have a look here : It contains very useful cocos2d tutorials and even have a tutorial of how to write a full functioning game (Look for the monkey game)
Note : It seems that the link does not work right now but I am sure it will be fixed soon..

iOS dev - sharing screen captures

I'm looking to write an app that lets users draw a game, something like tic-tac-toe, for example. One user would begin by drawing the grid, and then each player could literally draw their own O or X. It would be a multiplayer game where each user has his/her own device.
I'm not sure what would be the best way to share this data from device to device. I've only been able to think of 2 options:
Should I attempt to upload a screenshot to the server after each player makes a move?
Should I upload the exact points where the user is drawing and then redraw these points on the other user's screen?
Any other suggestions, or maybe a point in the right direction? I'm fairly new to all of this so please don't be too harsh ;)
starting out on a multiplayer game (even if it is a straightforward one) is ambitious :) if you don't mind restricting yourself to iOS5 and above, then i would check out the new turn based multiplayer game functionality. there's a good tutorial here:
http://www.raywenderlich.com/5480/beginning-turn-based-gaming-with-ios-5-part-1

Iphone OpengGL ES: detecting clicks on a primitive

I have created a 3d environment full of 3D cubes, does anyone have any idea how you would detect a touch on one of these Cubes. I thinking if I could get the cubes screen position (coords start from bottom left) then it would be pretty easy
UPDATE:
I added the function -(CGPoint)getScreenCoorOfPoint:(IMPoint3D)_point3D which seems to give me my items position in the world but the bit I am now stuck on is:
I have objects that have a position
I have my position in the world (gluLookAt eye[0], eye[1], eye[2])
and then I have where I tapped on the screen
How do I join all this up, its the last thing in my way to archiving greatness!!!!
Look up OpenGL picking on Google. There are two main methods to accomplish this, I recommend you use the second one described at OpenGL.org as it does not involve rendering anything offscreen:
[…] involves shooting a pick ray through the mouse location and testing for intersections with the currently displayed objects. OpenGL doesn't test for ray intersections, but you'll need to interact with OpenGL to generate the pick ray.
Also see this question for some discussion on the matter:
Screen-to-World coordinate conversion in OpenGLES an easy task?

iPhone OpenGL: Moving around a 3D environment

this is probably a long shot
I am looking for an example / tutorial of how to render a floor (or room) and move around it. There seems to be the perfect example here:
http://www.cocoachina.com/wiki/index.php?title=OpenGL_ES_13_-_Moving_in_3D
However the download (which is required) is missing.
Does anyone have any code samples for OpenGL 3D and moving around 3D Space
Look at the SIO2 package. There is a tutorial for moving a camera around a room, works out of the box. I forget exactly now but I think it's tutorial 06 or 07. He also puts videos explaining them on YouTube, which is nice.

How can I calibrate the accelerometer?

I'm using the accelerometer to move an object on my screen.
It's only working when the iphone is flat.
If I use the iPhone in another position, the object is not moving like I want
(the Y axis is not well managed).
So, I've to calibrate the position of the accelerometer, I guess.
But I've no idea how to do this.
Please help me.
Thanks in advance.
Regards,
ALpesH
hi hope all is well.
A simple google search came up with this beautiful post.
It is exactly what you wanted. A tutorial on Accelerometer Calibration & Optimizations.
This tutorial assumes you know the basics of the accelerometer. If not there are plenty of tutorials on google that will help get you accustomed to the accelerometer basics.
This tutorial will focus on 3 things:
Calibrating the accelerometer so the user can play your game from any
position.
Changing the "sensitivity" of your object's movement.
Adding the option to "invert" the controls.
First off, why bother adding these features? Simple. Launch your accelerometer based game and try the following tests:
Play sitting up in perfect position.
List item
Play it slouched over.
Play it lying down on your side.
Play it lying on your back with the device parallel to the floor and
the screen facing you.
Obtained from this website:
http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/39833-tutorial-accelerometer-calibration-optimizations.html
Let me know if this helps if it does choose this as the answer.
Other than that if you need any more help let me know
Ive implemented this tutorial code in my own app and i am not playing a simple ping pong game upside down and also playing it on the side whilst lying on the bed. :D
Pk