How can you create a multi faceted object like say in a shape of the mountain? Without resorting to something like THREE.PlaneGeometry? Can you use THREE.Geometry instead?
Three.PlaneGeoemtry is only a preset for the user that already generates the vertex positions and UV-coordinates for you. For creating a mountain, you should stick to Three.PlaneGeometry and move the vertices up and down, depending on some height values of any kind you wish (function, or height map texture or whatever). You could also create your own Three.Geometry object but in the end, I think, you will end up with something very close to PlaneGeometry.
Related
I'm trying to access Animation's but so far the only method I could think of was:
tool
...
set_meta("animation_path",["NodePath/to/AnimationPlayer","Animation Name"])
var ani_data=get_meta("animation_path")
var animation=get_node(ani_data[0]).get_animation(ani_data[1])
but the problem is that if I change the Animation Name I'll have to reset the value, so is there no way to store a unique id for Animation resource?
I tried storing get_instance_id() & using instance_from_id() but that doesn't work when I restart the game engine
If the Animation is saved
Given that Animation is a Resource, I believe you can use the resource_path (given the Animation is saved).
The resource_path represents where the Resource is saved, and thus it persists when you restart the game engine.
Also, it would be unique for each Resource (it is possible to have multiple Resources saved in the same file, but then the resource_path of each Resource points to a sub-resource of the file).
And yes, the resource_path does not change when you rename the Animation.
The other idea that comes to mind is that the Animation itself has metadata which you could use.
If you will not be using the animation name, you would have to iterate over the Animations of the AnimationPlayer to find the one you want.
I suppose that if you use the resource_path, you could load it and get the animation name form there. You could also be getting the same instance… That happens if you are getting it from cache.
If the Animation is not saved.
First of all, storing metadata on the Animation should still work. Except, of course, it still means to iterate over the Animations to find the correct one.
If the goal is to not do that, then you can hold a Dictionary with String for keys and Animations as values, and keep it somewhere you know there is only one instance. For example:
Store it in an EditorPlugin.
Store it in an Autoload.
Store it in a specific Resource which you preload.
Store it on a const. Godot will admit Dictionary and Array as consts. Making them consts means you cannot set them… But they are still mutable. Furthermore, consts are shared among instances.
In 3d Model of Autodesk Forge, We want to change the colour of the model with passing the DBId without selection. How can we do it? please help on this.. we are unable to find any reference on this.
If you already have a dbID of an object you'd like to color, you can use the viewer's setThemingColor method.
If you're asking about how to get dbIDs of objects without selecting them, there are different ways. For example, you can iterate through the scene hierarchy (as explained in this blog post), or obtain dbIDs of objects with specific properties (using the getProperties method).
I am practicing with Neo4j. I am trying to model colors and their relationships but I don't know what to do with different names of colors.
For example, it looks like (from what I read on the internet), aqua, cyan, teal are more or less the same color.
I want to model colors such as I can classify each color in it's category (primary, secondary, tertiary), in its family (warm, cool, neutral).
I also want to represent shades, tints and tones of different colors.
How do I model that x is a tint of y and y is a primary color for example? It is becoming difficult.
I want each color to be a SEPARATE NODE.
thank you for your time.
Honestly this really depends on how you want to query your data. You could represent color as simply as a hex code or a serialized JSON string of the properties that you describe above and then you would just need a property. But if colors are a fundamental part of your model then you could get really detailed and split things out into individual nodes and relationships. I'll assume that here.
So you could have, for example, Color, Level, Family, Shade, etc... labels. For the labels after Color you could just create all of them upfront, or you could use MERGE to create them only when necessary.
Then you could simply create color nodes and relationships like:
CREATE (color:Color {hex: '#FFFFFF', name: 'White'})
and then:
MATCH (white:Color {hex: '#FFFFFF'}), (primary:Level {name: 'Primary'})
CREATE (white)-[:IS_LEVEL]->(primary)
Again, this would be if you want to query by finding common paths between colors. If you just want to be able to tell if #FFFFFF is a primary color you could have a level property with the vaule Primary.
Side note: I suggest reading Randall Munroe's color survey results blog post because it is awesome.
EDIT:
Based in your comment, if you want to have different names for a color you could either have an array property for the name (or perhaps a name property which is a string and an alternative_names property which is an array), or you could have a ColorName node with a name property and then a (:Color)-[:HAS_NAME]->(:ColorName) relationship.
One consideration if your database were to grow very large is that Neo4j doesn't yet support indexing on array properties (I think you could do it with legacy indexes, though). So something like this would work:
MATCH (color:Color) WHERE 'Red' IN color.names RETURN *
But it will need to look through ever Color node. If you had a ColorName label then you could make an index for ColorName(name). But it does come with the tradeoff that the more you extract properties into separate nodes, your queries start becoming more difficult to maintain because you need to include those extra nodes every time you want to display information about a color. You start to get into queries like;
MATCH (color:Color)
WHERE color.hex = '#FFFFFF'
OPTIONAL MATCH (color)-[:HAS_LEVEL]->(level:ColorLevel)
WITH color, level
OPTIONAL MATCH (color)-[:HAS_NAME]->(color_name:ColorName)
WITH color, level, collect(color_name.name) AS names
// etc....
RETURN color, level, names, etc...
is it possible to modify/grasp the selected object pivot point (transform, rotate and scale) in which the pivots are pointing towards the camera that user selected/ via a list of cameras in the scene?
I wanted to try out it manually before I try converting into coding but the following method that I tried, was unsuccessful:
create a locator
constrain the locator to aim in the way of the camera that I wanted it to point to
parent the geo to the locator
Freeze Transform on the geo and unparent it from the locator
While the method kinda work, in which is is pointing towards the camera, but the geo was rotated. I tried copying rotational values into the rotate axis, either the geo got rotates, or zero-ing out the rotational values, it is back to square one.
Any ideas?
This is how i'd do it with python, if you want it coded.
This'll move your object's pivot without moving the object itself:
import maya.cmds as mc
mc.xform ('objectPivotYouWantToMove', piv=((mc.xform ('objectWhereYouWantPivotToBe', q=1, ws=1, piv=1))[0], (mc.xform ('objectWhereYouWantPivotToBe', q=1, ws=1, piv=1))[1], (mc.xform ('objectWhereYouWantPivotToBe', q=1, ws=1, piv=1))[2]))
What this does is moves the pivot of one object and puts it in the position of another's without moving the geo/shape.
If you want to move it without script select your object and then press the insert key. you can now move the pivot free of the object, if you hold down 'v' you can snap it to another.
Hope this helps!
This relates mostly with what a "best practice" would be with D3.js. I want to attach arbitrary information to different svg elements that I have on a page, after they are created. In D3, it looks like one generally generates svg elements from a dataset. I want to attach data to these svg elements at any time, without adding their HTML attributes.
Is there a good way of doing this? Do I need to use an auxillary array/object or is there a way to apply data to the elements themselves?
You would use the datum method if you want to attach arbitrary data:
D3.select('#mynodeId').datum( mydata );
And then later you could access the value again:
var mydata = D3.select('#mynodeId').datum();
Internally, D3 is going to use the __data__ property of the node, just like it does when the nodes were created from a data set via the selectAll, enter, append sequence.
Note that if you already have a reference to a DOM node you can pass it as the parameter to D3.select rather than making it re-look-up based on selector syntax:
D3.select( anExistingDOMNodeReference ).datum( mydata );
From the API doc:
d3.select(node): Selects the specified node. This is useful if you already have a reference to a node, such as d3.select(this) within an event listener, or a global such as document.body.