Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.


@chipxsd

Posts: 3

NGLNewbie

Wed, May 16 2012


I'm so glad NinevehGL got its own forum! Finally a place for a real community to spring.

Anyway ... I'm a total beginner at opengl coding, so my question may sound stupid.

Is there a way to do a hit-test from the viewport's perspective? I have these kind of hit-tests in mind:

  • mesh based - clicking (tapping) a single mesh (or more than one, if you don't want to stop at the first one)
  • vertex based - which would result as a 3d position of a nearest index (vertex of a mesh)
  • texture based - 2d pixel coordinate of a mapped texture


I have a clue this would require raytracing (ray's path from the 2d viewport into 3d world), but it seems so redundant to construct a 3D scene (based on viewport's parameters, meshes, etc...).

If this will be featured in a future release, I'd suggest implementing some of these methods I found in unity's documentation.
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Thu, May 17 2012


In response to: @chipxsd

Hello buddy,

Thanks for your compliments.

About the hit test. Yes, we already have one API under test.
However very far from what Unity believes as a hit test API. Remember that Unity still very far from what a 3D engine should be in iOS.

Anyway, the NinevehGL test API is based on 3 forms of precision and performance:

  • BoundingBox: Fastest way, however very imprecise, once it uses an imaginary box around the mesh. This is exactly as the Box2D physics engine works.
  • Surface: This method can catch the mesh more precisely than the BB, however still with precision loses.
  • Pixel: This method has the maximum precision, however it's expensive and should not be used in every cycle of the render.


Each of these 3 forms of touch detection has its use for specific situations. Depends on what you're planing to do, you choose one of them.
100% like this - 1/1

@chipxsd

Posts: 3

NGLNewbie

Thu, May 17 2012


@dineybomfim that's awesome news! It's exactly what I need - can't wait to try the new API.

Care to share any info on release date?
0% like this - 0/0

@onigl

Posts: 1

NGLNewbie

Mon, May 28 2012


In response to: @chipxsd

I am interresting by this api too.
A date or a estimated month for this release will be great !
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, May 28 2012


Well guys,

No estimated date.
We prefer to take as much as necessary than run against the clock to fit within schedules. So it can take 2 months or 6 months, we don't know.
0% like this - 0/0

@davidchanck

Posts: 16

NGLNewbie

Fri, Jun 1 2012


In response to: @dineybomfim

Hi, just started using your framework and it's really great up to now. The importer is priceless.

Can we have the bounding box hit test up sooner than the rest of the implementation ? I'm developing a 3D non-game app at work and this is pretty critical.

Obviously it's up to you guys, but I think having it is an essential part of the 3D engine.

If there is really no way a beta hit test can be released sooner, then can you just tell me if it's possible to implement something myself?

I'm able to grab the screen x and y pos of my touches. What are the next steps I need to take? Can I get the bounding box of my mesh at it's current state (0.9.3)?

Thanks again for this great piece of software. And especially making it free!
0% like this - 0/0

@davidchanck

Posts: 16

NGLNewbie

Fri, Jun 1 2012


In response to: @davidchanck

I see there's an attribute mesh.touchable?
Can this be used? Don't see it in the online docs.
Thanks!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sat, Jun 2 2012


In response to: @davidchanck

Hello dude,

Yes, in fact the online version already has the bounding box information. You can retrieve it if you want. Every NGLObject3D has the property "boundingBox"

Besides, I believe the online version has a small part of the touch API (that one using the pure bounding box, so it's fast, but not accurate).

The way to get it is from NGLCamera, you'll find a method called "touchingUnderPoint:". Just pass the CGPoint extracted from UITouch. There is also a property called "preferredView", by default it assumes the main window, however if your NGLView is not a full screen view you should set this property before call "touchingUnderPoint".

I know this is a confusing routine for now, but we're working on it.
0% like this - 0/0

@adameisfeld

Posts: 41

NGLUser

Sat, Jun 2 2012


In response to: @chipxsd



I have written my own system for doing hit tests on objects until Nineveh comes out with it's own version. I wont go into all of the routines Im using since youll probably be handling collision differently than I do, but here is the routine for getting a two 3d coordinates from a screen coordinate:



.h file:







.m file:







I wrote these two files inside of this post by taking code from various parts of my project and putting them together so its untested but I believe everything needed is there. Its a UIViewController with a UIView placed ontop of the UIViewController's main view as an IBOutlet, set to be an NGLView. The NGLView's delegate is the view controller itself. A tap gesture recognizer is added to the NGLView (referred to as glView in the code) with a selector pointing to handleTap: when the tap occurs. Upon tapping the screen, the code just finds a start and end position in 3D from the 2D tap location and does nothing with it, as this is just an example.



Also, Ive only included the pertinent UIViewController methods that use the provided code, so you'll have to add all of the other typical view controller methods that come standard. I did this for simplicity.



A lot of the unprojection code was found from various sources on the web.



So using my above code sample you're able to convert a 2D screen coordinate into two 3D coordinates (one close to the camera and one far away) where the touch occured. With this information, you can do whatever collision detection method you want.



My current system is a little complex. Each of my NGLMeshs has an associated array of "bounding boxes" (a simple class describing the position and dimensions of a bounding box for the mesh). I have a routine for detecting if two oriented bounding boxes are intersecting using Single-Axis tests. Whenever a user taps the screen, I create an oriented bounding box that is relatively thin starting at the close position and ending at the far position of the tap. I loop through all of the current active NGLMeshs' in the scene checking if any of their bounding boxes intersect the previously created screen-tap bounding box. If one of their bounding boxes intersects, I add it to an array of hit meshs.



I then go through the entire array of hit meshs and grab the mesh that is closest to the camera. This is the final hit mesh.



Obviously my system has various routines in place to filter through which meshs are checked for collision and whatnot to ensure the speed is consistent.



Goodluck, hope Ive helped somewhat,



- Adam Eisfeld
100% like this - 2/2

@adameisfeld

Posts: 41

NGLUser

Sat, Jun 2 2012


Okay Ive looked over the code I posted and I missed some things from my source when trying to write it into it's own class in the project. I am currently writing everything into a set of classes to handle this stuff, when Im done I will post it here.

- Adam Eisfeld
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Sun, Jun 3 2012


In response to: @adameisfeld

Hey Adam,

Good share!

Just some tips about posting:


Here are some instructions about embed things in this forum: http://nineveh.gl/community/forum/new_forum_feature_embed


And about the code, you could prefer use NGLMatrix.h instead of recreating matrices function. Like nglMatrixInverse, nglMatrixTranspose, nglMatrixMultiply, nglMatrixIdentity, etc..

BTW, nice post, friend!
0% like this - 0/0

@adameisfeld

Posts: 41

NGLUser

Sun, Jun 3 2012


Ah okay, I didn't realize you didn't want long posts like that. No problem.

I have rewritten everything into a nice little set of four classes; AEGLMesh, AEGLBoundingBox, AEGLBoundingBoxFace, and AEGLManager. Just doing some last minute tests and comments to make sure people can understand whats going on, but everything seems to be working fine. The AEGLManager comes with convenience methods such as

- (AEGLMesh*)didTapMeshInArray: (NSArray*)meshArray atViewLocation: (CGPoint) touchLocation;

- (NGLvec3)pickScreenAtX: (float)x Y: (float)y forDistance: (float)distance;

- (BOOL)collisionBetweenAEGLMeshA: (AEGLMesh*)meshA andAEGLMeshB: (AEGLMesh*)meshB;

And the system is designed to allow each AEGLMesh to be built up of a set of bounding boxes instead of just one large bounding box surrounding the mesh, so accuracy can be fine tuned.

I will post everything up tonight as an .xcodeproj for people to use and share. Glad I can contribute back to the community.

- Adam Eisfeld

0% like this - 0/0

@adameisfeld

Posts: 41

NGLUser

Sun, Jun 3 2012


I have posted a new thread containing a download to an .xcode project. This project contains an example of detecting mesh touches and detecting mesh-to-mesh collisions, along with all of the other code involved in the set of classes I am using right now.

Here is the thread:

http://nineveh.gl/community/forum/open_collision_library_for_ninevehgl

- Adam Eisfeld
100% like this - 1/1

@davidchanck

Posts: 16

NGLNewbie

Mon, Jun 4 2012


@dineybomfim said:


In response to:@davidchanck

Hello dude,

Yes, in fact the online version already has the bounding box information. You can retrieve it if you want. Every NGLObject3D has the property"boundingBox"

Besides, I believe the online version has a small part of the touch API(that one using the pure bounding box, so it's fast, but not accurate).

The way to get it is from NGLCamera, you'll find a method called"touchingUnderPoint:". Just pass the CGPoint extracted from UITouch. There is also a property called"preferredView", by default it assumes the main window, however if your NGLView is not a full screen view you should set this property before call"touchingUnderPoint".

I know this is a confusing routine for now, but we're working on it.



Thanks! But sorry, have a few questions.

So I put the following code inside of my drawView render loop.

NGLTouching touching = [_camera touchingUnderPoint:CGPointMake(currentTouchPosition.x, currentTouchPosition.y)];


Not sure what I can do with NGLTouching though. What's this supposed to be returned? Has this been implemented?

Is there a basic form of touch working right now in the online release?
Or you said YES as in I can implement my own?

Thanks,
David

0% like this - 0/0

@davidchanck

Posts: 16

NGLNewbie

Mon, Jun 4 2012


In response to: @davidchanck

Nevermind

Did an NSLog and see that NGLTouching keeps a reference to NGLMesh. Now need to figure out how to access that mesh.

Thank again!
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Mon, Jun 4 2012


In response to: @davidchanck

Yes, the NGLTouching will give you access to the NGLMesh under the touch and the surface which is being touched. This will probably grow to something more precise, like the position inside the surface.
0% like this - 0/0

@davidchanck

Posts: 16

NGLNewbie

Wed, Jun 6 2012


In response to: @dineybomfim

Hi again,

Touch is working. But encounter a road block, I have two imported meshes. One touchable, and one not. When the touchable mesh is positioned over the other mesh, the touchable mesh doesn't register the touch despite its greater z-index. When that touchable mesh has nothing beneath it, it's touchable.

Is this normal at the current state?

Thanks
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Jun 6 2012


In response to: @davidchanck

Yes,

Each NGLMesh has a property called "touchable". By default it's YES. Set it to NO and the mesh will be ignored in the touch routine.

But I'm not sure if the online version already has this feature. Ask us for the last version via email.
0% like this - 0/0

@davidchanck

Posts: 16

NGLNewbie

Wed, Jun 6 2012


In response to: @dineybomfim

I sent you an email just now.
Thanks!
0% like this - 0/0

@chipxsd

Posts: 3

NGLNewbie

Wed, Jun 20 2012


In response to: @adameisfeld

Whoa, thanks man! I'll be sure to look into your code.

I haven't been here a while now, I'm so amazed how fast the community has grown.
0% like this - 0/0

@NihilistMe

Posts: 7

NGLNewbie

Mon, Nov 25 2013


In response to: @adameisfeld

Hi Adam,

Thanks for this post, but the link that is there in the thread. It's not working. Can you please post new link or any way i can download the same.

Thanks
0% like this - 0/0

@phamdacloc

Posts: 4

NGLNewbie

Sun, Sep 21 2014


In response to: @adameisfeld

Does anyone has the project that Adam wrote? Please reshare as the link doesn't work.

Thx
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.