我想知道哪些節點被擊中,但我的方法僅適用於節點與像SCNBox幾何,SCNFloor ECT但不與.dea模式工作:的HitTest與.dae模型
- (void) handleTap:(UIGestureRecognizer*)gestureRecognize
{
// retrieve the SCNView
SCNView *scnView = (SCNView *)self.view;
// check what nodes are tapped
CGPoint p = [gestureRecognize locationInView:scnView];
NSArray *hitResults = [scnView hitTest:p options:nil];
// check that we clicked on at least one object
if([hitResults count] > 0)
{
SCNNode *hitNode = ((SCNHitTestResult*)[hitResults objectAtIndex:0]).node;
if(hitNode == boxNode)
{
NSLog(@"box hit"); //works
}
if(hitNode == floorNode)
{
NSLog(@"floor hit"); //works
}
if(hitNode == heroNode)
{
NSLog(@"heroNode from .dae hit"); //doesn't work
}
} }
這是我如何製作.dae節點(heroNode):
SCNScene *heroScene = [SCNScene sceneNamed:@"hero" inDirectory:nil options:nil];
heroNode = [heroScene.rootNode childNodeWithName:@"root" recursively:YES];
[scene.rootNode addChildNode:heroNode];
問題在哪裏?
它的工作原理!謝謝:) – Tomasz
聖@ *&#謝謝你這麼多,我被封鎖對這個 – darkheartfelt