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

    Immer

    @Immer

    10
    Reputation
    1
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Immer Unfollow Follow
    registered-users

    Latest posts made by Immer

    • RE: [Plugin] Import OBJ with Materials v2.1 20131118

      Thanks, but I've got enough projects on my plate already, I was just lopping a few warts off a new tool in my box. I've seen Fluid, but my main dabbling machine is an old Mac so it's not convenient to use.

      I can completely relate to not wanting to make frequent updates to old projects though, so here's my faster version for anyone interested.much faster version that also reuses existing materials instead of leaving objects untextured

      posted in Plugins
      I
      Immer
    • RE: [Plugin] OBJexporter v3.0 20130131

      Yeah, I had noticed and used the flattenUVQ method provided - I figured it was something you had brought in from someone else's code but didn't use. I didn't see it in the latest version so I thought I'd include it in case you didn't have an archive of older versions.

      Don't get me wrong, it's awesome that you've managed to export non-linearly distorted faces accurately, however for many situations a linear approximation is preferable, especially if lots of additional textures or a complicated group layout present problems - like if you intend to use the exported object in a game engine, or want to fine-tune the UV mapping in another program. It may even be what was actually intended: for example UVTools' spherical map apparently uses distorted textures when linear interpolation is the correct method. In fact I'm not sure it's even possible to specify a lineraly distorted face in Sketchup. I've yet to find a way to, for example, squeeze a rectangular texture onto a trapezoid so the edges and center-points line up perfectly, and that's UV mapping 101.

      All I'm suggesting is a checkbox on the option screen to choose between the accurate method and the "clean" one, it should just be a matter of changing the logic to

      
      if "face is distorted"     *AND* "use accurate method"
         create accurate texture
         export face using accurate texture
      else
         output face with normalized UVs # normalizing should have no effect on non-distorted faces
      
      
      posted in Plugins
      I
      Immer
    • RE: [Plugin] Import OBJ with Materials v2.1 20131118

      Hi TIG, I've got a few more patches for you, on your importer this time. I've been running into " - Material already exists..." errors a lot, which cause the associated group to be imported untextured.

      I changed the following code to reuse the existing material, but it might be nice to have an option to automatically mangle the material name if it really is a different texture.

      
      	when "newmtl"
      		mat_name=values[0]
                      matnames=[];materials.each{|mat|matnames << mat.display_name}
                      if matnames.include?(mat_name)
                        puts mat_name+" - Material already exists..."
                        ### traps for usemtl called x2 in obj or pre-existing materials
                        current_mat=nil
      		  ## NEW; make sure pre-existing materials are re-used
      		  if nil==new_mats.find{|mat|mat.name==mat_name}
      			new_mats << materials[mat_name]
      		  end
      
      

      I also noticed that the vast majority of import time is spent updating the progress bar. A quick fix that shortens a minute-long import to a few seconds:

      
      change 
      	Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
      to
      	 if line_cnt % 73 == 0 # could be any number, 73 just makes the digits spin nicely
      		Sketchup.set_status_text("Processing line #{line_cnt} of #{lines.length}")
      	 end
      
      

      Finally, one of my test models suffered from the "some faces get reversed" bug mentioned above - but I noticed that when I then imported the same object again, without my material reuse code so it ended up untextured, the problem disappeared. When I tested by commenting out the "position_material" line in the following code the problem also went away, but obviously so did the texture.

      
      if new_face and @current_mat!= nil 
      	if @current_mat.texture != nil
      		pt_array=[]
      		pt_array=[verts[0],face_uvs[0],verts[1],face_uvs[1],verts[2],face_uvs[2]]if verts_length==3 and face_uvs
      		pt_array=[verts[0],face_uvs[0],verts[1],face_uvs[1],verts[2],face_uvs[2],verts[3],face_uvs[3]]if verts_length>3 and face_uvs
      		# new_face.position_material(@current_mat,pt_array,true)
      	else
      ...
      
      

      I'll keep poking at it, but I'm having to figure out both Ruby and Sketchup's API as I go, so you might have more luck.

      Here's the globe model I noticed the problem on for referencetextured globe that suffers from some face-inversions when imported

      posted in Plugins
      I
      Immer
    • RE: [Plugin] OBJexporter v3.0 20130131

      Thanks TIG, this is an incredibly useful plugin, the most reliable obj-exporter I've tried.

      I have one feature request though - could you add an option to export faces with distorted textures using the original texture and just save the "distorted" UV coordinates in the .obj file? As it is now doing something as simple as exporting a spherically-mapped globe can generate hundreds of distorted texture files and a correspondingly complicated .obj file, not exactly ideal for loading into another program.

      I've modified version 1.1 to normalize the UVQ coordinates before export and it seems to work fine, it would be nice to have access to the more recent features though so I'm sending you the change in hopes that you'll incorporate it into the next version

      the relevant change was changing the line
      f_uvs=(1..mesh.count_points).map{|i|mesh.uv_at(i,1)}####1=front
      to
      f_uvs=(1..mesh.count_points).map{|i|flattenUVQ(mesh.uv_at(i,1))}####1=front
      where flattenUVQ is defined as
      def flattenUVQ(uvq)
      return Geom::Point3d.new((uvq.x/uvq.z), (uvq.y/uvq.z), 1.0)
      end

      Thanks a bunch!

      posted in Plugins
      I
      Immer