How to detect what part of the 3D object has been selected(touched by the user) using Xcode ARKit(Scenekit)? - scenekit

I have developed a POC using ARKit - SceneKit using https://developer.apple.com/sample-code/wwdc/2017/PlacingObjects.zip. I have implemented a feature using which user can change colours of the 3D object after placing it in floor using camera. I want to allow user to select the part of the model(with highlighting the part) as they touch the respective part using camera, detect what part has been selected and show the colour options to the user.
Right now i am allowing to change the colour of 0th object alone(0th object of selected Xcode .scn file) instead of user selecting particular parts like below,
self.virtualObjectManager.lastUsedObject?.childNodes[0].childNodes[0].geometry?.firstMaterial?.multiply.contents
= UIColor(red: 233/255, green: 136/255, blue: 215/255, alpha: 1)
How to implement this? Is there any way i can detect what part of the model user has touched(For example. If a cot with bed is displayed, i want to recognise if user touched cot or bed before showing colour options)

Related

How do I Color by Layer?

I have a react app that is using the forge viewer. It's running and showing the drawing (dwg file). My end goal for this task is to get specific layers to change color. How I'm trying to do that is to find the attribute index for the layer property (similar to the query tutorial) then enum the objects, get their layer property, and if it's the one I want set the theming color as follows:
const color = new THREE.Vector4(25, 25, 25, 25);
viewer.setThemingColor(dbId, color);
I can see that I'm getting a list of objects, but it's telling me THREE is not defined and not doing anything. I've added three.js to my project with yarn add three-js. How do I get it to do this? Is there a better method than what I'm using?

Azure Maps - How to set drawing manager layers z-index to the top?

In my design page, the user will be creating/drawing new shapes, in addition to adding image overlays. I'm finding that any shapes drawn using the drawing manager are rendering underneath any image overlays added to the map, see below:
I'd like to know how to achieve a couple of tasks:
1 - How to set the drawing manager so any shape (rectangle/point/circle etc be default is always added as an upper/top layer when the drawingcomplete event has fired, that way the shapes will always appear above any images added to the map.
2 - How to programatically change the order of the various layers created during design, given the user may want to adjust the z-index of the various layers to suit their own endering requirements.
The MS docs here is not really helping me understand how to achieve the above, but also doesnt mention anything about shapes/layers that currently reside within the drawing manager.
Partial answer but along the right tracks...
We can retrieve the shapes (drawing manager layers) from the drawing manager so we have a reference to them.
When i add an image overlay, before actually adding/rendering it to the map, i would first get the shape layers from the drawing manager, then remove them from the map.
Next we add the image overlay to the map and add the shape layers back in as well, its the order that we add/remove the layers that seems to be relevant here.
Once i had added all layers back to the map in the chosen order, i was still able to put the drawing manager into edit mode and select the shape for editing, so i beleive this will work as my solution going forwards.
// Create the image layer
var imageLayer = new atlas.layer.ImageLayer({
url: 'myImageUrl,
coordinates: coordinates
})
// Then get the existing shapes (layers) from the DM
var layers = drawingManager.getLayers();
console.log(layers);
// Remove the shapes.
map.layers.remove(layers.polygonLayer); // polygonLayer as an example...
// Add new image overlay, then the shapes
map.layers.add([imageLayer, layers.polygonLayer]);

Changing color of an image - at runtime

Im going to make a new application for a car dealership. They basically want a WPF/silverlight application where one can slect a car (model) and then via a color palette choose the color of the car (from predefined colors). They also need to be able to different kind of rims, headlights and interior.
what is the best/easiest approach for this. Been thinking on having all the different images and then just swap them out when the selection changes. This, however has the potentional problem of all images with all combinations does not exist (eg. a red VW, metallic rims, white leather interior) etc.
Is there any other approach to this? replacing colors? Having a basic model and then copying the "body" of the car on top, copy rims on top etc. and then just having to enable/disable a particular "layer" of the images?
I would do this by using different layers: the basic model with the car's color as translucent part, on top of this pictures with the different add-ons, the background color is the car's color. The trick is to fit everything together that it looks good.
Depending on the color (maybe you want to have shadows or chrome effects), you could have one model's picture for each color, and then add the add-ons and the interior on top of this.

How to interpolate between colors for a polygon in Bing Maps

I have a WPF application with the Bing Maps API. What I have is a polygon rendering on many countries as well as real time statistics being display. I'm using this to keep track of where my server traffic is mainly coming from. The project is coming along nicely, but I hit a small roadblock. What I have are polygons that go from green to red and vice versa if there is a change in the statistics. If someone logs off then it would go into the green, if someone logged on it would go into the red. What I'd like to do is given a set number of users, let's say 20, I can gradually change the colors over a period of a second.
An example is 0 would be green and 20 would be red. So 10 would be yellow. With this, is there a way to gradually change colors?
Thanks in advance
There might be a fancy way of doing what you are looking for in xaml, but I imagine it would be a lot easier to to just have the color of the polygon bound to a property in your viewmodel/code-behind and then update the color whenever necessary.
For color interpolation, there is another SO question on it here.

Drawing maps in WPF

I want to draw a map in WPF without using any third party controls.
I need each and every state of all the countries, and based on certain conditions I want to color them.
How can I get the polygon shapes of each state of all the countries?
Here is an SVG file with all the states as separate polygons (look at the source!)
You can convert it to xaml if you want and fill the state differently.
EDIT
Just google for svg world map. One of the first hits seems to be a nice resource.

Resources