Categories
Common talks Objective-C

How to create geometry in SceneKitКак создать геометрию в SceneKit

Small code example, how to create 3D Geometry in SceneKit from scratch. Apple didnt provide any samples, so i hope this will be useful for someone.

SCNNode *myNode = [SCNNode nodeWithGeometry:[self createGeometry]];

- (SCNGeometry *) createGeometry{

NSArray *sources = @[
[SCNGeometrySource geometrySourceWithVertices: (SCNVector3[]){
{.x = -1.0f, .y = -1.0f, .z = 0.0f},
{.x = -1.0f, .y = 1.0f, .z = 0.0f},
{.x = 1.0f, .y = 1.0f, .z = 0.0f},
{.x = 1.0f, .y = -1.0f, .z = 0.0f}
} count:4],
[SCNGeometrySource geometrySourceWithNormals:(SCNVector3[]){
{.x = 0.0f, .y = 0.0f, .z = -1.0f},
{.x = 0.0f, .y = 0.0f, .z = -1.0f},
{.x = 0.0f, .y = 0.0f, .z = -1.0f},
{.x = 0.0f, .y = 0.0f, .z = -1.0f}
} count:4],
[SCNGeometrySource geometrySourceWithTextureCoordinates:(CGPoint[]){
{.x = 0.0f, .y = 0.0f},
{.x = 0.0f, .y = 1.0f},
{.x = 1.0f, .y = 1.0f},
{.x = 1.0f, .y = 0.0f}
} count:4]
];

NSArray *elements = @[
[SCNGeometryElement geometryElementWithData:[NSData dataWithBytes:(short[]){0, 2, 3,0,1,2} length:sizeof(short[6])]
primitiveType:SCNGeometryPrimitiveTypeTriangles
primitiveCount:2
bytesPerIndex:sizeof(short)]];

SCNGeometry *geo = [SCNGeometry geometryWithSources:sources elements:elements];

SCNMaterial *mat = [SCNMaterial material];
mat.diffuse.contents = [NSColor redColor];

geo.firstMaterial = mat;
geo.firstMaterial.doubleSided = YES;

return geo;

}

 

Categories
Common talks Objective-C

Grab2Drop approved in AppStoreGrab2Drop заапрувили в AppStore

Grab2Drop was approved in AppStore. I’m happy! )

Download_on_the_App_Store_Badge_US-UK_135x40

 

 

Pro version coming soon.Grab2Drop появился в AppStore. Я счастлив! )

Download_on_the_App_Store_Badge_US-UK_135x40

 

 

Скоро допилю Pro версию.

Categories
Common talks Objective-C Others

Grab2Drop – share screenshots via Dropbox

On NewYear holidays i wrote small Mac OSX Application – Grab2Drop.

g2d_icon_cut

It save your screenshot to Dropbox and give back URL to it. Easy way to share screenshots with friends.

I setup small site for it – grab2drop.com

Hope, you will find it helpful. Post your comments and suggestions please. Maybe bug reports? )))