sketchucation logo sketchucation
    • Login
    1. Home
    2. zitoun
    3. Posts
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Z
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 2
    • Posts 23
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Transformations

      Another thing: angle_between only gives absolute angles.
      If you need oriented angles, you might need something like

      def angBtw(v1, v2)
      	u1 = v1.normalize
      	u2 = v2.normalize
      	a = u1.angle_between u2
      	if ( u1.cross u2 ).dot( Z_AXIS ) > 0
      		return a
      	else
      		return -a
      	end
      end
      

      Note 1: normalization is used only because there seems to be some trouble with angle_between for small values...
      Note 2: I took Z_AXIS as my scene reference vector for now, but the good way to do would be to take the up vector of your object.

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @adamb said:

      And you will end up with many problems if you build your code around inverting the CTM and multiplying by a new transform.

      Not really: it's more like reseting the transformation and set the one you like. No inverse is needed, and this solution is actually the only solution I can see so far.

      But you're right, ignoring each object's current orientation is a real problem.

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      @zitoun said:

      @object.transform! @object.transformation.inverse

      This just resets the transformation - same as @object.transformation = Geom::Transformation.new

      @zitoun said:

      @object.transform! @transformationAt[toPage] * @object.transformation.inverse

      Isn't this just the same as: @object.transformation = @transformationAt[toPage] ?

      Yes, the inverse is not useful in my case.
      I use @object.transformation= @transformationAt[toPage], as you suggest, and it works (well I still have some awkward pbs but I expect to solve them soon).

      The code was just for my tests, I wanted to underline here that if you wish to do

      entity.transform! entity.transformation.inverse
      entity.transform! transfA
      entity.transform! transfB
      

      you could as well do

      entity.transform! transfB * transfA * entity.transformation.inverse
      

      or even better, as you say Thomthom

      entity.transformation = transf[b]B[/b] * transf[b]A[/b]
      
      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      Ahem.

      Just remember:

      @object.transform! @object.transformation.inverse
      @object.transform! @transformationAt[toPage]
      
      @object.transform! @transformationAt[toPage] * @object.transformation.inverse
      

      Note the order of the transformations... I had forgotten this well known pb !

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      If you always calculate from one fixed state then there is no need to undo the current transformation, you just set a new transformation overriding the old one.

      Yes indeed, but for some reason I thought that the method entity.transformation= was working differently (but I may have been really tired at the time I tested it).
      It completely make sense that it works the way you describe it.

      posted in Developers' Forum
      Z
      zitoun
    • RE: [Info] Allowable Classes for "set_attribute"

      VERY useful thread, thanks !
      Please make it kind of sticky: I've been chasing an uncatchable bug for hours, ignoring this information... Others might like to know this in the future!

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      This seems like it can be reduced to
      e.transformation = initialTransformation
      and that could possibly be reduced to:
      e.transformation = initialTransformation * transformationAtSuchFrame

      Really?
      I thought I had tested this solution and my results were not conclusive.
      But maybe I was too tired: I'm gonna try again !

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      OK, I surrender, I chose Cleverbeans method in the end, which revealed to be quite fine to do:
      I re-initialized my plane transformation, then I scale it with a factor of 1/2 several time, until I had the right size (1/32 in the end). I then chose a reference rotation to position the plane as I wanted to in the first place. I then have an "initialTransformation" that I will have to apply each time BEFORE the other regular transformation.

      So for each frame I'll have
      e.transform!( e.transformation.inverse ) e.transform!( initialTransformation ) e.transform!( transformationAtSuchFrame ) #with transformationAtSuchFrame combining a rotation and a translation

      Now I am not depending anymore of a random initial state.
      Of course I will rather combine all the intermediate matrices and then apply once the resulting transformation, it should be quicker.

      EDIT: I may have a quicker solution, that I still have to validate: Geom::Transformation.origin method gives the translation to put the object at the origin (and then be able to perform a simple rotation).
      I might use this rather than combine several 4x4 matrix, it has to be a lot quicker !

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      In the same way my example took the local 3d position and transformed it with the combined transformation for all the containing groups/components you must apply the combined transformation to your vector of orientation/direction.

      Sure thomthom, I get that. My pb is deeper... OK, I have to give the details! Here is what I understood so far:

      An object has a 4x4 transformation matrix M attached that combines three parameters defining the geometrical state of the object:

      • the position T in space
      • the orientation R
      • the scale S

      Let's say I want to rotate my object (entity is the correct term I think) without changing the position: I will have to

      • apply to M the inverse of the translation T (so far I use [0,0,0]-T)
        Sketchup.active_model.active_entities.transform_entities(ORIGIN-fromPos,e) #puts the objet at the origin
      • then apply the relative orientation dR I need
        Sketchup.active_model.active_entities.transform_entities(Geom::Transformation.rotation(ORIGIN,UP,angle),e)
      • and finally apply back the translation T.

      You may say I should simply use the M.inverse but I think the scale factor would be a probl****em... Or not? (testing around) 🤓 ... All right. Seems we can simply do :

      • apply M.inverse,
        Sketchup.active_model.active_entities.transform_entities(e.transformation.inverse,e)
      • apply dR
      • apply M back
        Should be OK.

      And here comes my tiny problem: current orientation R of the object is somehow melted with the other parameters T and S in global my transformation matrix M... How the hell do I get a proper orientation R?
      Cause I already know the final absolute orientation R' I want my object (or entity, or, in my case, a good old german biplane) to reach: all I need is this initial orientation R to compute the difference dR.

      I thought to just get rid of the transformation, discard it and return to the identity and thus apply directly the wanted orientation R', then the position T. But it would be too easy: to fit in a small room, my plane had to be scaled, and I then need to know this scale factor S (that I otherwise simply ignore).

      This special line is to thank the reader for the effort he put to read my reply.
      And this one is for the people that would give me some clues: I owe you!

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      The transformation class has an axes method that I think could be used to get your bearings.

      As I see it, Transformation::axes method only enables to SET the axes, unfortunately not to GET them...
      😞

      EDIT: but maybe I should just SET the initial transformation, just like that... OK, let's try this.
      But I still think it should be a standard feature to get the absolute or relative rotation matrix/quaternion for any component of the scene...

      RE-EDIT: I hadn't seen Transformation::Xaxis, Yaxis and Zaxis method!
      I have no clue what these are yet, but I guess I somehow can retrieve my rotation matrix from such component...

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      However, Cleverbeans, an idea would be to integrate my plane as an external component and tailor the parameters so that it fits in my scene... That can be an idea, but I'll look into that once I'm desesperate !
      😉

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @cleverbeans said:

      If your plane is a component, then I believe it's orientation if constant based on how the component axes were defined originally. If your plane is not entering the model with consistent orientation, that suggest your placement transformation is rotating it rather than doing a strict translation. Once you've discerned your original orientation, it should be a simple matter of adding a rotation to orient the nose to the directional tangent to the spline then having your "up" vector rotate around the tangent until its parallel to the z-axis.

      Thanks Cleverbeans! Yes indeed you're right, if I have the initial orientation of my plane I should be able to retrieve the orientation at any time... And I may do this in the end but I'm not too fond of this.
      First because I don't really know the place of my plane at the first frame (cause I placed the plane and scaled it in the room to fit my purpose).
      And secondly, (I could but) I will not place my plane at the origin with the right orientation and put my scene around just because there is no simple way to find the actual orientation of a selected component! I feel like it's really a basic feature to be able to know the precise location and orientation (and, to be exhaustive, scale) of my component at any time. Plus I will further add other planes and may have to do more complicated things in the future.

      So I am really looking for a mean to find the exact orientation of a component at any time.

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      I don't really see how, TT...

      In the meantime, to illustrate what I say:

      http://farm2.static.flickr.com/1240/5123150633_55af66f6ce_o.png

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      @thomthom said:

      rrright... I'm not able to digest that comment just yet. (waiting for my dinner) ... But , about your airplane...

      Oh ! sorry 😄

      @thomthom said:

      You're making an airplane fly around following a path? Are you transforming the edges and faces themself to make it fly? or are you transforming a group/component containing the plane?
      How do you control the plane? control path?
      (Just trying to get the general scheme of what you are doing before getting into the nitty gritty coding details.)

      All right, I will explain.
      I don't use any transformation on edges and faces because it is really too low level for my animation, I just take the plane as a solid object and have it fly like this, without internal animation.

      My purpose is to have a plane flying in a close room and the camera followin it so that it is always in the field of view, from behind, in a tenth of the image maybe. I want to have a video of 25s out of it.

      What I did first was to create a close loop as a Bézier spline using Fredo6's impressive tool.

      Secondly I used Pixero's BZ_animator to get the camera follow the flypath and the scenes created accordingly.
      You may say that it is not very convenient to have something like 600 scenes (aka frames) but as SketchUp first move the camera, THEN your object, I had to use it like this. I simply set the transition time 1/25s.

      Thirdly, I had to move my plane along the camera path, and I didn't find anything to do it properly so I just grab an older version of Morisdov's Proper Animation to understand the mechanism he was using. So far, I can move the plane along the spline/flypath, so it's working rather fine.
      All I have to do to have something correct is to deal with the orientations: so far only the position of the plane changes.

      I haven't thought of my script as something that could be re-usable by other users so far, so my developments are completly focused on my goal. But once I have something decent I'll post it somewhere so that others can see what I did and may propose enhancements or other ways to do this.

      posted in Developers' Forum
      Z
      zitoun
    • RE: Transformations

      All right, this is a dusty old post I'm digging up here...
      My problem seems very common but I curiously found nothing to solve it so far. Doesn't mean the answer isn't located somewhere though, but I haven't found it.

      I am still trying to have a plane flying and it is going in a good direction thanks to Pixero, Fred and Morsidov's work on the subject.

      I needed the absolute 3D position of my object, and I found how to do it (thx thomthom).
      HOWEVER
      I am still struggling in retrieving the absolute 3D orientation of my object.
      I would have expect such info to be completely basic in a 3D editor, yet it doesn't seem that easy to find.

      Any help welcome !
      😄

      posted in Developers' Forum
      Z
      zitoun
    • RE: Notepad++

      @newone said:

      For this you will need last version of Notepad++ or if you use a older version, download NppExec plugin from http://notepad-plus.sourceforge.net/uk/site.htm (last version have this integrated).
      Then you will need TBD's SketchUp Bridge from here http://labs.plugins.ro/.

      Hey there!
      Please let me unbury this thread to say first that I really appreciate it and like to thank every people that participate (especially the author of the post above). It is very important to have the right tools when you code, and find such info quickly to avoid to loose to much time 😄
      So : thx !!

      And: TDB, is there a way to get your plugin transmitting compilation info (such as error line number) to NPP? Does anybody know?

      posted in Freeware
      Z
      zitoun
    • RE: Proper Animation query

      I cannot find the way to set Morisdov's ProperAnimation parameters from an external script !
      I think there was at least one parameter that was mentionned in the forum but I can't seem to locate it again...
      Any help ?

      EDIT: ahem, I HAD to ask to find it ^^

      Morisdov.transf_get("transf")

      PS: this thread is so close to this one that it would seem natural to move it there...

      posted in Plugins
      Z
      zitoun
    • RE: Ajout d'objet au graphe de scène

      Bah au moins merci de ton petit mot Sergio, je me sens moins seul à défaut d'être moins perdu 😉

      posted in Français
      Z
      zitoun
    • Ajout d'objet au graphe de scène

      Bonjour à tous les francophones!

      Je me permets de poster ici la traduction de ce post, si cela m'est permis: j'aimerais profiter des réponses de la communauté française...

      Le contexte:
      J'appelle "graphe de scène" (scenegraph) la hiérarchie des objets de la scène, y compris les caméras.
      Je cherche à faire voler un avion miniature dans une chambre fermée, et j'ai déjà réalisé une jolie trajectoire pour ma caméra avec l'aide des plugins de Pixero et Fred.
      J'aimerais maintenant faire en sorte que l'avion soit toujours dans le champ de la caméra, avec une position fixe par rapport à la caméra dans un premier temps.

      Les solutions théoriques:
      La façon la plus simple consisterait à attacher l'objet avion à la caméra, et indiquer un offset relatif fixe, comme c'est possible dans n'importe quel outil d'animation ou en VRML.
      Mais bon, j'ai l'impression que ce n'est pas si simple dans SketchUp.

      Une autre façon consisterait à récupérer pour chaque frame la position et l'orientation de la caméra, d'y ajouter offline le position et l'orientation relative de mon coucou, et de réinjecter la position et l'orientation absolue pour mon avion à chaque frame. Par exemple en utilisant le magnifique plugin ProperAnimation de Morsidov.

      Ma requête:
      Pour réaliser mon objectif, il me manque deux infos:

      • comment récupérer la position et l'orientation de la caméra (au moyen d'un script, hein: n'oublions pas que j'ai plus de 300 frames dans ma petite annimation de base) ?
      • comment réinjecter les valeurs calculées dans ProperAnimation ?

      Toute aide est la bienvenue, je vais tâcher de tenir à jour l'évolution de ce sujet à la fois en anglais et en français (je pense que ce genre de sujet est fait pour intéresser un grand nombre d'utilisateurs).
      Etant donné que je suis loin d'être un expert, en particulier en ce qui concerne l'usage des scripts et le panel d'outils disponibles, n'hésitez pas à m'indiquer les liens susceptibles d'apporter de l'eau à mon moulin, ou même de vous faire didactiques !
      Merci d'avance.

      posted in Français
      Z
      zitoun
    • RE: [Plugin] Proper Animation V1.08 Beta(Updated 14/11/10)

      Using Pixero and Fredo's work, I was able to create a sequence where my camera flies all around a room. Now I'd like the plane to be in the camera's field, first as a fixed item, and later moving (while staying in the viewfield).
      (Note: I talk about this aspect in a dedicated post)

      Most efficient way to do so is to attach the plane to the camera, as you can do in most animation tools. But I understood this would not be easily feasable.

      Another way is to get for each frame (from a script maybe) the camera position and orientation, add offline my plane wanted relative position and orientation, and then update my plane's coordinates for each frame, maybe using ProperAnimation plugin...

      But as I've just discovered SU, I still don't really know how to get these position + orientation infos... Plus I don't know if it is possible to set offline Proper Animation coordinates for an object !

      Is it ? How do I do this ?

      posted in Plugins
      Z
      zitoun
    • 1
    • 2
    • 1 / 2