void FinalProcess() { App.Current.Dispatcher.Invoke(() => { if (mesh == null) { return; } CreateBufferIfNeeded(); mesh.Mat = mat; float rx = (float)rotationX * ((float)Math.PI / 180.0f); float ry = (float)rotationY * ((float)Math.PI / 180.0f); float rz = (float)rotationZ * ((float)Math.PI / 180.0f); Quaternion rot = Quaternion.FromEulerAngles(rx, ry, rz); Matrix4 rotation = Matrix4.CreateFromQuaternion(rot); Matrix4 translation = Matrix4.CreateTranslation(xOffset, yOffset, zOffset); Matrix4 scale = Matrix4.CreateScale(scaleX, scaleY, scaleZ); Matrix4 view = rotation * Matrix4.CreateTranslation(0, 0, -cameraZoom); Vector3 pos = Vector3.Normalize((view * new Vector4(0, 0, 1, 1)).Xyz) * cameraZoom; mesh.View = view; mesh.CameraPosition = pos; mesh.Projection = Proj; //TRS mesh.Model = scale * translation; //light position currently doesn't do anything //just setting values to a default mesh.LightPosition = new Vector3(0, 0, 0); mesh.LightColor = new Vector3(1, 1, 1); processor.TileX = tileX; processor.TileY = tileY; processor.Mesh = mesh; processor.Process(width, height, buffer); processor.Complete(); Updated(); Output.Data = buffer; Output.Changed(); }); }
void Process() { if (mesh == null) { return; } CreateBufferIfNeeded(); mesh.Mat = mat; float rx = (float)this.rotation.X * ((float)Math.PI / 180.0f); float ry = (float)this.rotation.Y * ((float)Math.PI / 180.0f); float rz = (float)this.rotation.Z * ((float)Math.PI / 180.0f); Quaternion rot = Quaternion.FromEulerAngles(rx, ry, rz); Matrix4 rotation = Matrix4.CreateFromQuaternion(rot); Matrix4 translation = Matrix4.CreateTranslation(position.X, position.Y, position.Z); Matrix4 scale = Matrix4.CreateScale(this.scale.X, this.scale.Y, this.scale.Z); Matrix4 view = rotation * Matrix4.CreateTranslation(0, 0, -cameraZoom); Vector3 pos = Vector3.Normalize((view * new Vector4(0, 0, 1, 1)).Xyz) * cameraZoom; mesh.View = view; mesh.CameraPosition = pos; mesh.Projection = Proj; //TRS mesh.Model = scale * translation; //light position currently doesn't do anything //just setting values to a default mesh.LightPosition = new Vector3(0, 0, 0); mesh.LightColor = new Vector3(1, 1, 1); processor.TileX = tileX; processor.TileY = tileY; processor.Mesh = mesh; processor.Process(width, height, buffer); processor.Complete(); Output.Data = buffer; TriggerTextureChange(); }