protected Light(Light input) : base(input) { Color = input.Color; intensity = input.intensity; falloff = input.falloff; fov = input.fov; light_type = input.light_type; strct = input.strct; //Initialize new MeshVao meshVao = new GLMeshVao(); meshVao.type = TYPES.LIGHT; meshVao.vao = new Primitives.LineSegment(1, new Vector3(1.0f, 0.0f, 0.0f)).getVAO(); meshVao.metaData = new MeshMetaData(); meshVao.metaData.batchcount = 2; meshVao.material = RenderState.activeResMgr.GLmaterials["lightMat"]; instanceId = GLMeshBufferManager.addInstance(ref meshVao, this); //Add instance //Copy Matrices lightProjectionMatrix = input.lightProjectionMatrix; lightSpaceMatrices = new Matrix4[6]; for (int i = 0; i < 6; i++) { lightSpaceMatrices[i] = input.lightSpaceMatrices[i]; } update_struct(); RenderState.activeResMgr.GLlights.Add(this); }
public Light() { type = TYPES.LIGHT; fov = 360; intensity = 1.0f; falloff = ATTENUATION_TYPE.CONSTANT; light_type = LIGHT_TYPE.POINT; //Initialize new MeshVao meshVao = new GLMeshVao(); meshVao.type = TYPES.LIGHT; meshVao.vao = new Primitives.LineSegment(1, new Vector3(1.0f, 0.0f, 0.0f)).getVAO(); meshVao.metaData = new MeshMetaData(); meshVao.metaData.batchcount = 2; meshVao.material = Common.RenderState.activeResMgr.GLmaterials["lightMat"]; instanceId = GLMeshBufferManager.addInstance(ref meshVao, this); // Add instance //Init projection Matrix lightProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathUtils.radians(90), 1.0f, 1.0f, 300f); //Init lightSpace Matrices lightSpaceMatrices = new Matrix4[6]; for (int i = 0; i < 6; i++) { lightSpaceMatrices[i] = Matrix4.Identity * lightProjectionMatrix; } //Catch changes to MVector from the UI color = new MVector4(1.0f); color.PropertyChanged += catchPropertyChanged; }
public override void updateMeshInfo(bool lod_filter = false) { if (lod_filter) { strct.position.W = 0.0f; //Force not renderable base.updateMeshInfo(); RenderStats.occludedNum += 1; } else if (RenderState.renderViewSettings.RenderLights && renderable) { //End Point Vector4 ep; //Lights with 360 FOV are points if (Math.Abs(FOV - 360.0f) <= 1e-4) { ep = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); light_type = LIGHT_TYPE.POINT; } else { ep = new Vector4(0.0f, 0.0f, -1.0f, 0.0f); light_type = LIGHT_TYPE.SPOT; } ep = ep * _localRotation; direction = ep.Xyz; //Set spotlight direction update_struct(); //Update Vertex Buffer based on the new data float[] verts = new float[6]; int arraysize = 6 * sizeof(float); //Origin Point verts[0] = worldPosition.X; verts[1] = worldPosition.Y; verts[2] = worldPosition.Z; ep.X += worldPosition.X; ep.Y += worldPosition.Y; ep.Z += worldPosition.Z; verts[3] = ep.X; verts[4] = ep.Y; verts[5] = ep.Z; GL.BindVertexArray(meshVao.vao.vao_id); GL.BindBuffer(BufferTarget.ArrayBuffer, meshVao.vao.vertex_buffer_object); //Add verts data, color data should stay the same GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)0, (IntPtr)arraysize, verts); //Uplod worldMat to the meshVao instanceId = GLMeshBufferManager.addInstance(meshVao, this, Matrix4.Identity, Matrix4.Identity, Matrix4.Identity); //Add instance } else { base.updateMeshInfo(); updated = false; //All done } }
protected override void LoadSpecialized(BinaryReader _R) { m_LightType = (LIGHT_TYPE)_R.ReadByte(); m_Color = new float3(_R.ReadSingle(), _R.ReadSingle(), _R.ReadSingle()); m_Intensity = _R.ReadSingle(); m_HotSpot = _R.ReadSingle(); m_ConeAngle = _R.ReadSingle(); }
public Light(Scene _Owner, idTech5Map.Map.Entity _Entity) : base(_Owner, _Entity) { m_LightType = LIGHT_TYPE.POINT; // TODO // m_LightType = (LIGHT_TYPE) _Light.Type; // m_Color.FromVector3( _Light.Color ); // m_Intensity = _Light.Intensity; // m_HotSpot = _Light.HotSpot; // m_ConeAngle = _Light.ConeAngle; }
public Light(Scene _Owner, FBX.Scene.Nodes.Node _Node) : base(_Owner, _Node) { FBX.Scene.Nodes.Light _Light = _Node as FBX.Scene.Nodes.Light; m_LightType = (LIGHT_TYPE)_Light.Type; m_Color.FromVector3(_Light.Color); m_Intensity = _Light.Intensity; m_HotSpot = _Light.HotSpot; m_ConeAngle = _Light.ConeAngle; }
public override void update() { base.update(); //End Point Vector4 ep; //Lights with 360 FOV are points if (Math.Abs(FOV - 360.0f) <= 1e-4) { ep = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); ep = ep * _localRotation; light_type = LIGHT_TYPE.POINT; } else { ep = new Vector4(0.0f, 0.0f, -1.0f, 0.0f); ep = ep * _localRotation; light_type = LIGHT_TYPE.SPOT; } ep.Normalize(); direction = ep.Xyz; //Set spotlight direction update_struct(); //Assume that this is a point light for now //Right lightSpaceMatrices[0] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(1.0f, 0.0f, 0.0f), new Vector3(0.0f, -1.0f, 0.0f)); //Left lightSpaceMatrices[1] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(-1.0f, 0.0f, 0.0f), new Vector3(0.0f, -1.0f, 0.0f)); //Up lightSpaceMatrices[2] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(0.0f, -1.0f, 0.0f), new Vector3(0.0f, 0.0f, 1.0f)); //Down lightSpaceMatrices[3] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(0.0f, 1.0f, 0.0f), new Vector3(0.0f, 0.0f, 1.0f)); //Near lightSpaceMatrices[4] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(0.0f, 0.0f, 1.0f), new Vector3(0.0f, -1.0f, 0.0f)); //Far lightSpaceMatrices[5] = Matrix4.LookAt(worldPosition, worldPosition + new Vector3(0.0f, 0.0f, -1.0f), new Vector3(0.0f, -1.0f, 0.0f)); }
public Light(BinaryReader br) { TotalSize = br.ReadUInt32(); long end = br.BaseStream.Position + TotalSize; ObjSize = br.ReadUInt32(); Name = br.ReadCString(Constants.SizeName); ObjectId = br.ReadInt32(); ParentId = br.ReadInt32(); Flags = (GENOBJECTFLAGS)br.ReadUInt32(); LoadTracks(br); Type = (LIGHT_TYPE)br.ReadInt32(); AttenuationStart = br.ReadSingle(); AttenuationEnd = br.ReadSingle(); Color = new CVector3(br); Intensity = br.ReadSingle(); AmbientColor = new CVector3(br); // added at version 700 AmbientIntensity = br.ReadSingle(); // added at version 700 while (br.BaseStream.Position < end && !br.AtEnd()) { string tagname = br.ReadString(4); switch (tagname) { case "KLAI": IntensityKeys = new Track <float>(br); break; case "KLBI": AmbIntensityKeys = new Track <float>(br); break; case "KVIS": VisibilityKeys = new Track <float>(br); break; case "KLAC": ColorKeys = new Track <CVector3>(br, true); break; case "KLBC": AmbColorKeys = new Track <CVector3>(br, true); break; case "KLAS": AttenStartKeys = new Track <float>(br); break; case "KLAE": AttenEndKeys = new Track <float>(br); break; default: br.BaseStream.Position -= 4; return; } } }
protected override void LoadSpecific(System.IO.BinaryReader _Reader) { m_Type = (LIGHT_TYPE)_Reader.ReadInt32(); m_Color.X = _Reader.ReadSingle(); m_Color.Y = _Reader.ReadSingle(); m_Color.Z = _Reader.ReadSingle(); m_Intensity = _Reader.ReadSingle(); m_bCastShadow = _Reader.ReadBoolean(); m_bEnableNearAttenuation = _Reader.ReadBoolean(); m_NearAttenuationStart = _Reader.ReadSingle(); m_NearAttenuationEnd = _Reader.ReadSingle(); m_bEnableFarAttenuation = _Reader.ReadBoolean(); m_FarAttenuationStart = _Reader.ReadSingle(); m_FarAttenuationEnd = _Reader.ReadSingle(); m_HotSpot = _Reader.ReadSingle(); m_ConeAngle = _Reader.ReadSingle(); m_DecayType = (DECAY_TYPE)_Reader.ReadInt32(); m_DecayStart = _Reader.ReadSingle(); m_TempTargetNodeID = _Reader.ReadInt32(); }
protected override void LoadSpecific( System.IO.BinaryReader _Reader ) { m_Type = (LIGHT_TYPE) _Reader.ReadInt32(); m_Color.X = _Reader.ReadSingle(); m_Color.Y = _Reader.ReadSingle(); m_Color.Z = _Reader.ReadSingle(); m_Intensity = _Reader.ReadSingle(); m_bCastShadow = _Reader.ReadBoolean(); m_bEnableNearAttenuation = _Reader.ReadBoolean(); m_NearAttenuationStart = _Reader.ReadSingle(); m_NearAttenuationEnd = _Reader.ReadSingle(); m_bEnableFarAttenuation = _Reader.ReadBoolean(); m_FarAttenuationStart = _Reader.ReadSingle(); m_FarAttenuationEnd = _Reader.ReadSingle(); m_HotSpot = _Reader.ReadSingle(); m_ConeAngle = _Reader.ReadSingle(); m_DecayType = (DECAY_TYPE) _Reader.ReadInt32(); m_DecayStart = _Reader.ReadSingle(); m_TempTargetNodeID = _Reader.ReadInt32(); }
protected override void LoadSpecialized( BinaryReader _R ) { m_LightType = (LIGHT_TYPE) _R.ReadByte(); m_Color = new float3( _R.ReadSingle(), _R.ReadSingle(), _R.ReadSingle() ); m_Intensity = _R.ReadSingle(); m_HotSpot = _R.ReadSingle(); m_ConeAngle = _R.ReadSingle(); }
public Light( Scene _Owner, idTech5Map.Map.Entity _Entity ) : base(_Owner, _Entity) { m_LightType = LIGHT_TYPE.POINT; // TODO // m_LightType = (LIGHT_TYPE) _Light.Type; // m_Color.FromVector3( _Light.Color ); // m_Intensity = _Light.Intensity; // m_HotSpot = _Light.HotSpot; // m_ConeAngle = _Light.ConeAngle; }
public Light( Scene _Owner, FBX.Scene.Nodes.Node _Node ) : base(_Owner, _Node) { FBX.Scene.Nodes.Light _Light = _Node as FBX.Scene.Nodes.Light; m_LightType = (LIGHT_TYPE) _Light.Type; m_Color.FromVector3( _Light.Color ); m_Intensity = _Light.Intensity; m_HotSpot = _Light.HotSpot; m_ConeAngle = _Light.ConeAngle; }