Group moves to origin when I doubleclick to select component
-
Like an optional argument in Vertex.position perhaps - that takes a transformation argument?
-
Also, do anyone have a test script where current solution is slow?
-
@tt_su said:
Like an optional argument in Vertex.position perhaps - that takes a transformation argument?
Brainstormin'Umm. I was thinking more of a
.world_position()
instance method forGroup
andComponentInstance
classes.
But this may not be the most helpful.Maybe think more of working in "Local" and "World" modes.
And we gave a block formworld
and (maybe)local
methods.
(Sort of the old "with this do that" construct.)component_instance.world {|inst| # any vertice, point3d, vector3d, etc., # accessed within block is in world co-ordinates }
?
-
@dan rathbun said:
@tt_su said:
Like an optional argument in Vertex.position perhaps - that takes a transformation argument?
Brainstormin'Umm. I was thinking more of a
.world_position()
instance method forGroup
andComponentInstance
classes.
But this may not be the most helpful.Maybe think more of working in "Local" and "World" modes.
And we gave a block formworld
and (maybe)local
methods.
(Sort of the old "with this do that" construct.)component_instance.world {|inst| > # any vertice, point3d, vector3d, etc., > # accessed within block is in world co-ordinates > }
?
Seems to me that to avoid complete chaos for Components, it would need to be necessary either to make any "world" version of the Component read-only or else to intercept all of the setter methods on Entities and apply the reverse transformation back to the ComponentDefinition's "local" coordinates. Otherwise, any modifications made to the "world" version within the code block would create a mess in the ComponentDefinition! This seems like a terrible amount of complexity and risk of bugs!
Here's a different idea: what if there was a "export_to_world" method on ComponentInstance that would create a new Group containing copies of the ComponentDefinition's Entities transformed into "world" coordinates per that ComponentInstance's Transformation(s)? Because the copy's Entities would no longer be shared with the ComponentDefinition, there would be no risk of messing it up. Alterations made to the Group would not affect the ComponentDefinition or any of its ComponentInstances.
Steve
-
Steve, my original idea is morphing into something overly complicated.
I never wanted to imply a "world edition" of any
Group
orComponentInstance
instance object.I really meant that the
origin
(which is actually a property of a transformation object,) be returned in world co-ordinates instead of local co-ordinates. (So the instance object is not changed.)But this only within some scope mechanism. (A method block is only one such example.)
Copying an instance into the world model entities, is easy enough now.
I did not intend something that modified the model directly. I was aimed at simplifying virtual calculations.
-
@dan rathbun said:
@tt_su said:
Like an optional argument in Vertex.position perhaps - that takes a transformation argument?
Umm. I was thinking more of a
.world_position()
instance method forGroup
andComponentInstance
classes.Oh.. sorry (brain fart)
Yes the
position()
method is on theVertex
class, so the proposedworld_position()
, would also have to be upon this class.
I do not known what would be better, a new method, or adding an optional:world
symbol (or"world"
string,) argument. (I DO know I hate positional boolean args, so I'd rather not see a defaultfalse
arg, that we need to passtrue
in order to get world co-ordinates.)Above, where I ponder about a scope (or method block,) ... creating any of the "virtual" dimension classes (in module
Geom
,) would return new object using world co-ordinates,. instead of local co-ordinates.So in such a block
edge.start.postion
(for an edge that was nested at some level,) would return a newGeom::Point3d
instance, but it's x, y, z would be set to world co-ordinates. -
@dan rathbun said:
Steve, my original idea is morphing into something overly complicated.
I never wanted to imply a "world edition" of any
Group
orComponentInstance
instance object.I really meant that the
origin
(which is actually a property of a transformation object,) be returned in world co-ordinates instead of local co-ordinates. (So the instance object is not changed.)But this only within some scope mechanism. (A method block is only one such example.)
Copying an instance into the world model entities, is easy enough now.
I did not intend something that modified the model directly. I was aimed at simplifying virtual calculations.
So I guess I miss the point of the code block you suggested...what would it be iterating over?
-
There is NO rule that states that code blocks must be iterative!
For example, normal
begin
...end
ordo
...end
code blocks are not themselves iterative. Nor aredef
...end
code blocks iterative.A block of code is a scope mechanism. It can be iterated by calling it multiple times from an iterative expression such as
for
. Or a method block, can contain afor
expression that calls a passed code block using ayield
expression.What I am proposing is most like the new Ruby 2.0
using
keyword, and the refinement construct. In fact I said that above, where I called it a "with this do that" concept. -
@dan rathbun said:
Yes the
position()
method is on theVertex
class, so the proposedworld_position()
, would also have to be upon this class.But you cannot return a single world position for a vertex unless you have some extra info. If the vertex belong to a definition with multiple instances there are multiple possible world positions.
And there was some mention of performance concern - did anyone have a sample script of this?
-
@tt_su said:
But you cannot return a single world position for a vertex unless you have some extra info.
RIGHT.. I gotcha'
We would need to let Ruby know the parent instance's transform. (Not automatic unless in user edit mode.)
I guess we can do this now. We just create a copy of the instance's transformation, call it
**t**
:
world_pt = edge.start.position.transform(t)
I guess I was pondering how to automatically call#transform(t)
upon all newly createdGeom::Point3d
instances, within a code block scope.So, yes I suppose an optional "tranform" class argument for
Vertex#position
would be handy. (It could be aGeom::Transformation
instance, aGeom::Vector3d
in world context, OR either anArray
orGeom::Point3d
offset fromORIGIN
.) So it could look like:
world_pt = edge.start.position(t)
(2) So lets say you have collected a series of vertices (in an array
verts
.) And you want their world co-ordinates:
world_pts = verts.map {|v| v.postion(t) }
We have to use map, because the API's
Array#tranform()
andArray#tranform!()
methods, refuse to apply a transform to an array with anything other than than 3 numerics.
Even though each individual element has a transform method.Example, you have an array of
Geom::Point3d
objects, and you want to transform ALL elements the same.
The Array class transform methods should do this IF the the elements are not numeric, and theyrespond_to?(:transform)
. (Add: Any element that does not "respond_to" is returned unchanged.))
Advertisement