SCNLight: 燈光
概念:游戲框架中的光源,為場(chǎng)景 提供陰影
-
燈光的分類(光源分為四種):
- 環(huán)境光(SCNLightTypeAmbient),這種光沒有方向,位置在無窮遠(yuǎn)處,光均勻的散射在物體上
- 點(diǎn)光源(SCNLightTypeOmni):有固定位置,方向360度,可以衰減
- 平行方向光(SCNLightTypeDirectional):只有照射的方向,沒有位置,不會(huì)衰減
-
聚焦光源(SNCLightTypeSpot):光有固定位置,也有方向,也有照射區(qū)域,可以衰減
光源的顏色: Color
光源溫度: temperature
光源強(qiáng)度: intensity: 默認(rèn) 是 1000
CastsShadow:是否支持投射陰影,這個(gè)只有在點(diǎn)光源或者平行方向光源有作用
shadownColor: 陰影顏色
SCNGeometry: 幾何對(duì)象
- SCNGeometry: SCeneKit 游戲框架中的幾何對(duì)象.將幾何對(duì)象綁定到節(jié)點(diǎn)上,顯示到view
- 系統(tǒng)包含的,
正方體,
平面(SCNPlane),
金字塔,
球體,
圓柱體,
圓錐體,
管道,
環(huán)面,
地板(SCNFloor),
立體字,
自定義形狀(通過貝塞爾曲線)創(chuàng)建SCNShape
然后賦值給Node 節(jié)點(diǎn) - 代碼:
// 1. 球體
SCNSphere *sphere = [SCNSphere sphereWithRadius:0.5];
sphere.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *earthNode = [SCNNode nodeWithGeometry:sphere];
// [scene.rootNode addChildNode:earthNode];
//2. 字體
SCNText *scntext = [SCNText textWithString:@"Lenovo" extrusionDepth:0.3];
scntext.font = [UIFont systemFontOfSize:0.3];
SCNNode *textnode = [SCNNode nodeWithGeometry:scntext];
textnode.position = SCNVector3Make(-1, 0, -2);
// [earthNode addChildNode:textnode];
// 3. 平面
SCNPlane *plane = [SCNPlane planeWithWidth:2 height:2];
plane.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *planeNode = [SCNNode nodeWithGeometry:plane];
// [scene.rootNode addChildNode:planeNode];
// 4. 金字塔
SCNPyramid *pyramid = [SCNPyramid pyramidWithWidth:1 height:1 length:1];
pyramid.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *pyramidNode = [SCNNode nodeWithGeometry:pyramid];
// [scene.rootNode addChildNode:pyramidNode];
//5. 圓柱體
SCNCylinder *cylinder = [SCNCylinder cylinderWithRadius:1 height:1.5];
cylinder.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *cylinderNode = [SCNNode nodeWithGeometry:cylinder];
// [scene.rootNode addChildNode:cylinderNode];
//6. 管道
SCNTube *tube = [SCNTube tubeWithInnerRadius:0.5 outerRadius:0.6 height:1];
tube.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *tubeNode = [SCNNode nodeWithGeometry:tube];
// [scene.rootNode addChildNode:tubeNode];
//6. 管道
SCNTorus *torus = [SCNTorus torusWithRingRadius:1 pipeRadius:0.5 ];
torus.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *torusNode = [SCNNode nodeWithGeometry:torus];
// [scene.rootNode addChildNode:torusNode];
// 7. 地面
SCNFloor *floor = [SCNFloor floor];
floor.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *floorNode = [SCNNode nodeWithGeometry:floor];
// [scene.rootNode addChildNode:floorNode];
SCNShape *customShap = [SCNShape shapeWithPath:[UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 1, 1) cornerRadius:0.5] extrusionDepth:3];
customShap.firstMaterial.diffuse.contents = @"earth.jpg";
SCNNode *customShapNode = [SCNNode nodeWithGeometry:customShap];
[scene.rootNode addChildNode:customShapNode];
SCNCamera: 相機(jī)
以后用到單獨(dú)講解