Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@name MODULE_ComplexMeshLoader
- --@author artybyte
- --@client
- -- module for coroutine loading of complex objects consists of multiple meshes with different properties and functions
- --[[
- made ON and FOR StarfallEx
- Guide :: how to use this module READ THIS BEFORE USE
- This module should to use in clientside case. It runs on client.
- >> INCLUDING
- to include this module add these lines to start of your chip:
- >>
- --@include module/module_complexmeshloader.txt
- require('module/module_complexmeshloader.txt')
- >>
- Now it's ready to go. Then you should get the module table. add in code this line
- ComplexMeshLoader = MODULE__GetComplexMeshLoader() -- get module table
- >> USAGE
- now we ready to use it. Using of module splitted to some steps
- ==================================================================================================================================================================================
- 1) set your host URL of models.
- ComplexMeshLoader.SetHostURL("http://55.55.55.55:22222/") (slash ("/") symbol is NECESSARY in this URL. Keep it in mind.
- when module will start download models, it will concatenate this URL + "obj_name"
- ==================================================================================================================================================================================
- 2) set base parent of your meshes. If you will not provide parent_params, hologram will be parented to base parent.
- (UNNECESSARY)
- chip() is default.
- ComplexMeshLoader.SetBaseParent(entity(101))
- ==================================================================================================================================================================================
- 3) push all your mesh parts to module. Example:
- ComplexMeshLoader.PushComponent( {
- obj_name="vehicle_body.obj",
- mat="models/shiny",
- local_pos=Vector(0, 0.5, 14.3),
- local_ang=Angle(90,0,0),
- color=Color(100, 200, 200),
- part_name="body"
- } )
- About fields of part (component):
- 3.1) obj_name (NECESSARY) - string name of your .obj file. It should match with file name on provided host (URL)
- 3.2) mat (UNNECESSARY) - string of material of mesh. (default game materials or addon materials)
- 3.3) local_pos (UNNECESSARY) - local position offset relatively the Base Parent. 0, 0, 0, if not provided
- 3.4) local_ang (UNNECESSARY) - local angle offset relatively the Base Parent. 0, 0, 0 if not provided
- 3.5) color (UNNECESSARY) - color of mesh. 255, 255, 255, 255 if not provided
- 3.6) part_name (UNNECESSARY) - UNIQUE part name. It should be always unique for each part. if not provided, it will set as "mesh_part_(ORDINAL INTEGER BY IT'S ORDER IN COMPONENTS TABLE)
- 3.7) scale (UNNECESSARY) - scale of holo/mesh. 1, 1, 1 if not provided
- 3.8) create_callback (UNNECESSARY) - function value that will be called after hologram will be created and pasted. callback will run with 1 argument as it's hologram.
- 3.9) parent_params (UNNECESSARY) - table value. If not provided: mesh will be parented to Base Parent. If provided:
- If you no provide "part_parent" string, module will create parent holo to this part via given .local_pos and .local_ang values.
- If you PROVIDE "part_parent" - mesh will be parented to existing part by it's name after all pasting process.
- example:
- parent_params={ -- this param will parent current part to part "right_door" that you declared.
- part_parent="right_door"
- }
- parent_params={ -- this param will create new holo as parent for this current part. In this case holo will contain "parent" field and you can get it like Holo["parent"]
- local_pos=Vector(0,0,10), -- UNNECESSARY. default is 0, 0, 0
- local_ang=Angle(0,90,0), -- UNNECESSARY. default is 0, 0, 0
- scale=Vector(0,0,0) -- UNNECESSARY. default is 0.25, 0.25, 0.25
- }
- 3.10) render_mode (UNNECESSARY) -- the render mode for this holo. See Gmod Lua "RENDERMODE" default ENUMs. If not provided - holo will have normal RenderMode.
- ==================================================================================================================================================================================
- 4) Declare function that will execute only once after all downloading & pasting process will finish. (optionally)
- ComplexMeshLoader.SetOnPasteDoneOneTimeFunction( function()
- print("hello world") -- this code will execute once after all holos(meshes) will paste
- end )
- ==================================================================================================================================================================================
- 5) Declare function that will start to execute constantly after all downloading & pasting process will finish. (optionally)
- ComplexMeshLoader.SetOnPasteDoneContinuousFunction( function()
- print("hello world again") -- this code will execute each tick inside Think hook.
- end )
- ==================================================================================================================================================================================
- 6) **OPTIONALLY** you can disable drawing of 3D2D loading panel. Just call
- ComplexMeshLoader.DisableDownloadProgressHUD()
- ==================================================================================================================================================================================
- 7) and finally we can start the module.
- ComplexMeshLoader.Initialize()
- ==================================================================================================================================================================================
- Module will download all meshes via coroutine "threads" and then it will be transformed to holograms and pasted with provided parameters.
- Ensure your host address is match with allowed urls on server you playing. By default is dropbox, googleDrive etc. (popular hostings)
- -- [ MESH LOADING MODES ] --
- BE CAREFULL WITH PASTING SLASH IN LOADING PATH! IT SHOULDN'T DOUBLES WITH SLASH IN OBJ NAME PROVIDED IN PART TABLES!!!!
- IF YOU WANT TO LOAD MODELS LOCALLY, CALL THIS FUNCTION BEFORE INITIALIZATION:
- ComplexMeshLoader.SetLoadLocalModels()
- Actually you need to provide local path to load. Make it too via function: (before init too)
- ComplexMeshLoader.SetLocalModelsPath(string path)
- IF YOU WANT TO PROVIDE READY RAW OBJ MESHES TABLE, JUST CALL FUNCTION
- ComplexMeshLoader.SetReadyTable(table)
- provide table of strings. This table should be like
- tbl['obj_part_name.obj'] = "RAW OBJ VERTICES AND FACES FILE as string"
- ***
- also you can use this Python converter to get ready structure of model
- https://pastebin.com/gWB96Yqj
- usage: place script into .obj folder. then set variable "module_name" to your preferable name.
- then run script and get created folder with your module name to your "GarrysMod/data/starfall/" directory.
- then include & require that structure via "entry_point.txt" file LIKE:
- -- @include moduleName/entry_point.txt
- local obj_txt_Tbl = require('moduleName/entry_point.txt')
- >>obj_txt_Tbl will be contain all .obj meshes from that folder with .py script and keys is original obj file names.
- Enjoy!
- *** VERY IMPORTANT ***
- DO NOT CALL ComplexMeshLoader.SetLoadLocalModels() and ComplexMeshLoader.SetReadyTable(table) TOGETHER!!!! use these modes independently.
- >> useful info
- to get holos to interact with (for example in continuous function) just get it like
- ComplexMeshLoader.HologramCollection["right_door_exterior"]
- or if you attach it to another part or created holo - just
- ComplexMeshLoader.HologramCollection["right_door_exterior"].parent
- end of guide
- ]]--
- local ComplexMeshLoader = { }
- ComplexMeshLoader.host_address = "www.google.com"
- ComplexMeshLoader.components = { } -- it will store array structure of all needed holograms to be created with individual parameters (also with callback functions)
- ComplexMeshLoader.current_loaded_mesh = { } -- TEMP remove after
- ComplexMeshLoader.DownloadedObjData = { } -- stores raw downloaded obj model objects
- ComplexMeshLoader.HologramCollection = { } -- it will store done finished and transformed holograms
- ComplexMeshLoader.ConversionPool = { }
- ComplexMeshLoader.PartsParentPool = { }
- ComplexMeshLoader.HologramsRenderBounds = {Vector(-2000), Vector(2000)}
- ComplexMeshLoader.default_holo_model = "models/holograms/sphere3.mdl"
- ComplexMeshLoader.TOTAL_LOADING_DONE = false
- ComplexMeshLoader.YieldConversionPoolExecution = false
- ComplexMeshLoader.SetModuleModeToLoadLocalTxtModels = false
- ComplexMeshLoader.InitDrawDownloadingProgress = true
- ComplexMeshLoader.CURRENT_LOADING_ID = 1
- ComplexMeshLoader.ModelPasteInterval = 0.1 -- IN SECONDS
- ComplexMeshLoader.QuotaOverloadCooldown = 0.1 -- IN SECONDS
- ComplexMeshLoader.ConversionPoolWorker = { } -- coroutine
- ComplexMeshLoader.ReadyMeshTable = nil
- ComplexMeshLoader.LoadingPanelScale = 0.1
- ComplexMeshLoader.LastAverageQuota = 0
- ComplexMeshLoader.ReplaceNameWhat = nil
- ComplexMeshLoader.ReplaceNameTo = nil
- ComplexMeshLoader.LocalModelLoadingPath = 'obj_models'
- ComplexMeshLoader.LoadingPanelFont = render.createFont("Roboto", 64, 400, true)
- ComplexMeshLoader.VisualDecorHolo = holograms.create(chip():localToWorld(Vector(0, 0, 300)), chip():localToWorldAngles(Angle()), "models/holograms/icosphere2.mdl")
- ComplexMeshLoader.VisualDecorHolo:setScale(Vector(3, 3, 3))
- ComplexMeshLoader.VisualDecorHolo:setMaterial('models/wireframe')
- ComplexMeshLoader.VisualDecorHolo:setColor(Color(50, 255, 50))
- ComplexMeshLoader.default_parent = chip()
- ComplexMeshLoader.SetHostURL = function(url) ComplexMeshLoader.host_address = url end
- ComplexMeshLoader.DisableDownloadProgressHUD = function() ComplexMeshLoader.InitDrawDownloadingProgress = false end
- ComplexMeshLoader.SetBaseParent = function(ent) ComplexMeshLoader.default_parent = ent end
- ComplexMeshLoader.BackgroundCoroutineOnPasteFinishFunction = nil
- ComplexMeshLoader.OnPasteFinishFunction = nil
- ComplexMeshLoader.BackgroundCoroutineOnPasteFinishHookName = 'artybyte_cml_think_after_paste_' .. chip():entIndex()
- ComplexMeshLoader.HolosPasteDoneEvent = function()
- ComplexMeshLoader.DownloadedObjData = { } -- clear obj raw meshes that was downloaded from host
- ComplexMeshLoader.VisualDecorHolo:remove()
- ComplexMeshLoader.ParentPartsToAnotherParts()
- if ComplexMeshLoader.OnPasteFinishFunction ~= nil then -- run oncely callback if it's provided
- ComplexMeshLoader.OnPasteFinishFunction()
- end
- if ComplexMeshLoader.BackgroundCoroutineOnPasteFinishFunction ~= nil then -- run constant execution callback if it's provided
- hook.add('Think', ComplexMeshLoader.BackgroundCoroutineOnPasteFinishHookName, function( )
- ComplexMeshLoader.BackgroundCoroutineOnPasteFinishFunction()
- end )
- end
- end
- ComplexMeshLoader.SetReadyTable = function(tbl)
- ComplexMeshLoader.ReadyMeshTable = tbl
- end
- ComplexMeshLoader.ParentPartsToAnotherParts = function()
- for i, part_pair in pairs(ComplexMeshLoader.PartsParentPool) do
- local target_part_name = part_pair.target
- local parent_part_name = part_pair.parent
- local pos_to_reset = part_pair.target_pos
- local ang_to_reset = part_pair.target_ang
- local target_holo = ComplexMeshLoader.HologramCollection[target_part_name]
- local parent_holo = ComplexMeshLoader.HologramCollection[parent_part_name]
- local PARENT_TO_TARGETS_PARENT = part_pair.affect_target_parent
- if target_holo ~= nil and parent_holo ~= nil then
- if PARENT_TO_TARGETS_PARENT then -- NEED TESTS : MAY BE SHOULD REMOVE.
- target_holo:setParent(parent_holo.parent)
- target_holo["parent"] = parent_holo.parent
- else
- target_holo:setParent(parent_holo)
- target_holo["parent"] = parent_holo
- end
- target_holo:setPos(ComplexMeshLoader.default_parent:localToWorld(pos_to_reset))
- target_holo:setAngles(ComplexMeshLoader.default_parent:localToWorldAngles(ang_to_reset))
- else
- print('ComplexMeshLoader :: parent error [target: ' .. tostring(target_part_name) .. '| parent: ' .. tostring(parent_part_name) .. ']')
- end
- end
- end
- ComplexMeshLoader.SetFileNameReplacing = function(str_what, str_to)
- ComplexMeshLoader.ReplaceNameWhat = str_what
- ComplexMeshLoader.ReplaceNameTo = str_to
- end
- ComplexMeshLoader.SetLoadLocalModels = function(bool)
- ComplexMeshLoader.SetModuleModeToLoadLocalTxtModels = bool or true
- end
- ComplexMeshLoader.SetLocalModelsPath = function(path)
- ComplexMeshLoader.LocalModelLoadingPath = path
- end
- ComplexMeshLoader.SetOnPasteDoneContinuousFunction = function(func) -- will execute constantly after pasting all holos
- ComplexMeshLoader.BackgroundCoroutineOnPasteFinishFunction = func
- end
- ComplexMeshLoader.SetOnPasteDoneOneTimeFunction = function(func) -- will call once at pasting finish
- ComplexMeshLoader.OnPasteFinishFunction = func
- end
- ComplexMeshLoader.InitDrawingLoadingProgress = function() -- loading visualization
- hook.add("PostDrawOpaqueRenderables", "artybyte_ComplexMeshLoader_loading", function()
- local m = chip():getMatrix()
- m:translate(Vector(0, 0, 100))
- m:setAngles((eyePos() - m:getTranslation()):getAngle() + Angle(90, 0, 0))
- m:rotate(Angle(0, 90, 0))
- m:setScale(Vector(ComplexMeshLoader.LoadingPanelScale, -ComplexMeshLoader.LoadingPanelScale))
- render.pushMatrix(m)
- render.setColor(Color(0, 0, 0, 80))
- render.drawRect(-512, -128, 1024, 220)
- local loadingProgress = #ComplexMeshLoader.DownloadedObjData / #ComplexMeshLoader.components
- render.setColor(Color(140, 140, 140, 200))
- render.drawRect(-512 + 40, -128 + 40, (1024 - 80) * loadingProgress, 50)
- local pastingProgress = #table.getKeys(ComplexMeshLoader.HologramCollection) / #ComplexMeshLoader.components
- render.setColor(Color(140, 140, 140, 200))
- render.drawRect(-512 + 40, 0, (1024 - 80) * pastingProgress, 50)
- -- Override depth for text rendering, otherwise it's gonna draw on top of the world
- render.enableDepth(true)
- render.setColor(Color(200, 200, 200, 130))
- render.setFont(ComplexMeshLoader.LoadingPanelFont)
- render.drawSimpleText(0, -70, "download", 1, 1)
- render.setColor(Color(208, 200, 200, 130))
- render.drawSimpleText(0, 20, "paste", 1, 1)
- if math.floor(pastingProgress) == 1 then
- hook.remove("PostDrawOpaqueRenderables", "artybyte_ComplexMeshLoader_loading")
- enableHud(nil, false)
- end
- render.popMatrix()
- end)
- enableHud(nil, true)
- end
- -- download from web OR
- -- load from locals if ComplexMeshLoader.SetModuleModeToLoadLocalTxtModels used.
- ComplexMeshLoader.DownloadObjData = function()
- local Tasks = { }
- local TaskID = 1
- for i = 1, #ComplexMeshLoader.components do
- -- download model if it have .obj extension
- local objName = ComplexMeshLoader.components[ i ].obj_name
- if ComplexMeshLoader.ReplaceNameWhat ~= nil and ComplexMeshLoader.ReplaceNameTo ~= nil then
- objName = string.replace(objName, ComplexMeshLoader.ReplaceNameWhat, ComplexMeshLoader.ReplaceNameTo)
- end
- if ComplexMeshLoader.ReadyMeshTable ~= nil then -- if we set ready table and we can paste meshes via strings
- local component = ComplexMeshLoader.components[i]
- local remapValue = ComplexMeshLoader.ReadyMeshTable[component.obj_name] -- we need to change order of models according to component collection order.
- table.insert( ComplexMeshLoader.DownloadedObjData, remapValue)
- if ComplexMeshLoader.ReadyMeshTable[component.obj_name] == nil then
- print("***ComplexMeshLoader ERROR: component \"" .. tostring(component.obj_name) .. "\" not exist")
- end
- if i == #ComplexMeshLoader.components then
- ComplexMeshLoader.ConvertObjDataToMeshes()
- print("ComplexMeshLoader :: converting...")
- end
- -- ComplexMeshLoader.components[ i ].obj_name
- else
- local URL = ComplexMeshLoader.host_address .. objName
- table.insert( Tasks, function()
- coroutine.wrap( function()
- if not ComplexMeshLoader.SetModuleModeToLoadLocalTxtModels then -- if we need to download
- http.get(URL, function(objdata)
- table.insert( ComplexMeshLoader.DownloadedObjData, objdata )
- ComplexMeshLoader.VisualDecorHolo:emitSound("npc/turret_floor/ping.wav", 75, 100, 1, 0)
- TaskID = TaskID + 1
- if TaskID <= #Tasks then
- Tasks[TaskID] ()
- else
- -- ALL PARTS download complete, let's convert to mesh and spawn holos!
- ComplexMeshLoader.ConvertObjDataToMeshes() -- start converting all downloaded models to holos
- end
- end, function(err)
- print('ComplexMeshLoader: load fail ' .. tostring(ComplexMeshLoader.components[ i ].obj_name) .. ' at component [' .. tostring(ComplexMeshLoader.components[ i ].part_name) .. ']. Error text: ' .. tostring(err))
- table.insert( ComplexMeshLoader.DownloadedObjData, { } )
- TaskID = TaskID + 1
- if TaskID <= #Tasks then
- Tasks[TaskID] ()
- else
- -- ALL PARTS download complete, let's convert to mesh and spawn holos!
- ComplexMeshLoader.ConvertObjDataToMeshes() -- start converting all downloaded models to holos
- print("ComplexMeshLoader :: converting...")
- end
- end )
- else -- if we need to load locally
- local obj_name = ComplexMeshLoader.components[ i ].obj_name
- obj_name = string.replace(obj_name, '.obj', '.txt') -- if we want to switch from loading to locals and we lazy to change file ext
- local obj_txt = file.read(ComplexMeshLoader.LocalModelLoadingPath .. obj_name)
- if obj_txt == nil then
- -- file loaded successfully.
- print("ComplexMeshLoader error: can't load file " .. tostring(obj_name))
- end
- table.insert( ComplexMeshLoader.DownloadedObjData, obj_txt )
- TaskID = TaskID + 1
- if TaskID <= #Tasks then
- Tasks[TaskID] ()
- else
- -- All parts loaded locally from drive. ("data/sf_filedata/")
- ComplexMeshLoader.ConvertObjDataToMeshes() -- start converting all downloaded models to holos
- print("ComplexMeshLoader :: converting...")
- end
- end
- end ) ()
- end )
- end
- end
- if #Tasks > 0 then -- it could be 0 if we using ready table
- Tasks[1] () -- init all sequence level 1
- end
- end
- ComplexMeshLoader.ConvertObjDataToMeshes = function()
- local function MeshLoadComplete(_mesh, componentData)
- -- this function calls by converter from obj to mesh to install and set up hologram
- if type(_mesh) == 'Mesh' then
- local pos = componentData.local_pos
- local ang = componentData.local_ang
- local mat = componentData.mat
- local color = componentData.color
- local scale = componentData.scale
- local callback = componentData.create_callback
- local part_name = componentData.part_name
- local parent = componentData.parent
- local parent_params = componentData.parent_params
- local render_mode = componentData.render_mode
- local skin = componentData.skin
- local holo = holograms.create(
- ComplexMeshLoader.default_parent:localToWorld(pos),
- ComplexMeshLoader.default_parent:localToWorldAngles(ang),
- ComplexMeshLoader.default_holo_model
- )
- if skin ~= nil then
- holo:setSkin(skin)
- end
- if parent_params ~= nil then
- if parent_params.part_parent == nil then -- if we need to create parent point by params
- local parent_pos = parent_params.local_pos
- local parent_ang = parent_params.local_ang
- local parent_scale = parent_params.scale
- local parent_to_target_parent = parent_params.affect_target_parent
- if parent_params.local_pos == nil then parent_pos = Vector(0, 0, 0) end
- if parent_params.local_ang == nil then parent_ang = Angle(0, 0, 0) end
- if parent_params.scale == nil then parent_scale = Vector(0.25, 0.25, 0.25) end
- local parent = holograms.create(
- ComplexMeshLoader.default_parent:localToWorld(parent_pos),
- ComplexMeshLoader.default_parent:localToWorldAngles(parent_ang),
- ComplexMeshLoader.default_holo_model
- )
- parent:setScale(parent_scale)
- parent:setParent(ComplexMeshLoader.default_parent)
- parent:setPos(ComplexMeshLoader.default_parent:localToWorld(parent_pos))
- parent:setAngles(ComplexMeshLoader.default_parent:localToWorldAngles(parent_ang))
- holo:setParent(parent)
- -- to prevent offsetting
- holo:setPos(ComplexMeshLoader.default_parent:localToWorld(pos))
- holo:setAngles(ComplexMeshLoader.default_parent:localToWorldAngles(ang))
- holo["parent"] = parent
- else -- if we need to parent part to existing part by name
- -- reason to think: may be we need to provide local_pos & local_ang to move target part relatively parent on it's values.
- -- just to offset pos and ang target relatively parent
- table.insert( ComplexMeshLoader.PartsParentPool,
- {
- target=part_name,
- target_pos=pos,
- target_ang=ang,
- parent=parent_params.part_parent,
- affect_target_parent=parent_to_target_parent
- } )
- end
- else
- if parent == nil then
- holo:setParent(ComplexMeshLoader.default_parent)
- else
- holo:setParent(parent)
- end
- -- to prevent offsetting
- holo:setPos(ComplexMeshLoader.default_parent:localToWorld(pos))
- holo:setAngles(ComplexMeshLoader.default_parent:localToWorldAngles(ang))
- end
- if type(mat) == 'string' then
- holo:setMaterial(mat)
- else
- holo:setMeshMaterial(mat)
- end
- holo:setColor(color)
- -- do not change scale if it's equal to 1.1.1. It's unnecessary action
- if scale != Vector(1, 1 ,1) then holo:setScale(scale) end
- -- do not set rendermode if it's 0 (normal). unnecessary action
- if render_mode != nil then
- if render_mode != 0 then
- holo:setRenderMode(render_mode)
- end
- end
- holo:setMesh(_mesh)
- holo:setRenderBounds(unpack(ComplexMeshLoader.HologramsRenderBounds))
- ComplexMeshLoader.HologramCollection[part_name] = holo
- -- decor point
- ComplexMeshLoader.VisualDecorHolo:setPos(holo:getPos())
- ComplexMeshLoader.VisualDecorHolo:emitSound("npc/roller/remote_yes.wav", 75, 100, 1, 0)
- if callback ~= nil then
- callback( holo )
- end
- end
- -- turn on coroutine
- timer.simple(ComplexMeshLoader.ModelPasteInterval, function()
- coroutine.resume(ComplexMeshLoader.ConversionPoolWorker)
- end )
- end
- -- conversion. push all coroutine examplars to pool that will run these coroutines till it's complete.
- for i = 1, #ComplexMeshLoader.DownloadedObjData do
- local obj = ComplexMeshLoader.DownloadedObjData[i]
- -- if MODEL TABLE length is 0, it's empty table, skip conversion. (empty table goes from downloader and sets if we create .mdl part)
- -- if table is not empty, convert from obj
- local doConversion = coroutine.wrap( function()
- local _mesh = { }
- if type(obj) == 'string' then
- if string.len(obj) > 0 then
- local model = { }
- local succ, err = pcall( function( )
- model = mesh.createFromObj(obj, true, true)
- end )
- if not succ then
- print("ComplexMeshLoader :: PARSE ERROR AT COMPONENT " .. string.sub(obj, 0, 100))
- end
- _mesh = model[ table.getKeys(model)[1] ]
- else
- print("ComplexMeshLoader error: empty .obj file")
- end
- end
- return true, _mesh, i
- end )
- table.insert( ComplexMeshLoader.ConversionPool, doConversion )
- end
- -- conversion pool execution control
- ComplexMeshLoader.ConversionPoolWorker = coroutine.create( function( )
- while #ComplexMeshLoader.ConversionPool > 0 do
- if ComplexMeshLoader.LastAverageQuota ~= quotaAverage() then
- if ComplexMeshLoader.LastAverageQuota > quotaMax()/2 then
- timer.simple(ComplexMeshLoader.QuotaOverloadCooldown, function( )
- coroutine.resume( ComplexMeshLoader.ConversionPoolWorker )
- end )
- coroutine.yield()
- end
- ComplexMeshLoader.LastAverageQuota = quotaAverage()
- end
- local task = ComplexMeshLoader.ConversionPool[1]
- local done, _mesh, componentID = task()
- if done then
- MeshLoadComplete(_mesh, ComplexMeshLoader.components[componentID] )
- table.remove(ComplexMeshLoader.ConversionPool, 1)
- coroutine.yield()
- if #ComplexMeshLoader.ConversionPool == 0 then
- ComplexMeshLoader.HolosPasteDoneEvent()
- break
- end
- end
- end
- end )
- coroutine.resume( ComplexMeshLoader.ConversionPoolWorker )
- end
- ComplexMeshLoader.PushComponent = function( args )
- local component = { }
- local keys = table.getKeys(args)
- for i, key in pairs(keys) do
- component[key] = args[key]
- end
- -- insert defaults
- if component.mat == nil then mat = "default" end
- if component.local_pos == nil then component.local_pos = Vector(0, 0, 0) end
- if component.local_ang == nil then component.local_ang = Angle(0, 0, 0) end
- if component.color == nil then component.color = Color(255,255,255) end
- if component.part_name == nil then component.part_name = "mesh_part_" .. #ComplexMeshLoader end
- if component.scale == nil then component.scale = Vector(1, 1, 1) end
- table.insert(ComplexMeshLoader.components, component)
- end
- ComplexMeshLoader.Initialize = function() -- main method (entry point) to initialize job of module
- ComplexMeshLoader.DownloadObjData()
- print("ComplexMeshLoader :: downloading...")
- if ComplexMeshLoader.InitDrawDownloadingProgress then
- ComplexMeshLoader.InitDrawingLoadingProgress()
- end
- end
- function MODULE__GetComplexMeshLoader()
- return ComplexMeshLoader
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement