का उपयोग कर 3 डी स्पेस में एक एससीएनओडी ऑब्जेक्ट को घुमाएं मैं सीनकेकिट के आसपास अपना रास्ता सीखने की कोशिश कर रहा हूं और उदाहरण के तौर पर, मैंने सोचा कि मैं एसडीके का उपयोग कर सौर प्रणाली बनाने की कोशिश करूंगा। मैं एससीएनओडी ऑब्जेक्ट्स जोड़ने और पैटर्न और प्रकाश जैसे सामग्री गुणों को कॉन्फ़िगर करने में सक्षम हूं। इसके अलावा, मैं ग्रहों को घुमाने में सक्षम हूं, लेकिन मुझे समझ में नहीं आ रहा है कि मैं उन्हें किसी विशेष पथ के साथ "घूमता" कैसे करूं।SceneKit
मेरे कोड अब तक लगता है कि:
// create a new scene
SCNScene *scene = [SCNScene scene];
// create and add a camera to the scene
SCNNode *cameraNode = [SCNNode node];
cameraNode.camera = [SCNCamera camera];
[scene.rootNode addChildNode:cameraNode];
// place the camera
cameraNode.position = SCNVector3Make(0, 0, 2);
// create and add a 3d sphere - sun to the scene
SCNNode *sphereNode = [SCNNode node];
sphereNode.geometry = [SCNSphere sphereWithRadius:0.3];
[scene.rootNode addChildNode:sphereNode];
// create and configure a material
SCNMaterial *material = [SCNMaterial material];
material.diffuse.contents = [NSImage imageNamed:@"SunTexture"];
material.specular.contents = [NSColor whiteColor];
material.specular.intensity = 0.2;
material.locksAmbientWithDiffuse = YES;
// set the material to the 3d object geometry
sphereNode.geometry.firstMaterial = material;
// create and add a 3d sphere - earth to the scene
SCNNode *earthNode = [SCNNode node];
earthNode.geometry = [SCNSphere sphereWithRadius:0.15];
NSLog(@"Sun position = %f, %f, %f", sphereNode.position.x, sphereNode.position.y, sphereNode.position.z);
earthNode.position = SCNVector3Make(0.7, 0.7, 0.7);
NSLog(@"Earth position = %f, %f, %f", earthNode.position.x, earthNode.position.y, earthNode.position.z);
//earthNode.physicsBody = [SCNPhysicsBody dynamicBody];
[scene.rootNode addChildNode:earthNode];
SCNMaterial *earthMaterial = [SCNMaterial material];
earthMaterial.diffuse.contents = [NSImage imageNamed:@"EarthTexture"];
earthNode.geometry.firstMaterial = earthMaterial;
मैं AppleDocs कि आप सूर्य की समन्वय प्रणाली में और रूट नोड में नहीं ग्रहों जोड़ने की जरूरत में कहीं पढ़ा है लेकिन मुझे यकीन है कि अगर मैं समझ नहीं कर रहा हूँ वैसे भी ठीक है।
मुझे बताएं कि आप इसे करने के बारे में कैसे प्राप्त करते हैं।
कामकाज के रूप में, मैंने आपके बिंदु की तरह कुछ लागू किया है। विस्तृत उत्तर के लिए धन्यवाद और भौतिकी को लागू करने का विचार रोमांचक लगता है। –
बहुत बढ़िया। बस ... बस कमाल है। – Nerrolken
इससे बहुत मदद मिलती है। इसके अलावा, अगर आपने ऑर्री के साथ जाने का फैसला किया है और आप चाहते हैं कि आपके सभी ग्रहों के पास अलग-अलग पथ हों। आप हमेशा सूर्य के केंद्र में छिपा नोड जोड़ सकते हैं और अपनी धुरी घुमा सकते हैं;) – doNotCheckMyBlog