Add texture to part of 3d object and then output whole object - object

I have .obj file of truck where I want to assign a texture to tyres.
I am doing this in blender:
select the vertices/faces of tyres
split it into different object (using P)
assign a texture file to the new object
combine the new object back to the main object using Ctrl+J
The problem is the texture file is not preserved and the whole model is assigned one of the texture files.
How can I assign the texture to just tyres?

Make a new separate material and select the vertices of the tire,
then click 'Assign' to assign that new material to the selected vertices.
See image here

Related

Check if polygon is completely filled by other polygons

I'm currently creating a map in Openlayers for a customer that requires validation for drawing polygons inside another polygon (base-area). By using JSTS and Openlayers native methods, i'm able to validate that all shapes are drawn inside the polygon, and do not intersect with other shapes inside the polygon. This includes markers and polygons.
Another requirement is to check if the base-area is completely filled by other polygons, with pre-defined margins. I've not been able to think of any way to do this yet. What would be a good way to accomplish this?
EDIT:
Methods i used to check if polygon contains other polygon:
const geoJSONFormat = new GeoJSON();
const jstsGeoJSONReader = new jsts.io.GeoJSONReader();`
polygon1 = jstsGeoJSONReader.read(geoJSONFormat.writeFeatureObject(feature1)).geometry;
polygon2 = jstsGeoJSONReader.read(geoJSONFormat.writeFeatureObject(feature2)).geometry;
polygon1ContainsPolygon2= polygon1.contains(polygon2); `
First i pass the given feature the geoJSONFormat.writeFeatureObject which is imported from OL. And then assign this to a variable using the JSTS GeoJSON-reader.
contains-method from JSTS will return a boolean indicating if polygon2 is contained inside polygon1
Since you've already validated the polygons are inside the base-area and that they aren't overlapping. To check the base-area is completely filled, just check the sum of the area of the polygons is equal to the base-area.
I'm not entirely sure what you mean by margin but you could check the sum of the area of the polygons is at least some x% of the area of the base-area to give some "wiggle" room.

fabric.js: Normalizing fabric.Polygon points after dragging/scaling/rotating

In fabric.js when a Polygon object is moved, scaled, or rotated via mouse cursor manipulation, the Polygon's original points array elements are not updated to reflect their new "true" current positions on the canvas.
This is problematic in my application, where we allow adding points to an existing polygon via clicks on the canvas, by taking the points array of the existing object, removing the existing object from the canvas, adding the new point to the points array, and creating a new polygon object with those points. This works fine if the polygon was not manipulated by the user.
Is there a way to, using the object:modified event, recreate the polygon updating its points to reflect their new true positions, taking into account the object's new position, scaling, and rotation?

Unity2D: Add text to rigidbody2D element

I'm new to Unity and I started with the Catch Game Tutorial to learn to create a 2D game. Everything is working now but for my needs, I would like to add different textboxes to each of the fallen elements (in the tutorial the bowling balls) Those texts should move with the objects. I know I can change text dynamically in the code, but I couldn't figure out how to correctly add the element.
I tried to add a text object as a child of the gameobject and also tried to create a new gameobject which contains a text, but I can't position the element in front of the background and above my wished element (I can't choose a sorting layer for this)
Imagine this is the object which has to be collected and I would like to show a text like this:
My Questions are:
1. How can I add a text to be displayed in the correct position (GUIText, text in a gameobject, only text or something else?
2. How can I make this text dynamically move with the fallen object?
3. Can I set a background to my text as displayed above?
Thank you in advance!
I found a solution for my problem and did the following thing:
I created a Sprite with my wished background (black rectangle) and added it to the scene
I created a 3D Text and added it as a child to the created Sprite (and scaled it and positioned it)
I added a Script to the 3d Text with the following content:
void Start () {
this.gameObject.GetComponent<Renderer>().sortingLayerName = "[MyLayerName]";
this.gameObject.GetComponent<Renderer>().sortingOrder = 3;
}
I added the Sprite (with the text as child) to my gameObject (ananas)
A renewed the object in the Prefabs folder
Maybe my solution helps other people facing a similar problem.

Coloring twice in OpenGl es

i m doing color picking for my project, i m working with iphone sdk and my project substantially(for color picking part) load 3d models with texture, the "loader" own an array of objects, those objects are presented with drawView and are updated with redrawView. When i click with mouse on the iphone simulator i just call the method drwanWithOneUniqueColor
that should color each object in the array with one different color.
The result with number of models 3 so with array model count = 3 is: on the view just 1 object with 1 color , in a different position where was the object( in front of the view ) and under 3 models with texture and the 2 and 3 model are not colored why?
THE OBJECT VIEW
and
THE LOADER AND REDER OBJECTS
http://pastebin.com/LHpmFAzn
i m working on and i m discovering that models was well colored but attached one on the other
in this way i could see just 1 of them.
now i should resolve the question of translate in the right way the objects.

QT- QImage and multi-threading problem

Greetings all,
Please refer to image at :
http://i48.tinypic.com/316qb78.jpg
We are developing an application to extract cell edges from MRC images from electron microscope.
MRC file format stores volumetric pixel data (http://en.wikipedia.org/wiki/Voxel) and we simply use 3D char array(char***) to load and store data (gray scale values) from a MRC file.
As shown in the image,there are 3 viewers to display XY,YZ and ZX planes respectively.
Scrollbars on the top of the viewers use to change the image slice along an axis.
Here is the steps we do when user changes the scrollbar position.
1) get the new scrollbar value.(this
is the selected slice)
2) for the relavant plane (YZ,XY or
ZX), generate (char* slice;) array for
the selected slice by reading 3D char
array (char***)
3) Create a new QImage*
(Format_RGB888) and set pixel values
by reading 'slice' (using
img->setPixel(x,y,c);)
4) This new QImage* is painted in the
paintEvent() method.
We are going to execute "edge-detection" process in a seperate thread since it is an intensive process.During this process we need to draw detected curve (set of pixels) on top of above QImage*.(as a layer).This means we need to call drawPoint() methods outside the QT thread.
Is it the best wayto use QImage for this case?
What is the best way to execute QT drawing methods from another thread?
thanks in advance,
From documentation of QImage:
Because QImage is a QPaintDevice subclass, QPainter can be used to draw directly onto images. When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread.
Just create a QPainter on your image and draw what you need.

Resources