public double GetGenerationWeight(Camera cam) { bool isVisible = true; var myPos = rangeToCalculateScreenSizeOn.CenterPos + planetInfo.Transform.Position; var dirToCamera = myPos.Towards(cam.ViewPointPosition).ToVector3d(); dirToCamera.NormalizeFast(); // 0 looking at it from side, 1 looking at it from top, -1 looking at it from behind var dotToCamera = rangeToCalculateScreenSizeOn.NormalFast.Dot(dirToCamera); if (RendererSurface != null && RendererSurface.Mesh != null) { //var localCamPos = planetaryBody.Transform.Position.Towards(cam.ViewPointPosition).ToVector3(); //distanceToCamera = renderer.Mesh.Vertices.FindClosest((v) => v.DistanceSqr(localCamPos)).Distance(localCamPos); //isVisible = cam.GetFrustum().VsBounds(renderer.GetCameraSpaceBounds(cam.ViewPointPosition)); isVisible = RendererSurface.GetCameraRenderStatusFeedback(cam).HasFlag(RenderStatus.Rendered); } var weight = GetSizeOnScreen(cam); //weight *= (1 + MyMath.Clamp01(dotToCamera)); if (isVisible == false) { weight *= 0.3f; } return(weight); }
private void LoadRendererCore(IRenderer renderer) { RendererSurface surface = Model.Project.GetRendererSurface(renderer.Model.Guid); // * Lock // 렌더러를 모델에 의해 생성하는경우 초기화를 방지하기 위해 잠굼 DesignTime.Lock(renderer as ControlLayer); // Metadata mapping renderer.Metadata.CreatedPosition = surface.Metadata.CreatedPosition; renderer.Metadata.CreatedTime = surface.Metadata.CreatedTime; // * Pending rollback // 렌더러가 생성되고 WPF 컨트롤이 Load 될 때 바인딩을 진행하기 때문에 // 모델의 속성에 영향을 주지 않음 (덤프 가능 상태) var dump = new DumpDependencyObject(renderer.Model); renderer.ElementAttached += ElementAttached; void ElementAttached(object sender, EventArgs e) { renderer.ElementAttached -= ElementAttached; // Property Rollback dump.CopyTo(renderer.Model); // Unlock DesignTime.Unlock(renderer as ControlLayer); Canvas.SetLeft(renderer.Element, surface.Location.X); Canvas.SetTop(renderer.Element, surface.Location.Y); } }
public override void ViewDidAppear() { base.ViewDidAppear(); rendererSurface = new RendererSurface(FrameSizeWidth, FrameSizeHeight, PIXEL_SCALE, IMAGE_FLIP_X_COORD, IMAGE_FLIP_Y_COORD); renderer = new Renderer(rendererSurface); rendererSurface.Clear(); rendererSurface.SetPixelColor(255, 0, 0, 255); //drawLinesInCircle(25, 12); draw3Dmodel(); RefreshImage(); }