/// <summary> /// Spocita viditelnost objektu. Na zaklade vypocte se objekt bude nebo nebude renderovat /// </summary> /// <remarks>Metoda je zavisla na spravne vypocitanych vzdalenostech od kamery!</remarks> public virtual bool ComputeVisibility(ISceneCamera camera) { if (camera == null) { visible = true; return(true); } ClipVolume cv = camera.GetClipVolume(); Plane[] p = new Plane[] { cv.pNear, cv.pFar, cv.pLeft, cv.pRight, cv.pTop, cv.pBottom }; Matrix boundingWorld = boundingMeshWorld[0]; float radius = GetSphereRadius() * scale; Vector3 position = new Vector3(); position.TransformCoordinate(boundingWorld); if (mesh == null) { for (int t = 0; t < p.Length; t++) { float dot = p[t].Dot(GetPosition()) + radius; if (dot < 0) { visible = false; return(false); } } visible = true; return(true); } if (distance <= radius) { visible = true; return(visible); } for (int k = 0; k < p.Length; k++) { float dot = p[k].Dot(position); if (dot + radius < 0) { visible = false; return(visible); } } visible = true; return(visible); }
public bool ComputeVisibility(ISceneCamera camera) { if (camera == null) { this.visible = true; return(true); } ClipVolume cv = camera.GetClipVolume(); Plane[] p = new Plane[] { cv.pNear, cv.pFar, cv.pLeft, cv.pRight, cv.pTop, cv.pBottom }; for (int k = 0; k < p.Length; k++) { if (p[k].Dot(this.boundingSphereCenter) + this.radius < 0) { this.visible = false; return(this.visible); } } this.visible = true; return(this.visible); }