//public CameraSettingsClass( Viewport viewport, double aspectRatio, Degree fieldOfView, double nearClipDistance, double farClipDistance, // Vector3 position, Vector3 direction, Vector3 fixedUp, ProjectionType projection = ProjectionType.Perspective, // double orthographicHeight = 1, bool reflectionEnabled = false, Plane reflectionPlane = new Plane() ) //{ // Init( viewport, /*null, */false, aspectRatio, fieldOfView, nearClipDistance, farClipDistance, position, direction, fixedUp, // projection, orthographicHeight, reflectionEnabled, reflectionPlane ); //} //public CameraSettingsClass( Viewport viewport, double aspectRatio, Degree fieldOfView, double nearClipDistance, double farClipDistance, // Vector3 position, Vector3 direction, Vector3 fixedUp, ProjectionType projection = ProjectionType.Perspective, // double height = 1, bool reflectionEnabled = false, Plane reflectionPlane = new Plane() ) //{ // Init( viewport, /*null, */false, aspectRatio, fieldOfView, nearClipDistance, farClipDistance, position, direction, fixedUp, // projection, height, reflectionEnabled, reflectionPlane ); //} void Init(Viewport viewport, /*Component_Camera sourceCamera, */ bool frustumCullingTest, double aspectRatio, Degree fieldOfView, double nearClipDistance, double farClipDistance, Vector3 position, Vector3 direction, Vector3 fixedUp, ProjectionType projection, double height, double exposure, double emissiveFactor, bool reflectionEnabled, Plane reflectionPlane, Component_RenderingPipeline renderingPipelineOverride, bool renderSky) { this.viewport = viewport; //this.sourceCamera = sourceCamera; this.frustumCullingTest = frustumCullingTest; //fix invalid parameters //!!!!!! if (direction.Length() < .0001) { direction = new Vector3(fixedUp.Y, fixedUp.X, fixedUp.Z); } fixedUp.Normalize(); direction.Normalize(); if (direction.Equals(fixedUp, .0001)) { direction = new Vector3(fixedUp.Y, fixedUp.X, fixedUp.Z); } this.aspectRatio = aspectRatio; if (this.aspectRatio <= 0) { this.aspectRatio = (double)viewport.SizeInPixels.X / (double)viewport.SizeInPixels.Y; } this.fieldOfView = fieldOfView; this.nearClipDistance = nearClipDistance; this.farClipDistance = farClipDistance; this.position = position; //!!!!this.derivedPosition = position; this.direction = direction; //!!!!this.derivedDirection = direction; this.fixedUp = fixedUp; this.projection = projection; this.height = height; this.exposure = exposure; this.emissiveFactor = emissiveFactor; this.reflectionEnabled = reflectionEnabled; this.reflectionPlane = reflectionPlane; this.renderingPipelineOverride = renderingPipelineOverride; this.renderSky = renderSky; //!!!!!! if (this.reflectionEnabled) { Log.Fatal("impl reflectionEnabled"); } //!!!!new this.rotation = Quaternion.LookAt(direction, this.fixedUp); //this.rotation = Quat._Remove_FromDirectionZAxisUp( direction ); //!!!! this.direction = rotation.GetForward(); up = rotation.GetUp(); right = Vector3.Cross(this.direction, up); CalculateFrustum(); CalculateMatrices(); }
unsafe public override void Render(Component_RenderingPipeline pipeline, ViewportRenderingContext context, Component_RenderingPipeline.IFrameData frameData) { UpdateProcessedCubemaps(); if (mesh != null) { var pass = GetMaterialPass(); if (pass != null) { ////!!!! //CreatedCubemapUpdate(); //!!!!double Matrix4F worldMatrix = Matrix4.FromTranslate(context.Owner.CameraSettings.Position).ToMatrix4F(); foreach (var item in mesh.Result.MeshData.RenderOperations) { ParameterContainer generalContainer = new ParameterContainer(); generalContainer.Set("multiplier", Multiplier.Value.ToColorValue()); GetRotationMatrix(out var rotation); generalContainer.Set("rotation", rotation); // Matrix3.FromRotateByZ( Rotation.Value.InRadians() ).ToMatrix3F() ); Component_Image tex = null; //!!!!сделать GetResultEnvironmentCubemap()? //!!!!!!где еще его использовать if (processedEnvironmentCubemap != null) { tex = processedEnvironmentCubemap; } //else if( AnyCubemapSideIsSpecified() ) // tex = createdCubemap; else { tex = Cubemap; } if (tex == null) { tex = ResourceUtility.BlackTextureCube; } if (tex.Result != null && tex.Result.TextureType == Component_Image.TypeEnum.Cube) { var addressingMode = TextureAddressingMode.Clamp; context.BindTexture(new ViewportRenderingContext.BindTextureData(0 /*"skyboxTexture"*/, tex, addressingMode, FilterOption.Linear, FilterOption.Linear, FilterOption.Linear)); var containers = new List <ParameterContainer>(); containers.Add(generalContainer); Bgfx.SetTransform((float *)&worldMatrix); ((Component_RenderingPipeline_Basic)pipeline).RenderOperation(context, item, pass, containers); } } } } }
public abstract void Render(Component_RenderingPipeline pipeline, ViewportRenderingContext context, Component_RenderingPipeline.IFrameData frameData); //, Viewport renderToViewport );// ref Component_Texture actualTexture );
public CameraSettingsClass(Viewport viewport, double aspectRatio, Degree fieldOfView, double nearClipDistance, double farClipDistance, Vector3 position, Vector3 direction, Vector3 fixedUp, ProjectionType projection, double height, double exposure, double emissiveFactor, bool reflectionEnabled = false, Plane reflectionPlane = new Plane(), bool frustumCullingTest = false, Component_RenderingPipeline renderingPipelineOverride = null, bool renderSky = true) { Init(viewport, /*null, */ frustumCullingTest, aspectRatio, fieldOfView, nearClipDistance, farClipDistance, position, direction, fixedUp, projection, height, exposure, emissiveFactor, reflectionEnabled, reflectionPlane, renderingPipelineOverride, renderSky); }