Ciechan / BCMeshTransformView

Mesh transforms for UIView
MIT License
1.24k stars 126 forks source link

Nothings showing #23

Closed piotrros closed 7 years ago

piotrros commented 7 years ago

Hi, I wanted to use your library into my swift project. I've created an empty swift project and added your library via cocoa pods.

Here's my ViewController class:

import UIKit
import BCMeshTransformView

class ViewController: UIViewController {

    var transformView:BCMeshTransformView!
    var imageView:UIImageView!
    var transform:BCMutableMeshTransform!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        transformView = BCMeshTransformView(frame: self.view.bounds)
        transformView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

        imageView = UIImageView(image: UIImage(named: "picture.jpg")!)
        imageView.center = CGPoint(x: transformView.contentView.bounds.midX, y: transformView.contentView.bounds.midY)

        transformView.contentView.addSubview(imageView)

        transformView.diffuseLightFactor = 0.0

        transform = BCMutableMeshTransform.identityMeshTransform(withNumberOfRows: 20, numberOfColumns: 20)

        transform.mapVertices { (vertex, vertexIndex) -> BCMeshVertex in
            return BCMeshVertex(from: vertex.from, to: vertex.to)
        }

        transformView.meshTransform = transform

        self.view.addSubview(transformView)
    }

}

When I'm running the app nothing is showing. It's entirely white.

Removing this code:

transform = BCMutableMeshTransform.identityMeshTransform(withNumberOfRows: 20, numberOfColumns: 20)

transform.mapVertices { (vertex, vertexIndex) -> BCMeshVertex in
    return BCMeshVertex(from: vertex.from, to: vertex.to)
}

transformView.meshTransform = transform

doesn't change anything.

But when in xcode I'm switching to "Show UI hierarchy" I can see an image:

https://imgur.com/a/gLg66

Here's a whole sample project:

http://www116.zippyshare.com/v/IUTXbKJg/file.html

Why I cannot see anything? I tried making an example as simple as possible.

piotrros commented 7 years ago

Looks like that was a problem with that library codun't find shader files. I had to copy BCMeshShader.fsh and BCMeshShader.vsh to my project.