//The tool has been changed ! private void ToolChange() { //Is it a CubeResource ? if (_tool is CubeResource) { _renderingType = ToolRenderingType.Cube; _cubeRenderer.PrepareCubeRendering((CubeResource)_tool); } else if (_tool is IVoxelEntity) //A voxel Entity ? { logger.Info("Voxel Entity tool equipped : {0}", _tool.Name); var voxelEntity = _tool as IVoxelEntity; _renderingType = ToolRenderingType.Voxel; _toolVoxelModel = _voxelModelManager.GetModel(voxelEntity.ModelName); if (_toolVoxelModel != null) { if (!_toolVoxelModel.Initialized) { _toolVoxelModel.BuildMesh(); } _toolVoxelInstance = _toolVoxelModel.VoxelModel.CreateInstance(); _toolVoxelInstance.SetState(_toolVoxelModel.VoxelModel.GetMainState()); } else { logger.Info("Unable to display the voxel model"); } } }
private void PrepareModel() { var voxelEntity = (IVoxelEntity)Tool; if (voxelEntity == null || string.IsNullOrEmpty(voxelEntity.ModelName)) { _toolVoxelModel = null; return; } _toolVoxelModel = _voxelModelManager.GetModel(voxelEntity.ModelName); if (_toolVoxelModel != null) { if (!_toolVoxelModel.Initialized) { _toolVoxelModel.BuildMesh(); } _toolVoxelInstance = _toolVoxelModel.VoxelModel.CreateInstance(); _toolVoxelInstance.SetState(_toolVoxelModel.VoxelModel.GetMainState()); } }