简体   繁体   English

如何在iPhone中加载,渲染和显示由Maya或Blender创建的obj格式的3d模型,纹理为png或jpg?

[英]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.

相关问题 如何在Vuforia Augmented Reality iOS SDK中使用.obj和.mtl文件加载3D模型 - How to load 3d model with .obj and .mtl file in Vuforia Augmented Reality iOS sdk Opengl ES如何在运行时导入3D模型并将纹理映射到它 - Opengl ES how to import a 3D model and map textures to it on runtime 寻找一个示例应用程序,包括源代码,该示例应用程序在iPhone上显示搅拌机创建的3d图形 - Looking for an example application, including source code, that displays blender created 3d graphics on the iphone 将一个blender模型导出到opengles并在iphone上渲染它 - exporting a blender model to opengles and render it on iphone 将3D Blender模型添加到cocos2d iPhone游戏中 - Add 3D Blender models to cocos2d iPhone game 如何知道这个图像是jpg或png iphone - how to know this image is jpg or png iphone 如何与iPhone上基于OBJ的3D模型进行交互? - How does one interact with OBJ-based 3D models on iPhone? 将Maya模型引入iPhone - Getting a Maya Model into the iPhone 如何基于iPhone TrueDepth相机生成3D模型? - How to generate the 3D model based on iPhone TrueDepth Camera? 在iPhone中使用OpenGL从Blender导出的Header文件绘制3D形状 - Draw 3D shape from Blender exported Header file using OpenGL in iPhone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM