public override void SetupSlide(PresentationViewController presentationViewController) { // Add some text TextManager.SetTitle("Loading a 3D Scene"); TextManager.SetSubtitle("DAE Documents"); NodesToDim = new List <SCNNode> (); TextManager.AddBulletAtLevel("Geometries", 0); TextManager.AddBulletAtLevel("Animations", 0); NodesToDim.Add(TextManager.AddBulletAtLevel("Textures", 0)); NodesToDim.Add(TextManager.AddBulletAtLevel("Lighting", 0)); NodesToDim.Add(TextManager.AddBulletAtLevel("Cameras", 0)); NodesToDim.Add(TextManager.AddBulletAtLevel("Skinning", 0)); NodesToDim.Add(TextManager.AddBulletAtLevel("Morphing", 0)); // And an image resting on the ground DaeIcon = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/dae file icon", "png"), 10, false); DaeIcon.Position = new SCNVector3(6, 4.5f, 1); GroundNode.AddChildNode(DaeIcon); AbcIcon = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/abc file icon", "png"), 10, false); AbcIcon.Position = new SCNVector3(6, 4.5f, 30); GroundNode.AddChildNode(AbcIcon); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Create a node to own the "sign" model, make it to be close to the camera, rotate by 90 degree because it's oriented with z as the up axis var intermediateNode = SCNNode.Create(); intermediateNode.Position = new SCNVector3(0, 0, 7); intermediateNode.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); GroundNode.AddChildNode(intermediateNode); // Load the "sign" model var signNode = Utils.SCAddChildNode(intermediateNode, "sign", "Scenes/intersection/intersection", 30); signNode.Position = new SCNVector3(4, -2, 0.05f); // Re-parent every node that holds a camera otherwise they would inherit the scale from the "sign" model. // This is not a problem except that the scale affects the zRange of cameras and so it would be harder to get the transition from one camera to another right var cameraNodes = new NSMutableArray(); foreach (SCNNode child in signNode) { if (child.Camera != null) { cameraNodes.Add(child); } } for (nuint i = 0; i < cameraNodes.Count; i++) { var cameraNode = new SCNNode(cameraNodes.ValueAt((uint)i)); var previousWorldTransform = cameraNode.WorldTransform; intermediateNode.AddChildNode(cameraNode); // re-parent cameraNode.Transform = intermediateNode.ConvertTransformFromNode(previousWorldTransform, null); cameraNode.Scale = new SCNVector3(1, 1, 1); } }
public override void PresentStep(int index, PresentationViewController presentationViewController) { switch (index) { case 0: // Set the slide's title and subtitle and add some text. TextManager.SetTitle("Performance"); TextManager.SetSubtitle("Flattening"); TextManager.AddBulletAtLevel("Flatten node tree into single node", 0); TextManager.AddBulletAtLevel("Minimize draw calls", 0); TextManager.AddCode("#// Flatten node hierarchy \n" + "var flattenedNode = aNode.#FlattenedClone# ();#"); break; case 1: // Discard the text and show a 2D image. // Animate the image's position when it appears. TextManager.FlipOutText(SlideTextManager.TextType.Code); TextManager.FlipOutText(SlideTextManager.TextType.Bullet); var imageNode = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/flattening", "png"), 20, false); imageNode.Position = new SCNVector3(0, 4.8f, 16); GroundNode.AddChildNode(imageNode); SCNTransaction.Begin(); SCNTransaction.AnimationDuration = 1; imageNode.Position = new SCNVector3(0, 4.8f, 8); SCNTransaction.Commit(); break; } }
private void FormMain_Load(object sender, EventArgs e) { var position = new vec3(5, 3, 4) * 0.2f; var center = new vec3(0, 0, 0); var up = new vec3(0, 1, 0); var camera = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height); this.scene = new Scene(camera); this.scene.ClearColor = Color.Black.ToVec4(); { var node = DemoNode.Create(); var ground = GroundNode.Create(); ground.RenderUnit.Methods[0].SwitchList.Add(new PolygonModeSwitch(PolygonMode.Line)); ground.EnableRendering = ThreeFlags.None; var group = new GroupNode(node, ground); this.scene.RootNode = group; } var list = new ActionList(); var transformAction = new TransformAction(scene.RootNode); list.Add(transformAction); var renderAction = new RenderAction(scene); list.Add(renderAction); this.actionList = list; var manipulater = new FirstPerspectiveManipulater(); manipulater.Bind(camera, this.winGLCanvas1); }
void ExecMoveQueue() { GroundNode groundNode = moveList[0]; if (groundNode.index == player.GetComponent <Player>().currentCoordinates) { //Debug.Log ("座標が一緒なので移動はスキップ"); CompleteMove(); } else { player.GetComponent <Animator>().SetFloat("velocity", 3.0f); iTween.MoveTo(player, iTween.Hash( "x", groundNode.ground.transform.position.x, "z", groundNode.ground.transform.position.z, "time", 0.3f, "delay", 0.0f, "easetype", iTween.EaseType.linear, "oncompletetarget", gameObject, "oncomplete", "CompleteMove" )); player.transform.LookAt(new Vector3(groundNode.ground.transform.position.x, player.transform.position.y, groundNode.ground.transform.position.z)); } }
public override void SetupSlide(PresentationViewController presentationViewController) { // Load the character and add it to the scene var heroNode = Utils.SCAddChildNode(GroundNode, "heroGroup", "Scenes/hero/hero", 0.0f); heroNode.Scale = new SCNVector3(0.023f, 0.023f, 0.023f); heroNode.Position = new SCNVector3(0.0f, 0.0f, 15.0f); heroNode.Rotation = new SCNVector4(1.0f, 0.0f, 0.0f, -(float)(Math.PI / 2)); GroundNode.AddChildNode(heroNode); // Convert sceneTime-based animations into systemTime-based animations. // Animations loaded from DAE files will play according to the `currentTime` property of the scene renderer if this one is playing // (see the SCNSceneRenderer protocol). Here we don't play a specific DAE so we want the animations to animate as soon as we add // them to the scene (i.e have them to play according the time of the system when the animation was added). HeroSkeletonNode = heroNode.FindChildNode("skeleton", true); foreach (var animationKey in HeroSkeletonNode.GetAnimationKeys()) { // Find all the animations. Make them system time based and repeat forever. // And finally replace the old animation. var animation = HeroSkeletonNode.GetAnimation(animationKey); animation.UsesSceneTimeBase = false; animation.RepeatCount = float.MaxValue; HeroSkeletonNode.AddAnimation(animation, animationKey); } // Load other animations so that we will use them later SetAnimation(CharacterAnimation.Attack, "attackID", "attack"); SetAnimation(CharacterAnimation.Die, "DeathID", "death"); SetAnimation(CharacterAnimation.Walk, "WalkID", "walk"); }
private void FormMain_Load(object sender, EventArgs e) { //CSharpGL.HowTransformFeedbackWorks.Run(); var position = new vec3(5, 3, 4); var center = new vec3(0, 0, 0); var up = new vec3(0, 1, 0); var camera = new Camera(position, center, up, CameraType.Perspecitive, this.winGLCanvas1.Width, this.winGLCanvas1.Height); this.scene = new Scene(camera) ; //this.scene.ClearColor = Color.Black.ToVec4(); { //var node = ParticleDemoNode.Create(10000); var node = DemoNode.Create(); var ground = GroundNode.Create(); ground.RenderUnit.Methods[0].StateList.Add(new PolygonModeState(PolygonMode.Line)); var group = new GroupNode(node, ground); this.scene.RootElement = group; } var list = new ActionList(); var transformAction = new TransformAction(scene); list.Add(transformAction); var renderAction = new RenderAction(scene); list.Add(renderAction); this.actionList = list; var manipulater = new FirstPerspectiveManipulater(); manipulater.Bind(camera, this.winGLCanvas1); }
public void init() { //set neighbors for (int i = 0; i < groundNodeList.GetLength(0); i++) { for (int j = 0; j < groundNodeList.GetLength(1); j++) { //Debug.Log ("(" + j + "," + k + ") " + groundNodeList[j,k]); if (groundNodeList[i, j] == null) { continue; } GroundNode currentNode = groundNodeList[i, j]; if (i > 0 && groundNodeList[i - 1, j] != null) { currentNode.AddNeighbor(groundNodeList[i - 1, j]); } if (i < groundNodeList.GetLength(0) - 1 && groundNodeList[i + 1, j] != null) { currentNode.AddNeighbor(groundNodeList[i + 1, j]); } if (j > 0 && groundNodeList[i, j - 1] != null) { currentNode.AddNeighbor(groundNodeList[i, j - 1]); } if (j < groundNodeList.GetLength(1) - 1 && groundNodeList[i, j + 1] != null) { currentNode.AddNeighbor(groundNodeList[i, j + 1]); } } } //for }
void CreateGrid() { nodes = new GroundNode[gridSizeY, gridSizeX]; bottomLeftWorldPosition = new Vector2( transform.position.x - gridWorldSize.x / 2 + gridNodeDiameter / 2, transform.position.z - gridWorldSize.z / 2 + gridNodeDiameter / 2); for (int i = 0; i < gridSizeY; i++) { for (int j = 0; j < gridSizeX; j++) { Vector3 worldPosition = new Vector3(); bool isWalkable = true; worldPosition.x = bottomLeftWorldPosition.x + (j * gridNodeDiameter); worldPosition.z = bottomLeftWorldPosition.y + (i * gridNodeDiameter); worldPosition.y = 0; if (Physics.CheckSphere(worldPosition, 1, wallLayerMask)) { isWalkable = false; } nodes[i, j] = new GroundNode(j, i, isWalkable); nodes[i, j].worldPosition = worldPosition; } } print("Grid created!"); }
private void PresentPrimitives(PresentationViewController presentationViewController) { var count = 100; var spread = 0.0f; // create a cube with a sphere shape for (int i = 0; i < count; ++i) { var model = SCNNode.Create(); model.Position = GroundNode.ConvertPositionToNode(new SCNVector3(RandFloat(-1, 1), RandFloat(30, 50), RandFloat(-1, 1)), null); model.EulerAngles = new SCNVector3(RandFloat(0, NMath.PI * 2), RandFloat(0, NMath.PI * 2), RandFloat(0, NMath.PI * 2)); var size = new SCNVector3(RandFloat(1.0, 1.5), RandFloat(1.0, 1.5), RandFloat(1.0, 1.5)); var random = new Random((int)DateTime.Now.Ticks); int geometryIndex = random.Next(0, 7); switch (geometryIndex) { case 0: // Box model.Geometry = SCNBox.Create(size.X, size.Y, size.Z, 0); break; case 1: // Pyramid model.Geometry = SCNPyramid.Create(size.X, size.Y, size.Z); break; case 2: // Sphere model.Geometry = SCNSphere.Create(size.X); break; case 3: // Cylinder model.Geometry = SCNCylinder.Create(size.X, size.Y); break; case 4: // Tube model.Geometry = SCNTube.Create(size.X, size.X + size.Z, size.Y); break; case 5: // Capsule model.Geometry = SCNCapsule.Create(size.X, size.Y + 2 * size.X); break; case 6: // Torus model.Geometry = SCNTorus.Create(size.X, NMath.Min(size.X, size.Y) / 2); break; default: break; } model.Geometry.FirstMaterial.Multiply.Contents = new NSImage(NSBundle.MainBundle.PathForResource("SharedTextures/texture", "png")); model.PhysicsBody = SCNPhysicsBody.CreateDynamicBody(); model.PhysicsBody.Velocity = new SCNVector3(RandFloat(-spread, spread), -10, RandFloat(-spread, spread)); model.PhysicsBody.AngularVelocity = new SCNVector4(RandFloat(-1, 1), RandFloat(-1, 1), RandFloat(-1, 1), RandFloat(-3, 3)); Shapes.Add(model); ((SCNView)presentationViewController.View).Scene.RootNode.AddChildNode(model); } }
// Load movies and display movie layers private AVPlayerLayer ConfigurePlayer(string movieName, string hostingNodeName) { var player = AVPlayer.FromUrl(NSUrl.FromFilename(movieName)); player.ActionAtItemEnd = AVPlayerActionAtItemEnd.None; // loop NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("PlayerItemDidReachEnd"), AVPlayerItem.DidPlayToEndTimeNotification, player.CurrentItem); player.Play(); // Set an arbitrary frame. This frame will be the size of our movie texture so if it is too small it will appear scaled up and blurry, and if it is too big it will be slow var playerLayer = new AVPlayerLayer(); playerLayer.Player = player; playerLayer.ContentsGravity = AVPlayerLayer.GravityResizeAspectFill; playerLayer.Frame = new CGRect(0, 0, 600, 800); // Use a parent layer with a background color set to black // That way if the movie is stil loading and the frame is transparent, we won't see holes in the model var backgroundLayer = CALayer.Create(); backgroundLayer.BackgroundColor = NSColor.Black.CGColor; backgroundLayer.Frame = new CGRect(0, 0, 600, 800); backgroundLayer.AddSublayer(playerLayer); var frameNode = GroundNode.FindChildNode(hostingNodeName, true); var material = frameNode.Geometry.Materials [1]; material.Diffuse.Contents = backgroundLayer; return(playerLayer); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Load the scene var intermediateNode = SCNNode.Create(); intermediateNode.Position = new SCNVector3(6, 9, 0); intermediateNode.Scale = new SCNVector3(1.4f, 1, 1); GroundNode.AddChildNode(intermediateNode); MapNode = Utils.SCAddChildNode(intermediateNode, "Map", "Scenes/map/foldingMap", 25); MapNode.Position = new SCNVector3(0, 0, 0); MapNode.Opacity = 0.0f; // Use a bunch of shader modifiers to simulate ambient occlusion when the map is folded var geomFile = NSBundle.MainBundle.PathForResource("Shaders/mapGeometry", "shader"); var fragFile = NSBundle.MainBundle.PathForResource("Shaders/mapFragment", "shader"); var lightFile = NSBundle.MainBundle.PathForResource("Shaders/mapLighting", "shader"); var geometryModifier = File.ReadAllText(geomFile); var fragmentModifier = File.ReadAllText(fragFile); var lightingModifier = File.ReadAllText(lightFile); MapNode.Geometry.ShaderModifiers = new SCNShaderModifiers { EntryPointGeometry = geometryModifier, EntryPointFragment = fragmentModifier, EntryPointLightingModel = lightingModifier }; }
public List <GroundNode> FindPath(GroundNode _start, GroundNode _dest) //경로가 없으면 null반환 { List <GroundNode> openList = new List <GroundNode>(); List <GroundNode> closeList = new List <GroundNode>(); List <GroundNode> path = new List <GroundNode>(); GroundNode current = null; //시작노드 정보 초기화 _start.SetParent(_start); _start.CalcGScore(); _start.CalcDist(_dest); //openList 초기화 openList.Add(_start); while (openList.Count > 0) { //openList가 전부 비워질 때까지 current = LowestFScoreInList(openList); //openList에서 가장 적은 F비용 노드 선택 if (current == _dest) { //선택된 노드가 목적지인 경우 CreatePath(_start, _dest, path); return(path); } openList.Remove(current); //선택한 노드를 openList에서 제거 closeList.Add(current); //closeList에 추가 List <GroundNode> neighbors = FindNeighbors(current); //인접노드 탐색 for (int i = 0; i < neighbors.Count; i++) { if (closeList.IndexOf(neighbors[i]) >= 0) { continue; } //인접노드가 closeList에 있다면 무시 if (openList.IndexOf(neighbors[i]) < 0) { //openList에 없다면 추가하고 부모를 선택 노드로 설정 openList.Add(neighbors[i]); neighbors[i].SetParent(current); //G스코어와 목적지까지의 거리를 계산하여 노드내에 정보 저장 neighbors[i].SetGScore(neighbors[i].CalcGScore()); neighbors[i].SetHScore(neighbors[i].CalcDist(_dest)); } //시작노드에서 Neighbor까지의 gScore가 current를 거쳐서 Neighbor까지 가는 gScore비용보다 싸면 무시 if (current.GetGScore() + current.CalcDistNeighbor(neighbors[i]) >= neighbors[i].GetGScore()) { continue; } //current를 거쳐서 가는 것이 더 좋다면 Neighbor의 부모를 current로 변경하고 비용을 다시 계산함 neighbors[i].SetParent(current); neighbors[i].SetGScore(current.GetGScore() + current.CalcDistNeighbor(neighbors[i])); } } //while문 종료 //openList가 전부 비었으므로 경로가 존재하지 않음 return(null); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Fog"); TextManager.SetSubtitle("SCNScene"); TextManager.AddEmptyLine(); TextManager.AddCode("// set some fog\n\naScene.#fogColor# = aColor;\n\naScene.#fogStartDistance# = 50;\n\naScene.#fogEndDistance# = 100;#"); //add palm trees var palmTree = Utils.SCAddChildNode(GroundNode, "PalmTree", "Scenes.scnassets/palmTree/palm_tree", 15); palmTree.Rotation = new SCNVector4(1, 0, 0, -(float)(Math.PI / 2)); palmTree.Position = new SCNVector3(4, -1, 0); palmTree = palmTree.Clone(); GroundNode.AddChildNode(palmTree); palmTree.Position = new SCNVector3(0, -1, 7); palmTree = palmTree.Clone(); GroundNode.AddChildNode(palmTree); palmTree.Position = new SCNVector3(8, -1, 13); palmTree = palmTree.Clone(); GroundNode.AddChildNode(palmTree); palmTree.Position = new SCNVector3(13, -1, -7); palmTree = palmTree.Clone(); GroundNode.AddChildNode(palmTree); palmTree.Position = new SCNVector3(-13, -1, -14); palmTree = palmTree.Clone(); GroundNode.AddChildNode(palmTree); palmTree.Position = new SCNVector3(3, -1, -14); }
public bool StartSearch(Vector2 startPos, Vector2 goalPos) { Reset(); startNode = groundNodeList[(int)startPos.x, (int)startPos.y]; goalNode = groundNodeList[(int)goalPos.x, (int)goalPos.y]; goalNode.SetMinimumCost(0); List <GroundNode> list = new List <GroundNode>(); list.Add(goalNode); while (list.Count > 0) { GroundNode tartgetNode = list[0]; foreach (GroundNode neighbor in tartgetNode.neighbors) { if (!neighbor.ground || (neighbor.ground && neighbor.ground.GetComponent <Ground>().life <= 0)) { continue; //GroundのゲームオブジェクトがDestroyされている、またはlife0以下(まだDestroyはされていない)の場合はスキップする } if (neighbor.minimumCost == -1 || tartgetNode.minimumCost + 1 < neighbor.minimumCost) { neighbor.SetMinimumCost(tartgetNode.minimumCost + 1, tartgetNode); list.Add(neighbor); } } list.RemoveAt(0); //最初にstartNodeに到達した経路が最短なので、今ループでstartNodeのminimumCostが確定したらループを抜ける if (startNode.minimumCost != -1) { break; } } //execute seach //Search (goalNode); //startNodeのminimumCostが-1なら到達できていないのでfalseを返す。それ以外はtrueを返す。 return(startNode.minimumCost != -1); /* * //return result * List<GroundNode> list = new List<GroundNode> (); * * if (startNode.minimumCost != -1) { * GroundNode currentNode = startNode; * list.Add (currentNode); * while(currentNode.nextNode is GroundNode) { * list.Add (currentNode.nextNode); * currentNode = currentNode.nextNode; * } * } * * return list; */ }
public int CalcDist(GroundNode _dest) { int x = Mathf.FloorToInt(Mathf.Abs(thisPos.x - _dest.GetPosition().x)); int y = Mathf.FloorToInt(Mathf.Abs(thisPos.y - _dest.GetPosition().y)); return(x * 10 + y * 10); }
void PlayerMove(GameObject g) { Ground ground = g.GetComponent <Ground> (); Vector2 groundPos = ground.position; Player playerComp = GameObject.FindWithTag("Player").GetComponent <Player>(); Vector2 playerPos = playerComp.currentCoordinates; //Debug.Log ("playerPos : " + playerPos.x + "," + playerPos.y); //探索開始 bool result = pathSearcher.StartSearch(playerPos, groundPos); if (result == true) { moveList.Clear(); //Debug.Log ("===== PathSearcher Result ====="); GroundNode currentNode = pathSearcher.startNode; moveList.Add(currentNode); //Debug.Log ("(" + currentNode.xIndex + "," + currentNode.yIndex + ") next(" + currentNode.nextNode + ")"); while (currentNode.nextNode is GroundNode) { currentNode = currentNode.nextNode; moveList.Add(currentNode); //Debug.Log ("(" + currentNode.xIndex + "," + currentNode.yIndex + ") next(" + currentNode.nextNode + ")"); } //GameObject.FindWithTag ("Player").GetComponent<Animator>().SetFloat ("velocity", 3.0f); ExecMoveQueue(); //Debug.Log ("===== /PathSearcher Result ====="); } else { Debug.Log("can't reach there"); } }
// Use this for initialization void Start() { gScore = 0; dist = 0; thisPos = transform.position; parentNode = null; myIndex = gameObject.GetComponent <GroundUnit>().getIndex(); }
private void PresentTextNode() { TextNode = SplittedStylizedText("I❤︎SceneKit"); TextNode.Scale = new SCNVector3(0.017f, 0.0187f, 0.017f); TextNode.Opacity = 0.0f; TextNode.Position = new SCNVector3(-14, 0, 0); GroundNode.AddChildNode(TextNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Per-Frame Updates"); TextManager.SetSubtitle("Game Loop"); var gameLoop = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/gameLoop", "png"), 17, false); gameLoop.Position = new SCNVector3(0, 6, 10); GroundNode.AddChildNode(gameLoop); }
private void UnhighlightContact(int index) { var contactNode = GroundNode.FindChildNode("contact" + index, true); //TODO contactNode.Filters = null; // Restore the original position and scale contactNode.Scale = new SCNVector3(1, 1, 1); contactNode.Position = new SCNVector3(contactNode.Position.X, contactNode.Position.Y, contactNode.Position.Z - 50); }
private SceneNodeBase GetTree() { var node = ParticleNode.Create(); var ground = GroundNode.Create(); var group = new GroupNode(ground, node); this.particleNode = node; return(group); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Related Sessions"); // load the "related.png" image and show it mapped on a plane var relatedImage = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/related", "png"), 35, false); relatedImage.Position = new SCNVector3(0, 10, 0); relatedImage.CastsShadow = false; GroundNode.AddChildNode(relatedImage); }
private void CreatePath(GroundNode _start, GroundNode _dest, List <GroundNode> _path) //목적지로부터 부모를 추적하며 경로생성 { GroundNode _parent = _dest.GetParent(); _path.Add(_dest); while (_parent != _start) { _path.Add(_parent); _parent = _parent.GetParent(); } }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Shadows"); TextManager.AddBulletAtLevel("Static", 0); TextManager.AddBulletAtLevel("Dynamic", 0); TextManager.AddBulletAtLevel("Projected", 0); var sceneryHolder = SCNNode.Create(); sceneryHolder.Name = "scenery"; sceneryHolder.Position = new SCNVector3(5, -19, 12); GroundNode.AddChildNode(sceneryHolder); //add scenery var scenery = Utils.SCAddChildNode(sceneryHolder, "scenery", "Scenes.scnassets/banana/level", 130); scenery.Position = new SCNVector3(-291.374969f, 1.065581f, -30.519293f); scenery.Scale = new SCNVector3(0.044634f, 0.044634f, 0.044634f); scenery.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 2); PalmTree = Utils.SCAddChildNode(GroundNode, "PalmTree", "Scenes.scnassets/palmTree/palm_tree", 15); PalmTree.Position = new SCNVector3(3, -1, 7); PalmTree.Rotation = new SCNVector4(1, 0, 0, -NMath.PI / 2); foreach (var child in PalmTree.ChildNodes) { child.CastsShadow = false; } //add a static shadow var shadowPlane = SCNNode.FromGeometry(SCNPlane.Create(15, 15)); shadowPlane.EulerAngles = new SCNVector3(-NMath.PI / 2, (float)(Math.PI / 4) * 0.5f, 0); shadowPlane.Position = new SCNVector3(0.5f, 0.1f, 2); shadowPlane.Geometry.FirstMaterial.Diffuse.Contents = new NSImage(NSBundle.MainBundle.PathForResource("Images/staticShadow", "tiff")); GroundNode.AddChildNode(shadowPlane); StaticShadowNode = shadowPlane; StaticShadowNode.Opacity = 0; var character = Utils.SCAddChildNode(GroundNode, "explorer", "Scenes.scnassets/explorer/explorer_skinned", 9); var animScene = SCNScene.FromFile("Scenes.scnassets/explorer/idle"); var animatedNode = animScene.RootNode.FindChildNode("Bip001_Pelvis", true); character.AddAnimation(animatedNode.GetAnimation(animatedNode.GetAnimationKeys() [0]), new NSString("idle")); character.EulerAngles = new SCNVector3(0, NMath.PI / 2, NMath.PI / 2); character.Position = new SCNVector3(20, 0, 7); Character = character; }
// Start is called before the first frame update void Start() { if (groundReference == null) { Debug.LogError("Ground reference NOT SET!"); } grid = groundReference.GetComponent <GroundGrid>(); GroundNode nodeStart = grid.GetStartingNode(); currentPlayerPosition = nodeStart.gridPosition; transform.position = new Vector3(nodeStart.worldPosition.x, 10, nodeStart.worldPosition.z); }
public override void SetupSlide(PresentationViewController presentationViewController) { // Set the slide's title and subtitle and add some text TextManager.SetTitle("Scene Graph"); TextManager.SetSubtitle("Scene"); TextManager.AddBulletAtLevel("SCNScene", 0); TextManager.AddBulletAtLevel("Starting point", 0); // Setup the diagram var diagramNode = SlideSceneGraph.SharedScenegraphDiagramNode(); GroundNode.AddChildNode(diagramNode); }
public override void SetupSlide(PresentationViewController presentationViewController) { TextManager.SetTitle("Loading a DAE"); TextManager.SetSubtitle("Sample code"); TextManager.AddCode("#// Load a DAE" + "\n" + "var scene = SCNScene.#FromFile# (\"yourPath\");#"); var image = Utils.SCPlaneNode(NSBundle.MainBundle.PathForResource("Images/daeAsResource", "png"), 9, false); image.Position = new SCNVector3(0, 3.2f, 7); GroundNode.AddChildNode(image); }
public void Reset() { startNode = null; goalNode = null; //reset all nodes foreach (GroundNode i in groundNodeList) { if (i != null) { i.Reset(); } } //set -1 into minimumCost }
private void PresentBalls(PresentationViewController presentationViewController) { var count = 150; for (int i = 0; i < count; ++i) { var worldPos = GroundNode.ConvertPositionToNode(new SCNVector3(RandFloat(-5, 5), RandFloat(25, 30), RandFloat(-5, 5)), null); var ball = CreatePoolBall(worldPos); ((SCNView)presentationViewController.View).Scene.RootNode.AddChildNode(ball); Balls.Add(ball); } }