Does sketchup have a UDP interface? We were thinking of having a play with some wiimote/kinect interaction stuff --> http://ubimash.com
Latest posts made by ben.doherty
-
UDP interface
-
RE: Some critique
Thanks chaps. In some odd way I knew that, well, I owned all the bits of information, I just hadn't assembled them yet. I've updated it so that lesson 1 reads better (i.e. no variables)
I'll go through and check the others now. -
Some critique
I made some Ruby tutorials for sketchup to use in our office. They are a but rough around the edges as they've not really stretched their legs yet. I'd be really interested in getting some feedback on them. If anyone fancies having a look at them then I'd be really grateful!
-
RE: Texture from url?
While the JS debate rages, I've been playing with what can be done with ruby (being single-minded/stubborn/lazy)
I've updated my !loadpaths file to match dan's latest http://forums.sketchucation.com/viewtopic.php?f=180&t=29412&hilit=load+path#p257058
and when I try a couple of things I get this response:
require 'net/http' Error: #<LoadError: C:/ruby186/lib/ruby/1.8/net/protocol.rb:21:in
require': No such file to load -- socket>
C:/ruby186/lib/ruby/1.8/net/protocol.rb:21
require 'date/format'
true`Any ideas on why net/http fails, but date/format works?
I'm sure it will take some clever file management, and refresh cycle control etc, but it'd be cool to be able to specify a url to get a texture from. That'd open up a load of opportunities for data vis etc.
-
RE: Texture from url?
That would probably work, but wouldn't win any prizes for elegance.
Given that ruby can access things on the internet as part of it's core library does anyone have any idea how to point it at those standard libraries? -
RE: Texture from url?
Hi, I'm trying to do something similar.
I'm not too fussed about using non sketchup ruby libraries, so I just want to do it in the most elegant way possible.I tried adding:
$LOAD_PATH << "C:/Ruby186/lib/ruby/1.8/net"
$LOAD_PATH << "C:/Ruby186/lib/ruby/1.8/i386-mingw32"
to my load paths as a way to crunch through the error messages that I got (couldn't find socket etc.)Is there an easy way to do this that is nice and easy and clean?
-
RE: InHalfspace?
I'm not interested in finding out if the point is on the plane, simply if it is in the +ve half or the universe bisected by the plane.
It's a pretty classic test that can be stacked up to do selection sets. i.e. to test if a point is in a cube you test to see if it is in the -ve halfspace of the planes of each of the faces. A fail on any test shows that it isn't in that halfspace, and therefore you can bail out.
I've got to put some effort into packaging this up so that it takes a plane and a point (or a collection thereof)
I think that there is probably something to be gained by pulling out the proper equation of the plane rather than doing the offset, but I'm not all that hot on maths. (not sure why they start you at university afterthe legal drinking age) -
InHalfspace?
I couldn't see a method to find out if a point is in a halfspace defined by a plane or not, so I made this toy one.
#setup gubbins mod = Sketchup.active_model ent = mod.entities sel = mod.selection #draw a face and select it, this checks that you have if sel[0].is_a? Sketchup;;Face #if you have, throw 100 points into the air for i in (0..100) ent.add_cpoint [rand*100,rand*100,rand*100] end #get the normal of the face normal = sel[0].normal #get the centroid of the face too offset = Geom;;Vector3d.new(sel[0].bounds.center.to_a) #make an empty collection to put your points into if they ARE in the halfspace pointsInPositiveHalfspace = [] #loop through all the things in the model, ent.each{|e| # if they are points... if e.is_a? Sketchup;;ConstructionPoint #move them so that they are relative to the centroid of the face, not to the origin. #this one is the big mental shift shiftedPt = Geom;;Vector3d.new(e.position.to_a) - offset #The dot product can be used as a half space test. A half space test can be used to #determine if an object, lets say a zombie, is in front of the player (or camera) or #behind it. If my player's forward vector is P and the vector from the player to the #zombie (zombie's position - player's position) is Z, then dotting P and Z would give #me the angle between the two vectors. If the angle is positive our player is facing #the zombie, otherwise the zombie is behind us (never turn your back on a zombie!!!). if (normal.dot shiftedPt) > 0 #put that point into the colleciton pointsInPositiveHalfspace << e end end } #for all the points in the collection... for i in (1..pointsInPositiveHalfspace.length) if pointsInPositiveHalfspace[i].is_a? Sketchup;;ConstructionPoint #Draw a line from it's predecesor to it ent.add_line pointsInPositiveHalfspace[i-1].position, pointsInPositiveHalfspace[i].position end end end
There's a lot to do to it before it is actually useful, but it may help me with my quest if there isn't a better way. -
RE: Taking pictures with cameras
The other solution I suppose would be to select everything in the halfspace behind the camera and set it's material to a transparent png as suggested here http://groups.google.com/group/SketchUp3d/browse_thread/thread/2ce1ef1f54e7b6dc?pli=1 .
That really is going to slow things down if I have to do 2 material sets for each entity.
-
RE: Taking pictures with cameras
Oh the arrogance. Nearly finished indeed!
I tested this on a real model rather than my toy model and it had a complete fit.it seems that even though you've set the eye point, SketchUp takes pictures from the edge of the universe.
This means that the images taken from the green positions are fine, but the ones taken from the red directions are actually taken from the outside of the building.I reproduced this to prove that I'm not mad.
The spikes are the view cones of 120 degree camera and a 60 degree camera. the circle is a cylinder behind the camera.
If you take a picture from this position the cylinder is clearly visible in the image. Grrrr
If you use the walk around tools in the UI then you can go in front of the cylinder, but I couldn't find anything to do with this in the API.
The thing that seemed to be the most likely to help was the section plane, but this seems to affect the shadows which isn't a lot of help.I think it might be time to start looking very seriously at OpenStudio, but it's a shame to have come this far to be thwarted at the end!
Any ideas?