urbanlamb - all messages by user

2013/3/28 20:30:38
ASE importer link I just opened it the file is not blank.

right click "save link as"

and then if you want to see it open it up in notepad but it does work

here is the code I dont know how successful you will be copying and pasting and resaving it but its there if you want to try.



#
# Muvizu-ASE-Exporter.rb
# 2010/09/18 - RUBY
#
#-------------------------------------------------------------------------------------------
#
# This program (plugin) is based on original work by Raphael Couturier (HardPCM). It has been
# modified, under the terms of the GNU Lesser General Public License, all changes made have
# been with a goal in mind; optimising the original ASE export feature from HardPCM for use
# with Muvizu (http://www.muvizu.com).
#
#-------------------------------------------------------------------------------------------
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place - Suite 330, Boston, MA 02111-1307, USA, or go to
# http://www.gnu.org/copyleft/lesser.txt.
#
#-------------------------------------------------------------------------------------------
#
# Original Auther - Raphael Couturier (HardPCM) - hardpcm666@hotmail.com, hardpcm666@gmail.com
# Updated by - Jamie Hill (CerebralDump) - jamie@muvizu.com
#
# File: MuvizuASEExporter.rb
# Version: 0.0.8
# Started: 01/09/10
# Released: -
# Langage: English
#
# Description: Main Source for a Google Sketchup Plugin that allows you to export
# ASE files specifically for Muvizu, which uses the Unreal 3 games engine.
#
#-------------------------------------------------------------------------------------------
#
# Special thanks to:
#
# - Raphael Couturier (HardPCM) for the original work.
#
# - Jim Skivington for testing the early attempts and the changes.
#
#-------------------------------------------------------------------------------------------
# Change List / History
#
# 0.0.1 - Write out texture filename and path for ASE submaterial tag *BITMAP "..."
# 0.0.2 - Generate collision mesh automatically. Copy geometry into another GEOMODEL object prefixing object name with UCX. Collision was too complex.
# 0.0.3 - Removed non-essential parts for Muvizu input (import, and all export except ASE functions).
# 0.0.4 - Limited output to components only. Remove all handling of groups.
# 0.0.5 - UI to allow selection of one component as geometry and one component as collision.
# 0.0.6 - Renamed classes and methods to avoid dependency or interfearance with the original plugin.
# 0.0.7 - Refined UI to reduce and report errors.
# 0.0.8 - Updated about text and source comments for completeness.
#
#-------------------------------------------------------------------------------------------

require 'sketchup.rb'

class WalkerWaitT3D_UTX

# Updated: by HardPCM date unknown.
def initialize
@m_nIndex = 0
@m_sTable =
end

# Updated: by HardPCM date unknown.
def Tick(nLevel = 1)
# Show step
a_sText = "Processing at level No = #{"%0.f" %(nLevel)} \"O.{#{@m_sTable}}.O\" \n"
code = Sketchup.set_status_text a_sText

# Next step
@m_nIndex += 1
if @m_nIndex >= 8
@m_nIndex = 0;
end
end

# Updated: by HardPCM date unknown.
def Say(sMessage)
code = Sketchup.set_status_text sMessage
end
end


class IteratorerDataT3D_UTX

# Updated: 24-September-2010
def initialize(pFirstNode = nil, pProcessorNode = nil, bFirstNode = nil, bProcessorNode = nil, thePath = "")
# Populate the instance variables to process the sketchup model into ASE format.
@m_pProcessorNodeCol = pProcessorNode
@m_pFirstNode = pFirstNode

# Expect to have collision by default.
@m_hasCollision = true

# Get the names of the components exported for later reporting.
@m_theModelName = pFirstNode.definition.name
@m_theSavePath = thePath

# Check if there is collision geometry to be generated as well.
if bFirstNode != nil
@m_bProcessorNodeCol = bProcessorNode
@m_bFirstNode = bFirstNode
@m_theCollisionName = bFirstNode.definition.name
else
# No collision.
@m_hasCollision = false
end

# Prepare the material lists.
@m_pMaterials =
@m_pMaterials.push(nil)
@m_bMaterialsChanged = false

# Prepare transforms - not sure why anything needs to be transformed...
@m_Transformations =
@m_Transformations.push(Geom::Transformation.new)

# Set level to begin processing at.
@m_nLevel = 1

# Start the wait walker to update the status bar text.
@m_pWalker = WalkerWaitT3D_UTX.new
end

# Updated: 24-September-2010
def Start()
# Process the geometry model.
self.Process(@m_pFirstNode, @m_pFirstNode, @m_pProcessorNodeCol)

if @m_hasCollision == true
# If selected process the collision model.
self.Process(@m_bFirstNode, @m_bFirstNode, @m_bProcessorNodeCol)
end

# Write to file.
@m_pProcessorNodeCol.WriteHeader
@m_pProcessorNodeCol.WriteMaterials
@m_pProcessorNodeCol.WriteGeometry
if @m_hasCollision == true
@m_bProcessorNodeCol.WriteCollision
end

# Finished!
@m_pWalker.Say("Job Done - Model exported!")
theEndMessage = ""
if @m_hasCollision == true
theEndMessage = "Collision geometry exported from component #{"%s" %(@m_theCollisionName)}\n\n"
else
theEndMessage = "No collision geometry exported. Muvizu will create this on import.\n\n"
end
UI.messagebox "#{"%s" %(theEndMessage)} Geometry model exported from component #{"%s" %(@m_theModelName)}\n\nFile saved to #{"%s" %(@m_theSavePath)}"
end

# Updated: 24-September-2010
def Process(pCurrentNode, pParent, theProcessor)

# Explode components or groups so we can process each face within it.
if(pCurrentNode.class == Sketchup::Group)
pCurrentNode = pCurrentNode.entities
elsif(pCurrentNode.class == Sketchup::ComponentInstance)
pCurrentNode = pCurrentNode.definition.entities
end

for a_Entity in pCurrentNode
if(a_Entity.class == Sketchup::Face and a_Entity.layer.visible?)
# Identify the material on the face being examined.
a_pMaterial = a_Entity.material
@m_bMaterialsChanged = false
if a_pMaterial != nil
@m_pMaterials.push(a_pMaterial)
@m_bMaterialsChanged = true
end

# Process the mesh co-ordinates for the face being examined.
theProcessor.ProcessFace(a_Entity, @m_pMaterials.last, @m_Transformations.last)

# Finish processing the material on the face being examined.
if @m_bMaterialsChanged == true
@m_pMaterials.pop
@m_bMaterialsChanged = false
end

# Reporting only.
@m_pWalker.Tick(@m_nLevel)
end
end

for a_Entity in pCurrentNode
# If there is a component within the current component or group then recursively process that component as well.
if((a_Entity.class == Sketchup::ComponentInstance or a_Entity.class == Sketchup::Group) and a_Entity.layer.visible?)
@m_nLevel += 1
@m_Transformations.push(@m_Transformations.last * a_Entity.transformation)
self.Process(a_Entity, pCurrentNode, theProcessor)
@m_Transformations.pop
@m_nLevel -= 1
end
end
end
end

class FileWritter

# Updated: 24-September-2010
def initialize(asePath)
@m_pFile = nil
@m_sAsePath = asePath
self.OpenFile
end

# Updated: 24-September-2010
def OpenFile
@m_pFile = File.new(@m_sAsePath,"wb")
end

# Updated: 24-September-2010
def WriteToFile(aLine)
@m_pFile.write(aLine)
@m_pFile.flush
end

# Updated: 24-September-2010
def CloseFile
@m_pFile.flush
@m_pFile.close
end
end

class ExporterDataASE_UTX

# Updated: 24-September-2010
def initialize(theFileWritter, theModelName)
@m_FileWritter = theFileWritter

@m_vVertex =
@m_vVertex.fill(,0,15000)
@m_nNextVertex = 0

@m_vVertexUV =
@m_vVertexUV.fill(,0,15000)
@m_nNextVertexUV = 0

@m_vNormal =
@m_vNormal.fill(,0,15000)
@m_nNextNormal = 0

@m_pTriangle =
@m_pTriangle.fill(,0,15000)
@m_nNextTriangle = 0

@m_pMaterial =
@m_pMaterial.fill(,0,1000)
@m_nNextMaterial = 0

@m_nModelName = theModelName
end


# Updated: by HardPCM date unknown.
def NextVertexXYZ(pPacket)
# Search an existing XYZ.
a_nIndex = @m_nNextVertex - 1
a_nCount = 256

if a_nCount > a_nIndex + 1
a_nCount = a_nIndex + 1
end

while a_nCount > -1
a_pTemp = @m_vVertex
if (a_pTemp == pPacket) && (a_pTemp == pPacket) && (a_pTemp == pPacket)
if (a_pTemp == pPacket) && (a_pTemp == pPacket) && (a_pTemp == pPacket)
return a_nIndex
end
end
a_nIndex = a_nIndex - 1
a_nCount = a_nCount - 1
end

# Create a new XYZ
@m_vVertex = pPacket
@m_nNextVertex = @m_nNextVertex + 1
return @m_nNextVertex - 1
end
# Updated: by HardPCM date unknown.
def NextVertexUV(pPacket)
# Search an existing UV
a_nIndex = @m_nNextVertexUV - 1
a_nCount = 256

if a_nCount > a_nIndex + 1
a_nCount = a_nIndex + 1
end

while a_nCount > -1
a_pTemp = @m_vVertexUV
if (a_pTemp == pPacket) && (a_pTemp == pPacket) && (a_pTemp == pPacket)
return a_nIndex
end
a_nIndex = a_nIndex - 1
a_nCount = a_nCount - 1
end

# Create a new UV
@m_vVertexUV = pPacket
@m_nNextVertexUV = @m_nNextVertexUV + 1
return @m_nNextVertexUV - 1
end

# Updated: by HardPCM date unknown.
def NextNormalXYZ(pPacket)
@m_vNormal = pPacket
@m_nNextNormal = @m_nNextNormal + 1
return @m_nNextNormal - 1
end

# Updated: by HardPCM date unknown.
def NextFaceABC(pPacket)
@m_pTriangle = pPacket
@m_nNextTriangle = @m_nNextTriangle + 1
return @m_nNextTriangle - 1
end


# Updated: by HardPCM date unknown.
def NextMaterial(pPacket)
# Search an existing material
a_nIndex = @m_nNextMaterial - 1
while a_nIndex > -1
a_pTempPacket = @m_pMaterial
if a_pTempPacket == pPacket
return a_nIndex
end
a_nIndex = a_nIndex - 1
end

# Create a new material
@m_pMaterial = pPacket
@m_nNextMaterial = @m_nNextMaterial + 1
return @m_nNextMaterial - 1
end

# Updated: by HardPCM date unknown.
def VectorFromSketchup(pVector)
return
end

# Updated: by HardPCM date unknown.
def VectorUvFromSketchup(pVector)
return
end
# Updated: 24-September-2010
def WriteHeader
@m_FileWritter.WriteToFile("*3DSMAX_ASCIIEXPORT\r\n")
@m_FileWritter.WriteToFile("*COMMENT Muvizu ASE Exporter.\r\n")
@m_FileWritter.WriteToFile("*COMMENT Based on HardPCM'S ASE output plugin for Sketchup (HSKP2UNR.rb)\r\n")
end

#Updated: 24-September-2010
def WriteMaterials

# Write the material header.
@m_FileWritter.WriteToFile("*MATERIAL_LIST {\r\n")
@m_FileWritter.WriteToFile("*MATERIAL_COUNT 1\r\n")
@m_FileWritter.WriteToFile(" *MATERIAL 0 {\r\n")
@m_FileWritter.WriteToFile(" *MATERIAL_NAME \"MUVIZU_ASE_TEXTURE\"\r\n")
@m_FileWritter.WriteToFile(" *MATERIAL_CLASS \"Multi/Sub-Object\"\r\n")

# Write the number of sub-materials to expect.
@m_FileWritter.WriteToFile(" *NUMSUBMTLS #{"%i" %(@m_nNextMaterial)}\r\n")

# Output sub-material list.
a_nIndex = 0
a_nCount = @m_nNextMaterial
while (a_nIndex < a_nCount)

a_pPacket = @m_pMaterial

@m_FileWritter.WriteToFile(" *SUBMATERIAL #{"%i" %(a_nIndex)} {\r\n");
@m_FileWritter.WriteToFile(" *MATERIAL_NAME \"#{"%s" %(a_pPacket)}\"\r\n");
@m_FileWritter.WriteToFile(" *MATERIAL_CLASS \"Standard\"\r\n");
@m_FileWritter.WriteToFile(" *MAP_DIFFUSE {\r\n");
@m_FileWritter.WriteToFile(" *MAP_CLASS \"Bitmap\"\r\n");
@m_FileWritter.WriteToFile(" *BITMAP \"#{"%s" %(a_pPacket)}\"\r\n");
@m_FileWritter.WriteToFile(" *UVW_U_OFFSET 0.0\r\n");
@m_FileWritter.WriteToFile(" *UVW_V_OFFSET 0.0\r\n");
@m_FileWritter.WriteToFile(" *UVW_U_TILING 1.0\r\n");
@m_FileWritter.WriteToFile(" *UVW_V_TILING 1.0\r\n");
@m_FileWritter.WriteToFile(" }\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")
@m_FileWritter.WriteToFile("}\r\n")
end

# Updated: 24-September-2010
def WriteGeometryBegin
@m_FileWritter.WriteToFile("*GEOMOBJECT {\r\n")
@m_FileWritter.WriteToFile(" *NODE_NAME \"#{"%s" %(@m_nModelName)}\"\r\n")
@m_FileWritter.WriteToFile(" *NODE_TM {\r\n")
@m_FileWritter.WriteToFile(" *NODE_NAME \"#{"%s" %(@m_nModelName)}\"\r\n")
@m_FileWritter.WriteToFile(" }\r\n")
@m_FileWritter.WriteToFile(" *MESH {\r\n")
@m_FileWritter.WriteToFile(" *TIMEVALUE 0\r\n")
end

# Updated: 24-September-2010
def WriteGeometryColBegin
@m_FileWritter.WriteToFile("*GEOMOBJECT {\r\n")
@m_FileWritter.WriteToFile(" *NODE_NAME \"UCX_#{"%s" %(@m_nModelName)}\"\r\n")
@m_FileWritter.WriteToFile(" *NODE_TM {\r\n")
@m_FileWritter.WriteToFile(" *NODE_NAME \"UCX_#{"%s" %(@m_nModelName)}\"\r\n")
@m_FileWritter.WriteToFile(" }\r\n")
@m_FileWritter.WriteToFile(" *MESH {\r\n")
@m_FileWritter.WriteToFile(" *TIMEVALUE 0\r\n")
end

# Updated: 24-September-2010
def WriteVertexXYZ
@m_FileWritter.WriteToFile(" *MESH_NUMVERTEX #{"%i" %(@m_nNextVertex)}\r\n")
@m_FileWritter.WriteToFile(" *MESH_NUMFACES #{"%i" %(@m_nNextTriangle)}\r\n")
@m_FileWritter.WriteToFile(" *MESH_VERTEX_LIST {\r\n")

a_nIndex = 0
a_nCount = @m_nNextVertex
while (a_nIndex < a_nCount)
a_pPacket = @m_vVertex
@m_FileWritter.WriteToFile(" *MESH_VERTEX #{"%i" %(a_nIndex)} #{"%+013.6f" %(a_pPacket)} #{"%+013.6f" %(a_pPacket)} #{"%+013.6f" %(a_pPacket)}\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")

end

# Updated: 24-September-2010
def WriteFaceVertexXYZ
@m_FileWritter.WriteToFile(" *MESH_FACE_LIST {\r\n")

a_nIndex = 0
a_nCount = @m_nNextTriangle
while (a_nIndex < a_nCount)
a_pPacket = @m_pTriangle
@m_FileWritter.WriteToFile(" *MESH_FACE #{"%i" %(a_nIndex)}: A: #{"%i" %(a_pPacket)} B: #{"%i" %(a_pPacket)} C: #{"%i" %(a_pPacket)} AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING 0 *MESH_MTLID #{"%i" %(a_pPacket)}\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")
end

# Updated: 24-September-2010
def WriteVertexUV
@m_FileWritter.WriteToFile(" *MESH_NUMTVERTEX #{"%i" %(@m_nNextVertexUV)}\r\n")
@m_FileWritter.WriteToFile(" *MESH_TVERTLIST {\r\n")

a_nIndex = 0
a_nCount = @m_nNextVertexUV
while (a_nIndex < a_nCount)
a_pPacket = @m_vVertexUV
@m_FileWritter.WriteToFile(" *MESH_TVERT #{"%i" %(a_nIndex)} #{"%+013.6f" %(a_pPacket)} #{"%+013.6f" %(a_pPacket)} 0.000000\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")
end

# Updated: 24-September-2010
def WriteFaceVertexUV
@m_FileWritter.WriteToFile(" *MESH_NUMTVFACES #{"%i" %(@m_nNextTriangle)}\r\n")
@m_FileWritter.WriteToFile(" *MESH_TFACELIST {\r\n")

a_nIndex = 0
a_nCount = @m_nNextTriangle
while (a_nIndex < a_nCount)
a_pPacket = @m_pTriangle
@m_FileWritter.WriteToFile(" *MESH_TFACE #{"%i" %(a_nIndex)} #{"%i" %(a_pPacket)} #{"%i" %(a_pPacket)} #{"%i" %(a_pPacket)}\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")
end

# Updated: 24-September-2010
def WriteFaceNormals
@m_FileWritter.WriteToFile(" *MESH_NORMALS {\r\n")

a_nIndex = 0
a_nCount = @m_nNextTriangle
while (a_nIndex < a_nCount)
a_pPacket = @m_pTriangle
@m_FileWritter.WriteToFile(" *MESH_FACENORMAL #{"%i" %(a_nIndex)} #{"%+013.6f" %(a_pPacket)} #{"%+013.6f" %(a_pPacket)} #{"%+013.6f" %(a_pPacket)}\r\n");
a_nID = a_pPacket
a_pTP = @m_vVertex
@m_FileWritter.WriteToFile(" *MESH_VERTEXNORMAL #{"%i" %(a_nID)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)}\r\n");
a_nID = a_pPacket
a_pTP = @m_vVertex
@m_FileWritter.WriteToFile(" *MESH_VERTEXNORMAL #{"%i" %(a_nID)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)}\r\n");
a_nID = a_pPacket
a_pTP = @m_vVertex
@m_FileWritter.WriteToFile(" *MESH_VERTEXNORMAL #{"%i" %(a_nID)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)} #{"%+013.6f" %(a_pTP)}\r\n");
a_nIndex = a_nIndex + 1
end

@m_FileWritter.WriteToFile(" }\r\n")
end

# Updated: 24-September-2010
def WriteGeometryFinish
@m_FileWritter.WriteToFile(" }\r\n")
@m_FileWritter.WriteToFile(" *MATERIAL_REF 0\r\n")
@m_FileWritter.WriteToFile("}\r\n")
end

#Updated 24-September-2010
def ProcessFace(pFace, pMaterial, pTransformations)

# Extract the mesh.
a_pMesh = pFace.mesh 7

# Transform the mesh.
a_pMesh.transform! pTransformations

# Eextract material info.
a_nMaterialU = 1.0
a_nMaterialV = 1.0
# Load default material name and bmp file path. Note the file toto.bmp
# does not exist unless you create it. For Muvizu it is recommended to
# create this file for the best results.
a_sTexture = "Engine.DefaultTexture"
a_pTexturePath = "C:\\ut3\\toto.bmp"

# Make sure that the material reference exists before processing anything else.
if pMaterial != nil

# If the material has a name in Sketchup use that instead of the default.
if pMaterial.name != ""
a_sTexture = pMaterial.name
end if

# Check that the material has a texture (and is not just a colour) before ensuring that
# the texture filename reference exists and has content. Use the actual path and filename
# for that texture / material instead of the default toto.bmp
if pMaterial.texture != nil
if pMaterial.texture.filename != nil
if pMaterial.texture.filename != ""
a_pTexturePath = pMaterial.texture.filename
end
end
end

# Take a reference to the texture object as well.
a_pTexture = pMaterial.texture
end

# Pack the material for later writting to file.
a_pMatPack =
a_nMaterialID = self.NextMaterial(a_pMatPack)

# Extract the triangle normal.
a_vNormal = pFace.normal
a_nNx = a_vNormal.x
a_nNy = a_vNormal.y
a_nNz = a_vNormal.z

# Loop for each triangle in the face.
a_nIndex = 1
while (a_nIndex <= a_pMesh.count_polygons)

# Extract the triangle indexes.
a_pPolygon = a_pMesh.polygon_at a_nIndex

# Extract the triangle vertex.
a_pVa = self.VectorFromSketchup(a_pMesh.point_at a_pPolygon)
a_pVb = self.VectorFromSketchup(a_pMesh.point_at a_pPolygon)
a_pVc = self.VectorFromSketchup(a_pMesh.point_at a_pPolygon)

a_pVa = a_nNx
a_pVa = a_nNy
a_pVa = a_nNz

a_pVb = a_nNx
a_pVb = a_nNy
a_pVb = a_nNz

a_pVc = a_nNx
a_pVc = a_nNy
a_pVc = a_nNz

a_nVa = self.NextVertexXYZ(a_pVa)
a_nVb = self.NextVertexXYZ(a_pVb)
a_nVc = self.NextVertexXYZ(a_pVc)

# Extract the texture coordinates.
a_pTa = self.VectorUvFromSketchup(a_pMesh.uv_at a_pPolygon,a_pPolygon)
a_pTb = self.VectorUvFromSketchup(a_pMesh.uv_at a_pPolygon,a_pPolygon)
a_pTc = self.VectorUvFromSketchup(a_pMesh.uv_at a_pPolygon,a_pPolygon)
a_nTa = self.NextVertexUV(a_pTa)
a_nTb = self.NextVertexUV(a_pTb)
a_nTc = self.NextVertexUV(a_pTc)

# Convert to face,
a_pFace =
a_nFace = NextFaceABC(a_pFace)
# --- next triangle ------------------------------------------------
a_nIndex += 1
end
end

# Updated 24-September-2010
def WriteGeometry
# Write out all parts for the geometry model.
self.WriteGeometryBegin
self.WriteVertexXYZ
self.WriteFaceVertexXYZ
self.WriteVertexUV
self.WriteFaceVertexUV
self.WriteFaceNormals
self.WriteGeometryFinish
end

# Updated 24-September-2010
def WriteCollision
# The only difference between WriteCollision and WriteGeometry is that the method
# WriteGeometryColBegin is called, which does the same as WriteGeometryBegin but
# prefixes the name of the object with UCX for a collision object.
self.WriteGeometryColBegin
self.WriteVertexXYZ
self.WriteFaceVertexXYZ
self.WriteVertexUV
self.WriteFaceVertexUV
self.WriteFaceNormals
self.WriteGeometryFinish
end

end

class MuvizuASEExporter

#Updated: 24-September-2010
def About

UI.messagebox("Muvizu ASE Exporter

Original work by Raphael Couturier (HardPCM) with HSKP2UNR
HardPCM's Google Sketchup Exporter to T3D/PSK/ASE/OBJ format
for UT3/UT2K4/UT2K3/UT99 game engines. Version 0.9.8 May 26nd 2009
was used as the foundation. The aim of this update is to provide
a more optomised exporter for use with Muvizu (http://www.muvizu.com)

Change List / History

# 0.0.1 - Write out texture filename and path for ASE submaterial tag *BITMAP "..."
# 0.0.2 - Generate collision mesh automatically. Copy geometry into another GEOMODEL object prefixing object name with UCX. Collision was too complex.
# 0.0.3 - Removed non-essential parts for Muvizu input (import, and all export except ASE functions).
# 0.0.4 - Limited output to components only. Remove all handling of groups.
# 0.0.5 - UI to allow selection of one component as geometry and one component as collision.
# 0.0.6 - Renamed classes and methods to avoid dependency or interfearance with the original plugin.
# 0.0.7 - Refined UI to reduce and report errors.
# 0.0.8 - Updated about text and source comments for completeness.

Freeware under the GNU Lesser General Public License version 2 or later.

Special thanks to:

- Raphael Couturier (HardPCM) for the original work.

- Jim Skivington for testing the early attempts at the changes.

How to install:

filename is: \"MuvizuASEExporter.rb\"
and put it in the directory like
\"C:\Program Files\Google\Google SketchUp X\Plugins\"

How this works:

Everything is in inch OK!!!
So 512 inch unit = 512 unreal unit.
This apply to the model size and the material size.

Muvizu supports both single and double sided objects. This means you do not need to worry about WHITE or BLUE mode for faces, however to achieve the best results from modelling for a games engine it is recommended that use only use signle sided objects. The recommendation is for WHITE (when all faces of your object look WHITE on the outside). If you do not then some faces will only be visible inside your object. Each face needs to have a texture applied to it.

http://www.muvizu.com/

" , MB_MULTILINE , "Muvizu ASE Exporter")

end

# Updated: 24-September-2010
def CountComponents deffs = nil
count = 0
if deffs != nil
deffs.each {|x|
if x.is_a? Sketchup::ComponentInstance
count += 1
end
}
end
# Returns the total number of available components.
return count
end

# Updated: 24-September-2010
def GetFirstComponent deffs = nil
hasFirst = false
first = ""
if deffs != nil
deffs.each {|modelref|
if modelref.is_a? Sketchup::ComponentInstance
# Get the name of the first component for default selection on the Export Options dialog box.
if hasFirst == false
deff = modelref.definition
first = deff.name
hasFirst = true
end
end
}
end
return first
end

# Updated: 24-September-2010
def GetDropDownList deffs = nil
listGeometry = ""
if deffs != nil
deffs.each {|x|
if x.is_a? Sketchup::ComponentInstance
# Go through all components that exist in the sketchup model and append each ones name to a string for use in a combo box.
deff = x.definition
listGeometry += "#{"%s" %(deff.name)}|"
end
}
end
return listGeometry
end

# Updated: 24-September-2010
def GetDropDownListCollision deffs = nil
# Always return the "None" option.
listCollision = "None - Muvizu generated collision"
if deffs != nil
# Append the None option to the list generated of existing components.
listCollision += "|#{"%s" %(self.GetDropDownList deffs)}"
end
return listCollision
end

# Updated: 24-September-2010
def GetEntityRefByName deffs = nil, theName = ""
# Return nil on error.
modelentity = nil
# Make sure we have valid references.
if deffs != nil
deffs.each {|modelref|
if modelref.is_a? Sketchup::ComponentInstance
deff = modelref.definition
# Go through all entities, check that it is a ComponentInstance and return reference to the one that matches the provided name,
if deff.name == theName
modelentity = modelref
end
end
}
end
return modelentity
end

def getMaterialFileNames(theMaterials)
allTextures = ""
theMaterials.texture.each { | text |
if theMaterials.texture != nil
allTexture += "#{"%s" %(theMaterials.texture.filename)}|"
end
}
return allTextures
end

def findDuplicate(arrayMaterials, check)
foundDup = false
arrayMaterials.each { | material |
if material.texture.filename == check.texture.filename
foundDup = true
end
}
return foundDup
end

def ProcessForTextures(pCurrentNode, pParent)

#tmpTextures = Array.new
# Explode components or groups so we can process each face within it.
if(pCurrentNode.class == Sketchup::Group)
pCurrentNode = pCurrentNode.entities
elsif(pCurrentNode.class == Sketchup::ComponentInstance)
pCurrentNode = pCurrentNode.definition.entities
end

for a_Entity in pCurrentNode
#UI.messagebox "Processing entities"
if(a_Entity.class == Sketchup::Face and a_Entity.layer.visible?)
# Identify the material on the face being examined.
a_pMaterial = a_Entity.material
#UI.messagebox "Checking materials"
if self.findDuplicate(@allMaterials, a_pMaterial) == false
@allMaterials.push(a_pMaterial)
#tmpTextures += "#{"%s" %(a_pMaterial.texture.filename)}|"
#UI.messagebox "#{"%s" %(a_pMaterial.texture.filename)}|"
end
end
end

for a_Entity in pCurrentNode
# If there is a component within the current component or group then recursively process that component as well.
if((a_Entity.class == Sketchup::ComponentInstance or a_Entity.class == Sketchup::Group) and a_Entity.layer.visible?)
self.ProcessForTextures(a_Entity, pCurrentNode)
end
end
end

# Updated: 24-September-2010
def ExportOptionMenu(firstName, geoList, colList)
a_pMenuResult = Array.new
# Check there is at least one component to list in the export options menu.
if geoList != nil && geoList.length > 0
# Prepare the export options menu.
a_pMenuDropdowns =
a_pMenuPrompts =
# Display Export Options
a_pMenuResult = UI.inputbox a_pMenuPrompts, , a_pMenuDropdowns, "Export options"

# Only progress if the user has selected Ok (true)
if a_pMenuResult != false
if a_pMenuResult == a_pMenuResult
a_pMenuResult = Array.new
a_pMenuResult = -1
end
end
else
a_pMenuResult = -2
end
return a_pMenuResult
end

# Updated: 24-September-2010
def ExportASE
# Get the entities available in the current model
model = Sketchup.active_model
deffs = model.entities

# Initialise variables for the menu and identifying the model and collision to export.
a_pMenuA = ""
a_pMenuB = ""
first = ""
exportCollision = true

# Get the menu options.
first = self.GetFirstComponent deffs
a_pMenuA = self.GetDropDownList deffs
a_pMenuB = self.GetDropDownListCollision deffs

# Validation flags.
readyToExport = false
progressExport = true
continueResult = 0

while readyToExport == false
a_pMenuResult = self.ExportOptionMenu(first, a_pMenuA, a_pMenuB)
if a_pMenuResult != false
if a_pMenuResult == -2
UI.messagebox "There are no components in your sketchup model to export. Select the groups, faces or edges you wish to export then right click and do \"Make Component\""
readyToExport = true
progressExport = false
elsif a_pMenuResult == -1
continueResult = UI.messagebox ("You have selected the same component for the geometry mesh and the collision mesh. This is not recommended, do you wish to progress?", MB_YESNO, "Are you sure?")
if continueResult == 6
readyToExport = true
progressExport = true
end
else
readyToExport = true
end
else
readyToExport = true
progressExport = false
end
end

# Begin export if all options are ready.
if progressExport == true
modelname = a_pMenuResult
modelindex = a_pMenuResult
collisionindex = a_pMenuResult

# Check if collision is to be exported or not.
if collisionindex == "None - Muvizu generated collision"
exportCollision = false
end

# Prepare save path.
a_sExportPath = UI.savepanel("Export Model to ASE", "" , "#{"%s" %(modelname)}.ase")

# Only progress to generating the ASE file if a save path and name have been selected.
if a_sExportPath != nil

# Find a reference to the object that contains the model and collsion entities.
modelentity = Sketchup::Entity
collisionentity = Sketchup::Entity
modelentity = self.GetEntityRefByName(deffs, modelindex)

# Only get the collision entity ref if collision is to be generated.
if exportCollision == true
collisionentity = self.GetEntityRefByName(deffs, collisionindex)
else
collisionentity = nil
end

# Create the file handle. File handle is opened within initialize here.
aFileWritter = FileWritter.new a_sExportPath

# Prepare the data processors that will convert the Sketchup model into ASE format.
a_pProcessor = ExporterDataASE_UTX.new(aFileWritter, modelname)

# Only create a data processor if collision is to be generated.
if exportCollision == true
b_pProcessor = ExporterDataASE_UTX.new(aFileWritter, modelname)
else
b_pProcessor = nil
end

# Finally send the processors and entity references to the iterator to generate the final output ASE file.
a_pIteratorer = IteratorerDataT3D_UTX.new(modelentity, a_pProcessor, collisionentity, b_pProcessor, a_sExportPath)
a_pIteratorer.Start

# Close the file handle.
aFileWritter.CloseFile
else
UI.messagebox "No save to path or filename specified for export. Operation cancelled."
end
end
end
end

file_loaded(".rb")

if(not file_loaded?("MuvizuASEExporter.rb"))
MZAE = MuvizuASEExporter.new
pMenuA = UI.menu("Plugins").add_submenu("Muvizu ASE Exporter")
pMenuA.add_item("Export ASE Format") { (MZAE.ExportASE) }
pMenuA.add_item("About Muvizu ASE Exporter") { (MZAE.About) }
else
UI.messagebox "There was an error loading the Muvizu ASE Exporter."
end
edited by urbanlamb on 28/03/2013
2013/3/28 18:50:42
ASE importer link hiya there is a link on the 3d gallery if you choose right click and download it saves it. I have no clue if they are the same script but here is the gallery link

http://muvizu.com/Gallery/#&&m=3D
2013/3/28 2:35:27
Problems uploading / commenting on videos If you uploaded to youtube directly then it wont appear here you need to go to your account profile on this site and choose upload in that case.


If you uploaded from this site then it worked and it has to wait to be moderated so it takes a day or two to appear on this site.
2013/3/26 23:08:34
upload a video help please yes it will take some time to appear especially at present they are busier then usual with the launch of muvizu play which has a major upgrade (and a new website). As long as its actually muvizu its fine its mostly to prevent ads and 'pron' and erroneous things you know selling viagra etc from appearing

basically if you upload weekends you have to wait till monday/tuesday and during the week there is a 24 hour delay depending on time of day uploaded.
edited by urbanlamb on 26/03/2013
2013/3/26 22:29:40
upload a video help please If you uploaded from here and its on youtube then likely it has not been moderated yet because they moderate all the videos to prevent things from appearing on this site that should not

otherwise ..

You login from here and look at your profile and choose upload on your muvizu profile and then it will post to youtube on the username you chose there. If you want to leave it up you can repost from here but you will have to change the filename of your video as youtube will recognize it as a duplicate and not upload or you can just delete the youtube one.
2013/3/26 17:10:43
Can Wheel of car or motorcycle spinning? and Yes the destoyable building I have done this or version of it. Make several versions of the object your trying to destory and use stop motion is about the only way to do in muvizu. Put all the cameras in place and film some frames, do a change to the model film another few frames and do this until your building is destroyed and edit in a video editor. Make sure there are no changes to the cameras and that if you do use camera switched you do it at a frame where a distinct change is happening. It takes awhile and then in your video editor you need to assemble this frame by frame until you get a smooth movement that looks realistic.
2013/3/25 19:53:03
New Wardrobe yes this is true so um "when do we get the new wardrobe" ? Big Grin
2013/3/25 19:51:06
Edit Environment sloped sky backgrounds? yes this is what I would probably do make a cube or something and texture the inside of it and plop it into the muvizu dome to make it all look okay

since the textures don't distort so much its also probably the least fussy method me thinks

and me you know being a lazy person at heart would pick the easiest way
edited by urbanlamb on 25/03/2013
2013/3/25 18:56:09
New Wardrobe They are probably holding it back for the muvizu live launch. Along with any of the other tidbits they have mentioned.
2013/3/24 20:52:38
help - PUBLISHING VIDEO - please! Dreeko wrote:
urbanlamb wrote:
I cant remove the watermark!


Patience... you will be able to very soon (so we hear!)

Thumbs Up
2013/3/24 18:21:20
help - PUBLISHING VIDEO - please! Hey can someone tell me how to remove the watermark? I figured out about that greyed out button but for the life of me I cant remove the watermark!
2013/3/23 23:27:49
CGI and faces. The future of Muvizu???? yes I was doing graphics when I was 20 and I remember the bits and then I got a hand scanner it was so much awesomness no more little squares that was a long time ago. For me I just like to oogle. I personaly dont know if anyone is truly trying to replace or mimic real life just add to it. the concept of games in rooms and in 3D etc (holodec type stuff) is something that many people work on but I dont consider it replacing anything only adding to it.

For me the fact that we can create such complex things on pc's now as just a hobby its mind boggling considering the first PC I ever touched was a commodore pet which had no real language to run it other then machine language and no software .. and the storage device was a cassette tape lol I remember those tapes and my dad sitting in the basement opening up casettes and combining them and rolling up the spool manually and putting it in a new case haha

I was ... maybe 12 ? 16? I cant remember now.. and the first pc game I played was on a black and white tv set and we had a square that myself and a friend bounced back and forth using two bars .. I think it was called ping pong.. lol

Oh and when I took computer programming in high school I was using punch cards.. and I used to go home with my shoeboxes of punch cards to fill out at home and bring them back to school and wait a week to see where my program crashed and then having to fill in all those cards all over again..

.. I feel.. old..
edited by urbanlamb on 23/03/2013
2013/3/23 1:32:24
Use unreal maps with Muvizu... This is just a generic answer for modelling in general but your going to likely have to redo all the materials. Save the file as is. Choose a building and delete the rest of it (i would import it building by building muvizu is intended for you to build the sets from the ground up) save that building under a different name. Then You will have to redo materials so that you don't get any errors inside muvizu and associate the uv maps to the new materials so that the textures work. If that is the obj file its already triangulated and I dont know how the exporter works but usually there is an option to not recalculate faces and whatnot which would help keep it from increasing in size.

This is a huge task and often its simply easier and faster just to do it from scratch although the model is already looking okay (assuming its only got one layer of mesh)

I personally would use the file as a visual aid to recreate my own from scratch building by building. Your going to need to learn about collision inside muvizu in order for this to import.
edited by urbanlamb on 23/03/2013
2013/3/22 18:51:16
CGI and faces. The future of Muvizu???? hehe I dont know about muvizu as I dont know what their future plans are like but iclone is very close. Muvizu would need to intoroduce more pupeteering we can't get into that creepy close part until we are given more control but yeah graphics are moving forward making it more possible
2013/3/22 0:27:16
Use unreal maps with Muvizu... lol that is huge even to start with. Obj files are often not triangulated ase exporters will double the face count of an obj file. Personally I would say you need to optimize that model for use it seems rather large I would assume it has an inside as well? you might want to start deleting things inside. Whatever happens your going to need to reduce the obj face count. I dont know what your using to import if its sketchup maybe someone else can explain. I also wonder if all these parts are joined into one mesh as well. Muvizu requires everything to be on single continuous mesh. From the sound of it this is a unit that has moving parts and other things.

Anyhow so that is where the size change often are and depending on how the textures and materials are being handled. This can add more. Not knowing how its built to start with its hard to know what all the causes of the size are however 60mb for a single item is well massive
2013/3/21 18:40:07
alpha sort bug Hi not really sure where to put this.. its a visual bug.. annoying but only if you do something to create it

anyhow I wasn't going to post this thinking "oh they probably are aware" but changed my mind just in case.

I created some doors all one unit with handles that are solid and a solid door frame and then a large semi transparent glass window part. Anyhow your alphas are not sorting properly

Anyhow just posting in case you were not aware but you probably are but just in case ..

2013/3/21 17:22:06
Use unreal maps with Muvizu... hi there

if you have the obj file you can import via blender as well using the plugin

they just upgraded their udk plugin (i liked the older one) this one seems to crash more anyhow it works


https://code.google.com/p/ase-export-vmc/

These guy use unreal engine but they are not part of that commercial operation that created unreal tournament which is actually Epic games. All that stuff is copyright by epic games meaning they dont hold a license to use their architecture. Muvizu is muvizu and its owned and created by digimania. To be honest importing into muvizu from other engines is actually pretty easy. Unreal engine is simply that an engine anyone can purchase a copy to it and make their own products from it.

http://www.unrealengine.com/licensing/faq/
edited by urbanlamb on 21/03/2013
2013/3/21 6:37:19
Coming Soon... Two grannies and a horse! Onwards to the next set ..

2013/3/19 18:50:41
I need a mirror please! Yes a mirror in 3D is an interesting trick (if you want to try this) it depends I guess on the way your using your mirror

to have a reflection here is "the trick" you create screen in the mirror in this case since this is a "new thing" for you probably the best way is to size down their background to fit. Place it inside the frame of the mirror whatever you choose

Then have your character do its act in front of the mirror and record that video with a camera facing the character from behind that mirror. Then use the background to play the video back and then do the action again (for real) with the cameras where you like them so that the actions in the mirror seem to be reflected from the glass.

You can make the mirror frame from anything as long as you can downsize and set the background piece inside it.



I dont know if fazz's method works I am old and stuck in my ways and this is what I learned years back :/
edited by urbanlamb on 19/03/2013
2013/3/18 16:59:18
ageing woman? if you open up the timeline there are are triangles you need to drag they are both set at 0.0 so you need to pull one over to the right for the length of video you need when you drag them a pink line will appear. You might also run a few questions when actually publishing the video but I will leave that until you actually run into the problems which are pretty common but some people dont encounter them so maybe you wont
pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86