public Task buildTask(string name, VoxelStruct vs, GeometryResult cb) { VoxelGeometry.MeshData data = null; TaskPack tp = new TaskPack(delegate(){ vs.arrange(); string md5 = VoxelFormater.GetMd5(vs); data = this.LoadFromFile(GetKey(md5)); if (data == null) { return(buildData(vs, delegate(VoxelGeometry.MeshData result) { data = result; // Debug.Log(md5); this.SaveToFile(GetKey(md5), data); })); } return(new Task()); }); TaskManager.PushBack(tp, delegate { if (this.gameObject.GetComponent <VoxelMesh>() == null) { this.gameObject.AddComponent <VoxelMesh>(); } VoxelMesh mesh = VoxelGeometry.Draw(name, data, this.gameObject, this._material); mesh.vs = vs; cb(mesh); }); return(tp); }
public void Awake() { if (_voxelMesh == null) { _voxelMesh = this.gameObject.GetComponent <VoxelMesh>(); } }
public override void build (VoxelMesh mesh, VoxelHandler handler) { VoxelEmitter emitter = (VoxelEmitter)GameObject.Instantiate (_emitter); emitter.transform.parent = mesh.transform; emitter.transform.position = new Vector3 (handler.position.x, handler.position.y, handler.position.z);//position; //emitter.transform.eulerAngles =c.transform.eulerAngles; emitter.gameObject.SetActive (true); //emitter.transform = c.transform.rotation; }
public override void build(VoxelMesh mesh, Voxel c) { VoxelEmitter emitter = (VoxelEmitter)GameObject.Instantiate (_emitter); emitter.transform.parent = mesh.transform; emitter.transform.position = c.transform.position; emitter.transform.eulerAngles =c.transform.eulerAngles; emitter.gameObject.SetActive (true); //emitter.transform = c.transform.rotation; }
public override void build(VoxelMesh mesh, VoxelHandler handler) { VoxelEmitter emitter = (VoxelEmitter)GameObject.Instantiate(_emitter); emitter.transform.parent = mesh.transform; emitter.transform.position = new Vector3(handler.position.x, handler.position.y, handler.position.z); //position; //emitter.transform.eulerAngles =c.transform.eulerAngles; emitter.gameObject.SetActive(true); //emitter.transform = c.transform.rotation; }
public void build (VoxelMesh mesh) { foreach(VoxelHandler handler in mesh._datas){ foreach (Item item in _itemList) { if(item.id == handler.id){ item.func.build(mesh, handler); } } } }
public VoxelMesh draw(string name, VoxelStruct vs, VoxelGeometry.MeshData data, GameObject obj = null) { if (obj == null) { obj = this.gameObject; } VoxelMesh mesh = VoxelGeometry.Draw(name, data, obj, this._material); mesh.vs = vs; return(mesh); }
public VoxelMesh create(VoxelData[] data, VoxelFunctionManager vf) { VoxelMesh vm = _create(); vm.build(data); if (vf != null) { vf.build(vm); } vm.showMesh(); return(vm); }
public VoxelMesh build(VoxelStruct vs, GameObject obj = null) { //VoxelData[] datas = vs.datas.ToArray (); if (obj == null) { obj = this.gameObject; } VoxelGeometry.MeshData data = BuildMeshData(vs); VoxelMesh mesh = VoxelGeometry.Draw("Mesh", data, obj, this._material); mesh.vs = vs; return(mesh); }
public void build(VoxelMesh mesh) { foreach (VoxelHandler handler in mesh._datas) { foreach (Item item in _itemList) { if (item.id == handler.id) { item.func.build(mesh, handler); } } } }
public static VoxelMesh Draw(string name, MeshData data, GameObject gameObject, Material material) { VoxelMesh mesh = gameObject.AddComponent <VoxelMesh> (); mesh.filter = CrateMeshFilter(data, name, material); mesh.filter.gameObject.transform.SetParent(gameObject.transform); mesh.filter.gameObject.transform.localPosition = Vector3.zero; mesh.filter.gameObject.transform.localScale = Vector3.one; mesh.filter.gameObject.transform.localRotation = Quaternion.Euler(Vector3.zero); mesh.filter.gameObject.SetActive(true); Refresh(data, mesh); return(mesh); }
void initMesh() { if (_mesh == null) { this._mesh = this.gameObject.GetComponent <VoxelMesh>(); } if (_mesh == null) { this._mesh = this.gameObject.AddComponent <VoxelMesh>(); } if (this._mesh._material == null) { this._mesh._material = this._material; } }
public static void Refresh(MeshData data, VoxelMesh mesh) { Vector3 offset = Vector3.zero; Vector3 size = new Vector3(data.max.x - data.min.x, data.max.z - data.min.z, data.max.y - data.min.y); offset = size / -2.0f - new Vector3(data.min.x, data.min.z, data.min.y); mesh.filter.transform.localPosition = offset; if (mesh.collider == null) { mesh.collider = mesh.gameObject.GetComponent <BoxCollider>(); } if (mesh.collider == null) { mesh.collider = mesh.gameObject.AddComponent <BoxCollider>(); } mesh.collider.size = size + Vector3.one; //mesh.collider = _collider; }
public bool colliderIt(VoxelMesh voxelMesh) { return(true); }
public virtual void build (VoxelMesh mesh, VoxelHandler handler) { }
public virtual void build(VoxelMesh mesh, VoxelHandler handler) { }
public void Awake() { if (_mesh == null) { _mesh = this.gameObject.GetComponent<VoxelMesh> (); } }
private VoxelMesh _create() { VoxelMesh mesh = (VoxelMesh)GameObject.Instantiate(_prototype); return(mesh); }
public virtual void build(VoxelMesh mesh, Voxel c) { }
public void setup(VoxelMesh mesh) { _mesh = mesh; //_mesh._datas }