Moderator: CPhillips
by CPhillips » Thu Jul 09, 2009 12:44 am
Here is another useful script. It allows scripts to print text to the screen. In this case a log of whatever touches the floor. - Code: Select all
#add blank text to screen at 10,50 @@log=SketchyPhysics::addWatermarkText(10,50,"") #place to store lines @@lines=[]
ontouch{|t,s,p| #add new line @@lines.push(t.name+" touched "+self.name)
#ensure only 5 lines on screen at once. @@lines.shift if @@lines.length>5 #display lines @@log.text=@@lines.join("\n")
}
onend{ @@log.erase! @@lines=nil }
Please, register (free) to access all the attachments on the forums.
-
CPhillips
-
- Posts: 1085
- Joined: Fri Nov 23, 2007 11:12 pm
by JaViXP » Sat Jul 11, 2009 3:08 pm
Very nice script! Can we upload with this version if we don't use the new features? 
-
JaViXP
-
- Posts: 168
- Joined: Fri Mar 20, 2009 3:56 pm
- Location: Spain
- Name: Javier
-
by =Physicsguy= » Sun Aug 09, 2009 5:56 am
Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)
-
=Physicsguy=
-
- Posts: 332
- Joined: Sun Feb 08, 2009 11:51 pm
- Location: [10,0,100]
- Name: Chris A
by JaViXP » Sun Aug 09, 2009 12:50 pm
Nice question, what do you want it for? Something like this should work (this one doesn't work, just play around with it): - Code: Select all
ontouch{|toucher,speed,pos| if(toucher.name=="box"){ split(self,1) } end }
Hope this helps! 
-
JaViXP
-
- Posts: 168
- Joined: Fri Mar 20, 2009 3:56 pm
- Location: Spain
- Name: Javier
-
by Wacov » Sun Aug 09, 2009 1:11 pm
=Physicsguy= wrote:Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)
Any SU ruby would work, ao you might be able to load an external .rb file as an ontick func, or whatever. But you don't need that to do what you're asking, as Jav has shown; and anything that SU can detect can be acted upon.
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by CPhillips » Sun Aug 09, 2009 10:48 pm
Wacov wrote:=Physicsguy= wrote:Never really got back to this one: Are we going to be able to set an object's scripting from an external source code?(ie setting an emitted object to explode on impact.)
Any SU ruby would work, ao you might be able to load an external .rb file as an ontick func, or whatever. But you don't need that to do what you're asking, as Jav has shown; and anything that SU can detect can be acted upon.
Hi everyone. Sorry I have been quiet lately. Been taking some time off and enjoying the summer. I think it is possible to set events externally with this version. I know the the syntax is a bit weird and I plan to clean it up. Create a good sized cone and put this in its scripted field. - Code: Select all
b=copy b._setEvent("ontick", <<CODE push([0,0,1])#go forward if(frame>50) destroy #die after 50. end CODE )
The cone will copy itself and then set the "ontick" event in the copy. I tried to make an example that uses "ontouch" but it didnt work for some reason. I will have to debug it.
-
CPhillips
-
- Posts: 1085
- Joined: Fri Nov 23, 2007 11:12 pm
by NorviewsVeteran » Thu Aug 20, 2009 8:05 am
Sorry I don't have much to add, but there are a few things. I'm no programmer, I'm on the mechanical team. 1. You guys are blowing my mind. Wacov, when I opened your cloth file my jaw dropped for so long I almost drooled on my cat. 2. Can we upload with this version if we don't use the new features?
3. I needed an excuse to upload the Gopher.
Please, register (free) to access all the attachments on the forums. - Code: Select all
//This_Is_All(I)+=Know()About.Code;
-
NorviewsVeteran
-
- Posts: 17
- Joined: Wed Mar 11, 2009 1:00 am
- Name: Richard Raitt
by CPhillips » Fri Aug 21, 2009 6:06 am
Nice model!
-
CPhillips
-
- Posts: 1085
- Joined: Fri Nov 23, 2007 11:12 pm
by NorviewsVeteran » Sat Aug 22, 2009 7:00 am
Thank you, have another.
I figured out the scripted joints (big for me) to the point where I used universal joints for the bogies and you can copy more cars to the train, but the problem is I had to daisychain the joints under the cars so much the sag makes the cars lean in turns. Just beware of derails, they seem to be quite frequent...
If anyone can figure out a way around this, that would be great.
Please, register (free) to access all the attachments on the forums. - Code: Select all
//This_Is_All(I)+=Know()About.Code;
-
NorviewsVeteran
-
- Posts: 17
- Joined: Wed Mar 11, 2009 1:00 am
- Name: Richard Raitt
by Wacov » Thu Aug 27, 2009 6:41 pm
NorviewsVeteran wrote:1. You guys are blowing my mind. Wacov, when I opened your cloth file my jaw dropped for so long I almost drooled on my cat. CPhillips wrote:I think it is possible to set events externally with this version. I know the the syntax is a bit weird and I plan to clean it up. Create a good sized cone and put this in its scripted field. - Code: Select all
b=copy b._setEvent("ontick", <<CODE push([0,0,1])#go forward if(frame>50) destroy #die after 50. end CODE )
The cone will copy itself and then set the "ontick" event in the copy. I tried to make an example that uses "ontouch" but it didnt work for some reason. I will have to debug it.
It totally crashes my SU when I try it in ontouch, and freezes the sim in ontick... also, I can't drag the original object. It highlights, and the drag line appears, but no movement 
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by =Physicsguy= » Thu Aug 27, 2009 7:52 pm
I think it is possible to set events externally with this version. I know the the syntax is a bit weird and I plan to clean it up.
Create a good sized cone and put this in its scripted field.
Err... looks like you didn't try it in the right field.
-
=Physicsguy=
-
- Posts: 332
- Joined: Sun Feb 08, 2009 11:51 pm
- Location: [10,0,100]
- Name: Chris A
by Wacov » Fri Aug 28, 2009 3:17 pm
I mean ontick/touch as in: - Code: Select all
ontick{ ... }
Try it, see what you get.
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by CPhillips » Fri Sep 04, 2009 11:55 pm
I am not 100% sure that works in this version. It may depend on some unreleased code. Can anyone confirm it works?
-
CPhillips
-
- Posts: 1085
- Joined: Fri Nov 23, 2007 11:12 pm
by =Physicsguy= » Sun Sep 06, 2009 2:20 am
It works for me.
-
=Physicsguy=
-
- Posts: 332
- Joined: Sun Feb 08, 2009 11:51 pm
- Location: [10,0,100]
- Name: Chris A
by JaViXP » Sun Sep 06, 2009 2:44 pm
Same for me.
-
JaViXP
-
- Posts: 168
- Joined: Fri Mar 20, 2009 3:56 pm
- Location: Spain
- Name: Javier
-
by Wacov » Sun Sep 06, 2009 4:02 pm
It works for me, just not in any events.
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by CPhillips » Sat Sep 12, 2009 5:46 am
Wacov wrote:It works for me, just not in any events.
Not sure I understand. Can you post a model that fails and I will take a look.
-
CPhillips
-
- Posts: 1085
- Joined: Fri Nov 23, 2007 11:12 pm
by =Physicsguy= » Sat Sep 12, 2009 6:36 am
BTW,(this may be a stupid question), but is there a way around the camera 'bending' situation where the camera eye overshots to some other point3D? I cant get any reliable camera systems...
-
=Physicsguy=
-
- Posts: 332
- Joined: Sun Feb 08, 2009 11:51 pm
- Location: [10,0,100]
- Name: Chris A
by Wacov » Sat Sep 12, 2009 12:01 pm
CPhillips wrote:Wacov wrote:It works for me, just not in any events.
Not sure I understand. Can you post a model that fails and I will take a look.
In Jun 27, putting your code inside a normal event (ontick{...}) crashes. It seems to work in the SVN version, though 
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by mariocha » Thu Oct 22, 2009 3:11 am
Hi, just to share 2 small animations done with SkPh-3. One is quite amusing, showing Emitter, Thruster and magnet http://www.youtube.com/watch?v=ea5KeZ7Turgthe other shows pseudo-virus http://www.youtube.com/watch?v=Yb_D__3m_0w
Mario C. Certified SketchUp Trainer, QC CA, Mac Pro 2xQuad core & MacBook Pro 3.06 Ghz.
-

mariocha
- Premium Member

-
- Posts: 171
- Joined: Wed Nov 21, 2007 3:00 pm
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by mariocha » Thu Oct 29, 2009 2:03 am
Wacov wrote:Got cloth smoothing working, and made it easier to change the scripting (everything's in the floor).
Ok I give up. Wacov, I just cannot see how this works. I have tried a few times. Refreshed my SkPh knowledge. Had fun with the new features. But your cloths are a vast mystery to me. The SkPh UI shows nothing. Is it PC only ? Scripting only ?
Mario C. Certified SketchUp Trainer, QC CA, Mac Pro 2xQuad core & MacBook Pro 3.06 Ghz.
-

mariocha
- Premium Member

-
- Posts: 171
- Joined: Wed Nov 21, 2007 3:00 pm
- Operating system: Mac
- SketchUp version: 8
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Wacov » Thu Oct 29, 2009 12:17 pm
Basically, there's a physics object at the vertices of each panel of cloth. What you see in the simulation is Sketch Up geometry, which is created at the beginning of the sim, and modified in real-time; the main script is in the floor's scripted field, which creates a command used in the hidden physics objects.
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by JeremyGBertin » Mon Nov 30, 2009 7:20 pm
Hello Everyone, new member here.
Can anyone point me to a working example using the 'UnTouch' script functionality? I've played around with it, but can't quite seem to get it to work. I apologize if this has long since been covered somewhere, but I can't seem to find any examples. Thanks.
-
JeremyGBertin
-
- Posts: 5
- Joined: Thu Nov 26, 2009 10:46 pm
- Name: Jeremy
by Davidfi1 » Mon Nov 30, 2009 7:31 pm
Did you mean OnTouch? 
Please, register (free) to access all the attachments on the forums.
-
Davidfi1
-
- Posts: 81
- Joined: Sat Oct 11, 2008 8:31 am
by JeremyGBertin » Mon Nov 30, 2009 8:34 pm
No, I was not referring to the onTouch which is in the UI, but rather the opposite signal for when two objects stop touching.
Looking through the ruby code there seem to be events for onTouch, onTouching, and onUnTouch and I would like to know whether these are accessible for use. I am specifically looking for an example making use of an event which can fire code when two objects stop touching.
The effect I am trying to achieve it to set a variable when two objects come into contact, and clear the variable only when the objects move apart. Thanks!
-
JeremyGBertin
-
- Posts: 5
- Joined: Thu Nov 26, 2009 10:46 pm
- Name: Jeremy
by Wacov » Mon Nov 30, 2009 9:40 pm
Basically, you use: - Code: Select all
ontouch{ #your code here #code #code #more code #etc }
In the scripted field. The code you put between the brackets will be executed, in the case of ontouch, upon every collision with another object. ontick{...}, onuntouch{...}, and ontouching{...} work in basically the same way, with ontick executed every frame, onuntouch whenever the object stops colliding, and ontouching every frame the object is colliding with another. With any of the the touch events, you can also access the object being collided with, the exact point3d of the collision, and the impact speed of the collision, using: - Code: Select all
ontouch{|toucher,speed,pos| #code }
You can then use them as variables in your event code.
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by JeremyGBertin » Mon Nov 30, 2009 11:20 pm
Thanks Wacov. Much appreciated.
-
JeremyGBertin
-
- Posts: 5
- Joined: Thu Nov 26, 2009 10:46 pm
- Name: Jeremy
by hpnisse » Tue Dec 01, 2009 6:27 pm
Hello! When I try the "ontouch" in script-field event it will not work:S Ex. I have a "button" (box), and when I push that button it touch another box with the script (easy one, see below) the physics engine freeze and I need to restart the physics-simulator. Here is the simple code I use: - Code: Select all
ontouch{ setVar("var1",1) }
Why does the physics-simulator freeze? And will this script set the "var1" to "0" (zero) when I relase the button? Thank´s for help. /hpnisse
/hpnisse Windows 7 U - Sketchup 8 - SketchyPhysics 3.2-Dec2 - from Sweden
-
hpnisse
-
- Posts: 101
- Joined: Tue Feb 10, 2009 1:02 pm
- Name: Tim
by Wacov » Tue Dec 01, 2009 8:44 pm
The commands from RC1 no longer work in the scripted field, inluding get/setVar. The new variables are:
@var = 1
For a local (this group only) variable, retrieve it with:
@var
And:
@@var = 1
For a global (acessible from all groups) variable. Retrieve with:
@@var
-
Wacov
-
- Posts: 532
- Joined: Wed Sep 24, 2008 8:32 pm
- Location: United Kingdom
by JeremyGBertin » Wed Dec 02, 2009 4:37 am
Does anyone know of a way to allow for a Servo joint to rotate multiple revolutions?
It seems like the maximum workable range for the Servo joints are 360 Degrees (2*pi radians) symmetrical about the starting angle, and when exceeded the joint starts to endlessly spin around. I am looking to achieve multiple revolutions while still maintaining angular position control. Any ideas would be welcome. Thanks!
-
JeremyGBertin
-
- Posts: 5
- Joined: Thu Nov 26, 2009 10:46 pm
- Name: Jeremy
by Ad Machine » 5 minutes ago
Need SketchUp Books, Models, Styles or Textures? Check out our One Stop Shop for SketchUp. Premium Members get 20% discount!
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to SketchyPhysics
|