Starting a Group After Another
-
Hi sawdust. I don't think there is a joint that would do what you want. However, a lot of things is possible through coding. Here, I used a motor joint and recorded its angle to determine when to stop the motor. Here is the code:
onstart { setVar("autoStart", 1) setVar("spin", 0) @hand_wheel = simulation.findBody("HandWheel") @last_dir = @hand_wheel.group.transformation.xaxis @desired_revolutions = 10 @desired_angle = Math;;PI*2 * @desired_revolutions @angle = 0 Sketchup.active_model.entities.each { |e| if e.is_a?(Sketchup;;Text) @output = e break end } @orig_text = @output.text } onpostframe { if frame == 20 setVar("spin", 1) end if getVar("spin") != 0 tra = @hand_wheel.group.transformation dir = @last_dir.transform(tra.inverse) dir.z = 0 theta = Math.acos(dir.x / dir.length) theta = -theta if dir.y < 0 @angle += theta @last_dir = tra.xaxis if @angle.abs >= @desired_angle setVar("spin", 0) setVar("autoStart", 0) end end @output.text = @orig_text + sprintf("\nRevolutions; %.2f", (@angle / Math;;PI / 2).abs) } onend { @output.text = @orig_text }
I modified the model to use the new code.
-
There are a few things you're doing wrong, but who would expect you to do it right when there is no proper documentation...
First, when you set thread to static mesh, its sub groups will be a mesh collision, regardless of what you set their shape to. And just to note, Static Mesh shape and Static Mesh state are the same the things. So, if you set any top level group as a static mesh state, it will the same as setting it to static mesh shape. As I can see, your thread has sub groups consisting of convex hulls. But, you assigned the main thread to be static mesh state, which is same as static mesh shape. I suppose you wanted to simply make it a static compound shape. If that was so, then you could set its shape to Default/Compound2 and set its state to static.
Second, I can see that you are using hinge for your model. That hinge would only allow the gear to spin, but it wont allow it to move up or down. You will need to either use a hinge and slider (with temporary box to allow vertical movement and rotation) or a simply use a corkscrew joint.
Third, Static Mesh shape that is assigned to the thread doesn't consider geometry of subgroups. Your thread is made of of sub groups. That's why your thread didn't have collision. Use Static Mesh 2. Static Mesh 2 is similar to static mesh, but, unlike Static Mesh, it considers sub groups and sub components. However, if particular sub group/component has "ignore" state, then that particular sub group wouldn't be part of collision mesh.
For the nut, I would suggest using Compound2 shape. Its better than Default shape, since Compound2 assigns true centre of mass to body, and by default considers all sub groups as convex shapes. Default shape, however, by default has all sub shapes as boxes (unless you set sub shape to any other shape).
Here is the fixed thread and nut. I added a motor joint just for convenience.
-
Hi guys, once again some stuff to try and to learn - Thank you!
-
Corkscrew joint doesn't have a feature to spin connected body. You can replace it with motor and slider. Do the following:
- Create motor inside the nut
- Add a temporary box above the nut as a top level group
- Add a slider joint as a top level joint.
- Adjust motor accel and damp, and set its controller to
slider("motor")-0.5
- Adjust slider min and max. Make them -10 and 10 for instance.
- Use joint connection tool to connect motor to temporary box, and slider to temporary box.
-
I don't think I understand what you want there. Can you be a bit more informative?
-
Yes, you're right. Accel means acceleration and Damp means damper = friction.
The reason thread doesn't move properly along the nut is because physics engine that SP uses is not so good in such realtime collision operations.
Edit: You know you can always hide that temporary box if its buggin you.
-
I never used physicsCopy before. Whenever I needed a copy of something, I disconnected joints, and copied groups I wanted. Then I pasted them and created a new set of joints for the pasted groups. It's not a very convenient way though.
-
Static Mesh state and Static Mesh shape are same things, just different menu locations - they both generate static mesh collision. Static state, however, makes any collision non-movable. No-Auto-Freeze means that particular body will never go to sleep mode, a mode when body reaches its equilibrium. Sleep mode was added to physics engine to maintain performance. Enabling noautofreeze feature will never put body to sleep. This feature could be useful for some scripted FPS rigs, but its generally not useful to users who are not involved in SP scripting.
-
Speaking of the flipped thread, can you upload the model so I can see what's going on. 3D models mean a billion words...
By saying the word "collision", I don't mean the verb - contanct b/w bodies, I mean the noun - an object that consist of geometry. Static state makes any body/group/collision a non-movable ojbect. Static means that gravity or any force applied on an object, containing static state, will have no effect on its position. Static bodies are bodies with ZERO mass.
-
@sawdust_online said:
Static generates mesh collision but unmovable. Object never move.
You got Static and Static Mesh state a little wrong.
Static state does not generate any collision. It only makes any body static (non-movable). It is not responsible for generating collision of a group. Group Shape, however, like convexhull and compound, is responsible for specifying group collision type. Static state simply sets body mass to ZERO, after the body is created from a group.
Static Mesh state and Static Mesh shape assign group a mesh collision. Newton physics engine doesn't support a feature for mesh collision to be movable, so any group that has a mesh collision will be non-movable.
@sawdust_online said:
Logically unaffected state should mean .moveable?
If group shape or state is Static Mesh, it will not be movable, regardless of whether you assign it a Static state. Any other shape with an unaffected state will have the object movable.
The picture with the collision wireframe is strange. It is possible that the collision is generated incorrectly. One, is that collision wireframe is over-scaled. Two, that it has these "buggy lines".
I will try to reproduce that and debug further. -
Group/component is an entity in SU.
Collision is created from group geometry. Collision contains geometric points and lines.
Body is created from collision. Body contains functions like set position, set mass, and set velocity.
Using the word "object" is not accurate, however, I did understand what you meant. -
Your not there yet. Body is a feature from SP. Body is created by SP, not by standalone SU API.
How SP adds bodies to simulation? Answer: When you press play, SP iterates through all top level groups/components and does the following to each group:
- If particular top level group has an ignore state, then skip it - do not create collision from it - do not create body from it - do not add it to SP simulation.
- If particular top level group doesn't have an ignore state, then generate collision associated with group geometry, create body from that collision, and then add that body to simulation.
Say you have a group consisting of five subgroup, with each subgroup consisting of faces and edges. One of the subgroups contains an ignore state. The rest of them four subgroups don't contain an ignore state. This means that when SP creates collision from that top level group, only faces and edges from the four un-ignored subgroup will be added to main collision. The ignored group will not be part of the main collision. The ignore feature is added to exclude particular group from simulation because sometimes the user may not want particular sub groups to be part of simulation.
-
I think SP was designed more for mini games in SU, like a simple car that relies on joints and keyboard controls. Search 3d warehouse for "SketchyPhysics" and sort it by "most likes". You'll come across various great uses of SP. SP, with realtime simulation engine, isn't good with mechanical movements. You could try making gear, but there are low chances that it would be reliable. Collision and joints seem to be flexible. I, once, made a differential gear and it works great, although, if you surround it with a drive-able car, there is a potential for lag and too much resistance on opposite wheels might trigger intersection between gears. I think animation would suit better when dealing with precise and accurate mechanical movements. But it all depends on how complex one wants to get with mechanics. The good thing about SP is that its simple to create simulations that could be exported to separate images and combined into a movie.
Advertisement