[英]How to Load, render and display 3d model of obj format created by maya or blender in iphone with textures as png or jpg?
Hi i know many wavefrontobj parsers are available in web to load .obj model but mostly are loading without textures so i need to know that how can we load TEXTURES(.png and .jpg). 嗨,我知道网上有很多wavefrontobj解析器可以加载.obj模型,但是大多数都没有纹理加载,因此我需要知道如何加载TEXTURES(.png和.jpg)。 Also i have written code for scaling 3d model and for having interaction with it but its not working.
我也编写了用于缩放3d模型并与其进行交互的代码,但是它不起作用。 So can anyone help me out there to cope with this problem.
因此,谁能帮助我解决这个问题。 Any sample application having all above capabilities will be highly appreciated.
具有上述所有功能的任何示例应用程序将受到高度赞赏。
Thanks in advance.. 提前致谢..
Code for Scaling: 缩放代码:
- (void)scale:(id)sender
{
if([(UIPinchGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded)
{
lastScale = 1.0;
return;
}
CGFloat prevZoomValue = zoomValue;
CGFloat scale = (1.0 - (lastScale - [(UIPinchGestureRecognizer*)sender scale]))/10;
if ([(UIPinchGestureRecognizer*)sender scale] < 1)
{
//user is zooming in
// range 1.0 to 0.0
zoomValue -= scale;
}
else
{
//user is zooming out
// range > 1.0
zoomValue += scale/10;
}
// if zoom value is not in the range then restore last value
if (!(zoomValue < -0.1 && zoomValue > -10.0))
{
zoomValue = prevZoomValue;
lastScale = [(UIPinchGestureRecognizer*)sender scale];
}
}
Code for Interaction: 互动代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// NSMutableSet *currentTouches = [[[event touchesForView:self] mutableCopy] autorelease];
// [currentTouches minusSet:touches];
secondsInterval = CFAbsoluteTimeGetCurrent();
//longPressTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startLongPressCounter) userInfo:nil repeats:YES];
// New touches are not yet included in the current touches for the view
lastMovementPosition = [[touches anyObject] locationInView:self];
rotateX = endMovementPosition.x;
rotateY = endMovementPosition.y;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
idleRotate = FALSE;
CGPoint currentMovementPosition = [[touches anyObject] locationInView:self];
NSLog(@"touchesMoved");
rotateX = (lastMovementPosition.x - currentMovementPosition.x);
rotateY = (lastMovementPosition.y - currentMovementPosition.y);
//[self renderByRotatingAroundX:(lastMovementPosition.x - currentMovementPosition.x) rotatingAroundY:(lastMovementPosition.y - currentMovementPosition.y)];
lastMovementPosition = currentMovementPosition;
}
NSString *path = [[NSBundle mainBundle] pathForResource:@"cubeimage" ofType:@"jpg"];
OpenGLTexture3D *newTexture = [[OpenGLTexture3D alloc] initWithFilename:path width:512 height:512];
self.texture = newTexture;
[newTexture release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.