sketchucation logo sketchucation
    • Login
    1. Home
    2. AdamB
    3. Posts
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 129
    • Posts 933
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: SketchyPhysics Alpha

      re: weighing stuff.

      In the past I've had some good success using Physics systems by calculating the volume of an object and using some density parameter to figure some mass. The volume of a closed object is as I describe in this thread:

      301 Moved Permanently

      favicon

      (www.sketchucation.com)

      I used to figure density from the materials the object used (which tended to be correct as they're often used to drive sound / particle-puffs on collisions.

      posted in SketchyPhysics
      AdamBA
      AdamB
    • RE: Volume Calculator v2...

      One technique I use to mark problem geometry for my stuff is to use something like this:

      def show_problem(wpos)
      msg = Sketchup.active_model.entities.add_text "malformed material; missing albedo", wpos
      msg.vector= Geom::Vector3d.new(20,20,20)
      msg.display_leader=true
      end

      You might want to also check the volumes form a manifold surface before you start.. Just a thought.

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: Detecting a flipped transform.

      OK, I think I can help. First off, don't get hung up on the flipped thing. Its not a 'magic' operation - how many times have I multiplied the following number by -1?

      123

      You can't know. An even number of multiplies (aka flips) gets you back to where you started. Its the same with multiplying an axis.

      OK, some background. The basic building block of almost all this stuff is dot product. Dot product is actually projecting 1 vector onto another to see how far along it lies. The transforms in SU are made of 4 things. An xaxis, yaxis, zaxis and a position stored in a Geom::Transformation. When you do "object.transform aMatrix" what you're actually doing is calculating how far along those 3 axes "object" lies. If you look at a vector matrix multiply it is composed of 3 dot products because all you're doing is projecting the vector onto those 3 axes in turn to give 3 numbers to make your 3d coordinate. (Its very simple but I'm amazed the number of engineers I've interviewed for jobs that haven't understood this!)

      The scale of an SU transform is in the axis,yaxis,zaxis of the Transformation. So, the length of the xaxis,yaxis and zaxis tell you much scaling there is in each direction.

      object.transformation.to_a[0..2] is the xaxis
      object.transformation.to_a[4..6] is the yaxis
      object.transformation.to_a[8..10] is the zaxis

      (Rather unhelpfully if you do object.transformation.xaxis you get a unit length vector..)

      A normal matrix has axes of unit length (aka no scaling)
      An orthogonal matrix has axes at right-angles to each other.
      A orthonormal matrix is both unit length AND at right-angles.

      Physics systems often want orthonormal matrices. This means you'll need to record the length of each axis then normalize followed by ensuring its orthogonal by ensuring z = x * y and x = y * z

      A note on crossproduct

      a * b gives a vector perpendicular to a and b and of length absin(theta) where theta is the angle between a & b. What this means is if a and b are unit length but NOT perpendicular, you'll get a vector that is not unit length and it needs re-normalizing.

      You can see that Orthonormalization of matrices is expensive but the quality of your results depends on it.

      There's something to be going on...

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: Detecting a flipped transform.

      Ah but if you 'flip' in blue and then green the object isn't flipped! You've performed a 180 around x. The math is telling the truth.. πŸ˜„ The cross product of the axes will give you the handedness of the coordinate system. Sounds like you almost want some kind of history of what happened - thats something the coordinate frame cannot give you.

      Stepping back.. What are you trying to do? Is it face winding order you want? ie Whats 'front' and whats 'back'?

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: Keeping control over very long tasks

      I've had no success either. I guess its because if you look at how its recommended to embed Ruby in an App, its a very simple ruby_run() model. So SU may be multi-threaded or not, but the call to Ruby is a busy wait.

      Pretty much the only thing that does work is spawn a Ruby thread that twiddles the Sketchup.set_status_text

      😞

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: Detecting a flipped transform.

      Sketchup uses a righthanded coordinate system. Flipping (scale by -1) of an axis makes it like a lefthanded system, so why don't you just check that xaxis * yaxis == zaxis and yaxis * zaxis == xaxis. In fact you're only interested in the sign so (xaxis * yaxis).dot(zaxis) < 0 means its flipped.

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: An idea: topography in sketchup (I am not a programmer :-( )

      Not sure what you mean by "simple shapes"..

      If the origin is outside the shape, then the origin-facing faces give a negative contribution, the others a positive so you get the right answer.

      Not sure what happens with multi-boundary faces, but all this was in the context of a marching cubes point cloud triangulation, so we're good to go.

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: An idea: topography in sketchup (I am not a programmer :-( )

      Ah, you spotted my deliberate slowdown so I could come out with v2.0 Damn.

      Yes of course that would be picoseconds faster..

      FWIW, its because I would normally write this as edge1 x edge2 to get the 0.5 the face area, but the good folks at Sketchup already gave me a Face#area call but I neglected to remove the multiply. Or I hadn't had enough coffee.

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: Lighting Plugin for Sketchup

      Thanks for all the nice words!

      I've still got work to do on the technology but its mostly there. Currently it is a pure Ruby implementation (so its fine on any platform), I already have a custom Tool for area emitter power, color, and angular fall-off (so IES light support should be possible) and materials can be marked to be ignored (ie skip geometry). Animation should "just work" and I'm going to speak with the Sketchup guys to figure out how to integrate better with the built-in lighting.

      It does need more work on how I map from HDR internally to RGB for display, and I can wring some more performance out of it, but you can see its in the ballpark.

      I am really pleased with the responses so far; this is a classic case of needing some lighting myself, developing the tech and then finding lots of others want the same!

      I'll keep you posted!

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: An idea: topography in sketchup (I am not a programmer :-( )

      Well funnily enough I wrote the following snippet for calculating volume this morning.

      class Geom;;Point3d
      	def dot(v)
      		self.x * v.x + self.y * v.y + self.z * v.z
      	end
      end	
      
      def calculateVolume(container)
      		volume = 0
      	for face in container
      		next unless face.kind_of? Sketchup;;Face
      		volume += (2 * face.area * (face.vertices[0].position.dot face.normal)) / 6
      	end
      	volume
      end
      
      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: [Plugin] VolumeCalculator v1.8

      Doh. And you need to have Geom::Point3d#dot defined - (which is beyond me why it isn't as standard)

      class Geom;;Point3d
      	def dot(v)
      		self.x * v.x + self.y * v.y + self.z * v.z
      	end
      end	
      
      posted in Plugins
      AdamBA
      AdamB
    • Lighting Plugin for Sketchup

      Hi,

      Thought you might be interested in this video of some lighting technology I've been developing for Sketchup.

      Is this useful? Any comments, suggestions etc welcome.

      Adam

      posted in Developers' Forum
      AdamBA
      AdamB
    • RE: [Plugin] VolumeCalculator v1.8

      This all seems quite a complex way of getting the volume.. The following analytic approach works nicely.

      def calculateVolume(container)
      	
      	volume = 0
      	for face in container
      		next unless face.kind_of? Sketchup;;Face
      
      		volume += (2 * face.area * (face.vertices[0].position.dot face.normal)) / 6		
      	end
      	volume
      end
      
      posted in Plugins
      AdamBA
      AdamB
    • 1 / 1