private void MoveCamera(DrawContext dc, Vector2 prev, Vector2 current) { Vector3d pv = new Vector3d(prev.X, prev.Y, 0); Vector3d cv = new Vector3d(current.X, current.Y, 0); Vector3d dv = cv - pv; dv.X *= -1.0; dc.WorldVectorToDevVector(dv); Vector3d lookAt = dc.LookAt + dv; Vector3d eye = dc.Eye + dv; dc.SetCamera(eye, lookAt, dc.UpVector); }
/** * 画面上での間隔が min より大きくなるように間引く為のサイズの * 倍率を求める */ public double Decimate(DrawContext dc, Gridding grid, double min) { double scaleX = 1.0; double scaleY = 1.0; double scaleZ = 1.0; double gridSizeX = grid.GridSize.X; double gridSizeY = grid.GridSize.Y; double gridSizeZ = grid.GridSize.Z; Vector3d devLen; double t = 1; double d; double devLenX; double devLenY; double devLenZ; // X axis devLen = dc.WorldVectorToDevVector(new Vector3d(gridSizeX, 0, 0)); devLenX = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y)); if (devLenX != 0 && devLenX < min) { d = Math.Ceiling(min / devLenX) * devLenX; t = d / devLenX; } if (t > scaleX) { scaleX = t; } // Y axis devLen = dc.WorldVectorToDevVector(new Vector3d(0, gridSizeY, 0)); devLenY = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y)); if (devLenY != 0 && devLenY < min) { d = Math.Ceiling(min / devLenY) * devLenY; t = d / devLenY; } if (t > scaleY) { scaleY = t; } // Z axis devLen = dc.WorldVectorToDevVector(new Vector3d(0, 0, gridSizeZ)); devLenZ = Math.Max(Math.Abs(devLen.X), Math.Abs(devLen.Y)); if (devLenZ != 0 && devLenZ < min) { d = Math.Ceiling(min / devLenZ) * devLenZ; t = d / devLenZ; } if (t > scaleZ) { scaleZ = t; } return(Math.Max(Math.Max(scaleX, scaleY), scaleZ)); }