is there a way to draw a shape or contour, overlaid on a map kit view, making sure it's bound to it so when the map kit view moves or re-scales it adjusts accordingly?
Have look at the "Location Awareness Programming Guide" at http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/Introduction/Introduction.html and specifically at the MKOverlay protocol and MKOverlayView classes.
These should be exactly what you are looking for.
Related
I created a SCNPlane in my scene. I set the diffuse content of the SCNPlane to an image. Now I need to display other details on the plane (e.g. the name of the plane, and other simple drawings like an arrow).
This seems like a simple task but I could not find any relevant information. Should I create other geometries and attach them to the plane? If so, how do I do that without z-fighting occurring?
Materials in SceneKit are very flexible. When you are assigning something to the diffuse or ambient property you are assigning a SCNMaterialProperty. From Apples docs you can assign:
An image object, or a path or URL to an image file
A specially formatted image or array of six images to be used as a cube map
A Core Animation layer or layer hierarchy, which itself may contain animated content
A SpriteKit texture providing a static image, or an entire SpriteKit scene rendering animated 2D content.
I haven't got the Core Animations layers to work properly, maybe someone else can give more information on it, but I have been using SpriteKit and it is really easy to set up.
Create a SKScene and add animate it as much as you want
Set the size of your scene. SceneKit will scale this up if your plane is bigger than your size.
Add it to your materials diffuse property
From Apples class reference for SKShapeNode's but also from many developers i hear that using SKShapeNode for drawing custom shapes you want to draw often on the view is a bad idea because it performs bad.
Its true, a simple app with some custom shapes is spiking my CPU up to 80% and using like 80MB RAM (on devices its a bit better).
So then, how do i draw shapes like arrows without using SKShapeNode, because i like the idea to draw with bezierpaths since i do not need to care about display size.
How to draw an arrow with a texture without getting a bad quality, since it would stretch my image when i move my touch stretching the arrow. Doing this with SKShapeNode works perfect but performs bad.
You can always have one SKShapeNode node available that you use for creating shapes, and use the path property to design the shape. Then create a texture out of the SKShapeNode from the scenes view with let texture = scene.view.textureFromNode(shapeNode) and place the new texture into an SKSpriteNode
Hello i can't for the life of me work out how to add a 2D image in the scene using scenekit is it even possible? What I'm trying to accomplish is have a 3D flying plane over a 2D background image but the background image can't cover the whole screen. Thanks to anyone that can help
Others have said plenty good suggestions above.
Let me summarize each solution with different scenarios:
Using scnScene.background: Easiest, but fullscreen and static. You cannot display in a smaller area of the scene, nor can you customize the transformations.
Using scnScene.overlaySKScene to display a 2D SKScene and adding image sprite. This is probably what fits your scenario. If you want static but with configurable transformations, this is a good choice. Notably overlaySKScene is recommended by Apple to create HUD in your 3D scene.
However, if you want the 2D content to track the 3D movement, you need to do some coordinate conversion from 3D space to 2D space every frame. Bad news is the job is done by CPU, which will add performance drag. (Believe me, this frustrate me too!)
Using SCNNode with SCNPlane geometry and set the diffuse.content with the image; add SCNBillBoardConstraint to the node to ensure it's always facing the camera.
Most flexible. However if your camera is not orthographic, the picture is going to zoom as the fov of camera changes, which doesn't look 2D but rather a hanging 3D billboard.
SceneKit and SpriteKit play very nicely together.
Implement the background 2D image as a SceneKit node with SCNPlane geometry, using your image as the plane's material. If you want to get fancier, use a full, live SpriteKit scene as the SCNPlane's material. Place that node at the far end of your camera's frustum, with your 3D aircraft in front of it.
You might also consider providing a cube map (skybox) as your scene's background. See SCNScene.background.
You can use the background property on SCNScene to set a background image.
scnScene.background.contents = UIImage(named: "myImage")
Contents
You can set a value for this property using any of the following
types:
A color (NSColor/UIColor or CGColorRef), specifying a constant color
across the material’s surface
An image (NSImage/UIImage or CGImageRef), specifying a texture to be
mapped across the material’s surface
An NSString or NSURL object specifying the location of an image file
An array of six images (NSArray), specifying the faces of a cube map
A Core Animation layer (CALayer)
A texture (SKTexture, MDLTexture, MTLTexture, or GLKTextureInfo)
A Sprite Kit scene (SKScene)
I have a custom annotation to represent a moving bus, and id love to have that "pulse" has. I believe its also referred to as the accuracy circle. Is there a way to use that with an image overlay ontop of it?
I am new to XNA and I am having problems with collision detection when I rotate my sword. I am using a rectangle bounding box approach and I don't know how I can rotate my rectangle together with the sword sprite.
http://picpaste.com/pics/f10268c108e885498a4ae603ab030a60.1328941784.png
The orange line represents the sword and the blue rectangle represents the bounding box, I want to also rotate my bounding box to the position where the arrow goes.
Any suggestions on how can i solve my problem is really appreciated. Thanks!
I have a sample showing how to detect rotated rectangle collision, you'll need a similar approach for detecting rotated bounding box collisions.
My sample uses the Separating Axis Theorem which is a very common approach. You can read my sample here on Rotated Rectangle Collision
There's also a ton of fantastic resources out there on helping to try and get a handle on the concept of rotated rectangle collision detection. Here's a few I used in constructing my sample.
http://www.metanetsoftware.com/technique/tutorialA.html
http://www.codeproject.com/KB/GDI-plus/PolygonCollision.aspx?print=true
Now that you know the term to search for, you should be able to find even more that meet your learning style.