public EditableMatrixImage2i(Vector2i size, IImageSampler2i sampler, IImageConstraint2i constraint) { _constraint = constraint; _sampler = sampler; _editableMatrix = new Matrix <int>(size); FixImage(new Rect2i(0, 0, size.x, size.y), Direction.Unknown); }
private void Initialize() { _editableImageConstraint = new TycoonTileConstraint2i(); _sampler = new DualImageSampler2i(); _terrainGenerator = new TerrainGenerator2i <TerrainMesher2i>(); _meshUpdater = new TerrainMeshUpdater(); _groupsSelector = new GroupsByCameraVisibilitySelector(); _imageProvider = new EditableMatrixImage2i(InitialTexture, InitialTextureScale, _sampler, _editableImageConstraint); }
public SceneContext( IGroupSelector groupSelector, ITerrainGenerator2i terrainGenerator, IMeshUpdater meshUpdater, Vector3 cameraPosition, IReadOnlyList <Plane> cameraPlanes, IReadOnlyPooledList <Vector3> cameraFrustumCorners, Matrix4x4 cameraLocalToWorldMatrix, Matrix4x4 parentContainerWorldToLocalMatrix, IReadOnlySet <Vector2i> existingGroups, Vector2i cellInGroupCount, IImage2i image, Rect2i invalidatedArea_imageSpace, IImageSampler2i imageSampler, Func <GameObject> gameObjectFactory, ProfilerFactoryDelegate profilerFactory, LoggerFactoryDelegate loggerFactory) { GroupSelector = groupSelector; TerrainGenerator = terrainGenerator; MeshUpdater = meshUpdater; CameraPosition = cameraPosition; CameraPlanes = cameraPlanes; CameraFrustumCorners = cameraFrustumCorners; CameraLocalToWorldMatrix = cameraLocalToWorldMatrix; ParentContainerWorldToLocalMatrix = parentContainerWorldToLocalMatrix; ExistingGroups = existingGroups; CellInGroupCount = cellInGroupCount; Image = image; ImageSampler = imageSampler; GameObjectFactory = gameObjectFactory; ProfilerFactory = profilerFactory; LoggerFactory = loggerFactory; RangeZ = image.RangeZ; GroupBounds = new Bounds(new Vector3(CellInGroupCount.x / 2.0f, CellInGroupCount.y / 2.0f, RangeZ.Center), new Vector3(CellInGroupCount.x, CellInGroupCount.y, RangeZ.Size)); InvalidatedArea_worldSpace = ImageSampler .ImageToWorld(invalidatedArea_imageSpace) .RoundToContain(); (Image as IInitializableImage)?.StartUsing(); }
private void DisposeService() { (_imageProvider as IDisposable)?.Dispose(); _imageProvider = null; (_editableImageConstraint as IDisposable)?.Dispose(); _editableImageConstraint = null; (_sampler as IDisposable)?.Dispose(); _sampler = null; (_terrainGenerator as IDisposable)?.Dispose(); _terrainGenerator = null; (_meshUpdater as IDisposable)?.Dispose(); _meshUpdater = null; (_groupsSelector as IDisposable)?.Dispose(); _groupsSelector = null; }
public EditableMatrixImage2i(Texture2D texture, float scale, IImageSampler2i sampler, IImageConstraint2i constraint) { _constraint = constraint; _sampler = sampler; int width = texture.width; int height = texture.height; var size = new Vector2i(width, height); _editableMatrix = new Matrix <int>(size); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { _editableMatrix[x, y] = (int)(texture.GetPixel(x, y).grayscale *scale); } } FixImage(new Rect2i(0, 0, size.x, size.y), Direction.Unknown); }
public static Rect ImageToWorld(this IImageSampler2i sampler, Rect2i rect) { var min = sampler.ImageToWorld(rect.min); var max = sampler.ImageToWorld(rect.max); return Rect.MinMaxRect(min.x, min.y, max.x, max.y); }