예제 #1
0
 public void setColorFromHSV(float H, float S, float V)
 {
     // calculate light color
     difHue        = H;
     difSaturation = S;
     difIntensity  = V;
     ColorTools.HSV2RGB(difHue, difSaturation, difIntensity, out difR, out difG, out difB);
 }
예제 #2
0
        private static void SetLightingUniforms(Shader shader, Camera camera)
        {
            // fresnel sky/ground color for characters & stages
            GL.Uniform3(shader.getAttribute("fresGroundColor"), Lights.fresnelLight.groundR, Lights.fresnelLight.groundG, Lights.fresnelLight.groundB);
            GL.Uniform3(shader.getAttribute("fresSkyColor"), Lights.fresnelLight.skyR, Lights.fresnelLight.skyG, Lights.fresnelLight.skyB);
            GL.Uniform3(shader.getAttribute("fresSkyDirection"), Lights.fresnelLight.getSkyDirection());
            GL.Uniform3(shader.getAttribute("fresGroundDirection"), Lights.fresnelLight.getGroundDirection());

            // reflection color for characters & stages
            float refR, refG, refB = 1.0f;

            ColorTools.HSV2RGB(Runtime.reflection_hue, Runtime.reflection_saturation, Runtime.reflection_intensity, out refR, out refG, out refB);
            GL.Uniform3(shader.getAttribute("refLightColor"), refR, refG, refB);

            // character diffuse lights
            GL.Uniform3(shader.getAttribute("difLightColor"), Lights.diffuseLight.difR, Lights.diffuseLight.difG, Lights.diffuseLight.difB);
            GL.Uniform3(shader.getAttribute("ambLightColor"), Lights.diffuseLight.ambR, Lights.diffuseLight.ambG, Lights.diffuseLight.ambB);

            GL.Uniform3(shader.getAttribute("difLightColor2"), Lights.diffuseLight2.difR, Lights.diffuseLight2.difG, Lights.diffuseLight2.difB);
            GL.Uniform3(shader.getAttribute("ambLightColor2"), Lights.diffuseLight2.ambR, Lights.diffuseLight2.ambG, Lights.diffuseLight2.ambB);

            GL.Uniform3(shader.getAttribute("difLightColor3"), Lights.diffuseLight3.difR, Lights.diffuseLight3.difG, Lights.diffuseLight3.difB);
            GL.Uniform3(shader.getAttribute("ambLightColor3"), Lights.diffuseLight3.ambR, Lights.diffuseLight3.ambG, Lights.diffuseLight3.ambB);

            // character specular light
            Lights.specularLight.setColorFromHSV(Runtime.specular_hue, Runtime.specular_saturation, Runtime.specular_intensity);
            Lights.specularLight.setDirectionFromXYZAngles(Runtime.specular_rotX, Runtime.specular_rotY, Runtime.specular_rotZ);
            GL.Uniform3(shader.getAttribute("specLightColor"), Lights.specularLight.difR, Lights.specularLight.difG, Lights.specularLight.difB);

            // stage fog
            GL.Uniform1(shader.getAttribute("renderFog"), Runtime.renderFog ? 1 : 0);

            GL.Uniform3(shader.getAttribute("difLight2Direction"), Lights.diffuseLight2.direction);
            GL.Uniform3(shader.getAttribute("difLight3Direction"), Lights.diffuseLight2.direction);

            GL.Uniform3(shader.getAttribute("stageLight1Direction"), Lights.stageLight1.direction);
            GL.Uniform3(shader.getAttribute("stageLight2Direction"), Lights.stageLight2.direction);
            GL.Uniform3(shader.getAttribute("stageLight3Direction"), Lights.stageLight3.direction);
            GL.Uniform3(shader.getAttribute("stageLight4Direction"), Lights.stageLight4.direction);


            if (Runtime.cameraLight) // camera light should only affects character lighting
            {
                Matrix4 invertedCamera = camera.getMVPMatrix().Inverted();
                Vector3 lightDirection = new Vector3(0f, 0f, -1f);
                GL.Uniform3(shader.getAttribute("lightDirection"), Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
                GL.Uniform3(shader.getAttribute("specLightDirection"), Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
                GL.Uniform3(shader.getAttribute("difLightDirection"), Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
            }
            else
            {
                GL.Uniform3(shader.getAttribute("specLightDirection"), Lights.specularLight.direction);
                GL.Uniform3(shader.getAttribute("difLightDirection"), Lights.diffuseLight.direction);
            }
        }
예제 #3
0
        private static Vector3 CreateFogColorFromFogSet(ParamFile lightSet, int i)
        {
            float hue = (float)RenderTools.GetValueFromParamFile(lightSet, 2, 1 + i, 0);
            float saturation = (float)RenderTools.GetValueFromParamFile(lightSet, 2, 1 + i, 1);
            float value = (float)RenderTools.GetValueFromParamFile(lightSet, 2, 1 + i, 2);
            float fogR = 0.0f, fogB = 0.0f, fogG = 0.0f;

            ColorTools.HSV2RGB(hue, saturation, value, out fogR, out fogG, out fogB);
            Vector3 color = new Vector3(fogR, fogG, fogB);

            return(color);
        }
예제 #4
0
        public DirectionalLight(float H, float S, float V, Vector3 lightDirection, string name)
        {
            // calculate light color
            difHue        = H;
            difSaturation = S;
            difIntensity  = V;
            ColorTools.HSV2RGB(difHue, difSaturation, difIntensity, out difR, out difG, out difB);

            direction = lightDirection;

            this.id = name;
        }
예제 #5
0
 private void UpdateButtonColor()
 {
     try
     {
         string selectedMatPropKey = propertiesListView.SelectedItems[0].Text;
         colorSelect.BackColor = Color.FromArgb(255,
                                                ColorTools.FloatToIntClamp(currentMaterialList[currentMatIndex].entries[selectedMatPropKey][0]),
                                                ColorTools.FloatToIntClamp(currentMaterialList[currentMatIndex].entries[selectedMatPropKey][1]),
                                                ColorTools.FloatToIntClamp(currentMaterialList[currentMatIndex].entries[selectedMatPropKey][2]));
     }
     catch (ArgumentOutOfRangeException)
     {
     }
 }
예제 #6
0
        public static void SetLightingUniforms(Shader shader, Camera camera)
        {
            // fresnel sky/ground color for characters & stages
            ShaderTools.LightColorVector3Uniform(shader, Runtime.lightSetParam.fresnelLight.groundColor, "fresGroundColor");
            ShaderTools.LightColorVector3Uniform(shader, Runtime.lightSetParam.fresnelLight.skyColor, "fresSkyColor");
            shader.SetVector3("fresSkyDirection", Runtime.lightSetParam.fresnelLight.getSkyDirection());
            shader.SetVector3("fresGroundDirection", Runtime.lightSetParam.fresnelLight.getGroundDirection());

            // reflection color for characters & stages
            float refR, refG, refB = 1.0f;

            ColorTools.HsvToRgb(Runtime.reflectionHue, Runtime.reflectionSaturation, Runtime.reflectionIntensity, out refR, out refG, out refB);
            shader.SetVector3("refLightColor", refR, refG, refB);

            // character diffuse lights
            shader.SetVector3("difLightColor", Runtime.lightSetParam.characterDiffuse.diffuseColor.R, Runtime.lightSetParam.characterDiffuse.diffuseColor.G, Runtime.lightSetParam.characterDiffuse.diffuseColor.B);
            shader.SetVector3("ambLightColor", Runtime.lightSetParam.characterDiffuse.ambientColor.R, Runtime.lightSetParam.characterDiffuse.ambientColor.G, Runtime.lightSetParam.characterDiffuse.ambientColor.B);

            shader.SetVector3("difLightColor2", Runtime.lightSetParam.characterDiffuse2.diffuseColor.R, Runtime.lightSetParam.characterDiffuse2.diffuseColor.G, Runtime.lightSetParam.characterDiffuse2.diffuseColor.B);
            shader.SetVector3("ambLightColor2", Runtime.lightSetParam.characterDiffuse2.ambientColor.R, Runtime.lightSetParam.characterDiffuse2.ambientColor.G, Runtime.lightSetParam.characterDiffuse2.ambientColor.B);

            shader.SetVector3("difLightColor3", Runtime.lightSetParam.characterDiffuse3.diffuseColor.R, Runtime.lightSetParam.characterDiffuse3.diffuseColor.G, Runtime.lightSetParam.characterDiffuse3.diffuseColor.B);
            shader.SetVector3("ambLightColor3", Runtime.lightSetParam.characterDiffuse3.ambientColor.R, Runtime.lightSetParam.characterDiffuse3.ambientColor.G, Runtime.lightSetParam.characterDiffuse3.ambientColor.B);

            // character specular light
            shader.SetVector3("specLightColor", LightTools.specularLight.diffuseColor.R, LightTools.specularLight.diffuseColor.G, LightTools.specularLight.diffuseColor.B);

            // stage fog
            shader.SetBoolToInt("renderFog", Runtime.renderFog);

            shader.SetVector3("difLight2Direction", Runtime.lightSetParam.characterDiffuse2.direction);
            shader.SetVector3("difLight3Direction", Runtime.lightSetParam.characterDiffuse2.direction);

            if (Runtime.cameraLight)
            {
                // Camera light should only affect character lighting.
                Matrix4 invertedCamera = camera.MvpMatrix.Inverted();
                Vector3 lightDirection = new Vector3(0f, 0f, -1f);
                shader.SetVector3("lightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
                shader.SetVector3("specLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
                shader.SetVector3("difLightDirection", Vector3.TransformNormal(lightDirection, invertedCamera).Normalized());
            }
            else
            {
                shader.SetVector3("specLightDirection", LightTools.specularLight.direction);
                shader.SetVector3("difLightDirection", Runtime.lightSetParam.characterDiffuse.direction);
            }
        }
예제 #7
0
        public HemisphereFresnel(float groundH, float groundS, float groundV, float skyH, float skyS, float skyV,
                                 float skyAngle, float groundAngle, string name)
        {
            this.groundHue        = groundH;
            this.groundSaturation = groundS;
            this.groundIntensity  = groundV;
            this.skyHue           = skyH;
            this.skySaturation    = skyS;
            this.skyIntensity     = skyV;
            ColorTools.HSV2RGB(skyHue, skySaturation, skyIntensity, out skyR, out skyG, out skyB);

            this.skyAngle    = skyAngle;
            this.groundAngle = groundAngle;

            this.name = name;
        }
예제 #8
0
        public DirectionalLight(float difH, float difS, float difV, float ambH, float ambS, float ambV, float rotX, float rotY, float rotZ, string name)
        {
            // calculate light color
            difHue        = difH;
            difSaturation = difS;
            difIntensity  = difV;
            ambHue        = ambH;
            ambSaturation = ambS;
            ambIntensity  = ambV;
            ColorTools.HSV2RGB(difHue, difSaturation, difIntensity, out difR, out difG, out difB);
            ColorTools.HSV2RGB(ambHue, ambSaturation, ambIntensity, out ambR, out ambG, out ambB);

            // calculate light vector
            this.rotX = rotX;
            this.rotY = rotY;
            this.rotZ = rotZ;
            UpdateDirection(rotX, rotY, rotZ);

            this.id = name;
        }
예제 #9
0
        public DirectionalLight(float difH, float difS, float difV, float ambH, float ambS, float ambV, float rotX, float rotY, float rotZ, string name)
        {
            // calculate light color
            difHue        = difH;
            difSaturation = difS;
            difIntensity  = difV;
            ambHue        = ambH;
            ambSaturation = ambS;
            ambIntensity  = ambV;
            ColorTools.HSV2RGB(difHue, difSaturation, difIntensity, out difR, out difG, out difB);
            ColorTools.HSV2RGB(ambHue, ambSaturation, ambIntensity, out ambR, out ambG, out ambB);

            // calculate light vector
            this.rotX = rotX;
            this.rotY = rotY;
            this.rotZ = rotZ;
            Matrix4 lightRotMatrix = Matrix4.CreateFromAxisAngle(Vector3.UnitX, rotX * ((float)Math.PI / 180f))
                                     * Matrix4.CreateFromAxisAngle(Vector3.UnitY, rotY * ((float)Math.PI / 180f))
                                     * Matrix4.CreateFromAxisAngle(Vector3.UnitZ, rotZ * ((float)Math.PI / 180f));

            direction = Vector3.Transform(new Vector3(0f, 0f, 1f), lightRotMatrix).Normalized();

            this.id = name;
        }
예제 #10
0
 public void setAmbIntensity(float intensity)
 {
     this.ambIntensity = intensity;
     ColorTools.HSV2RGB(ambHue, ambSaturation, ambIntensity, out ambR, out ambG, out ambB);
 }
예제 #11
0
 public void setAmbSaturation(float saturation)
 {
     this.ambSaturation = saturation;
     ColorTools.HSV2RGB(ambHue, ambSaturation, ambIntensity, out ambR, out ambG, out ambB);
 }
예제 #12
0
 public void setAmbHue(float hue)
 {
     this.ambHue = hue;
     ColorTools.HSV2RGB(ambHue, ambSaturation, ambIntensity, out ambR, out ambG, out ambB);
 }
예제 #13
0
        public static void DrawCollisions(Stopwatch timeSinceSelected)
        {
            Color color;

            GL.LineWidth(4);
            Matrix4 transform = Matrix4.Identity;

            foreach (Collision c in Runtime.TargetLVD.collisions)
            {
                bool  colSelected = (Runtime.LVDSelection == c);
                float addX = 0, addY = 0, addZ = 0;
                if (c.useStartPos)
                {
                    addX = c.startPos[0];
                    addY = c.startPos[1];
                    addZ = c.startPos[2];
                }
                if (c.flag2)
                {
                    //Flag2 == rigged collision
                    ModelContainer riggedModel = null;
                    Bone           riggedBone  = null;
                    foreach (ModelContainer m in Runtime.ModelContainers)
                    {
                        if (m.name.Equals(c.subname))
                        {
                            riggedModel = m;
                            if (m.vbn != null)
                            {
                                foreach (Bone b in m.vbn.bones)
                                {
                                    if (b.Equals(c.boneName))
                                    {
                                        riggedBone = b;
                                    }
                                }
                            }
                        }
                    }
                    if (riggedModel != null)
                    {
                        if (riggedBone == null && riggedModel.vbn != null && riggedModel.vbn.bones.Count > 0)
                        {
                            riggedBone = riggedModel.vbn.bones[0];
                        }
                        if (riggedBone != null)
                        {
                            transform = riggedBone.invert * riggedBone.transform;
                        }
                    }
                }

                for (int i = 0; i < c.verts.Count - 1; i++)
                {
                    Vector3 v1Pos  = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ + 5), transform);
                    Vector3 v1Neg  = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ - 5), transform);
                    Vector3 v1Zero = Vector3.Transform(new Vector3(c.verts[i].x + addX, c.verts[i].y + addY, addZ), transform);
                    Vector3 v2Pos  = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ + 5), transform);
                    Vector3 v2Neg  = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ - 5), transform);
                    Vector3 v2Zero = Vector3.Transform(new Vector3(c.verts[i + 1].x + addX, c.verts[i + 1].y + addY, addZ), transform);

                    GL.Begin(PrimitiveType.Quads);
                    if (c.normals.Count > i)
                    {
                        if (Runtime.renderCollisionNormals)
                        {
                            Vector3 v = Vector3.Add(Vector3.Divide(Vector3.Subtract(v1Zero, v2Zero), 2), v2Zero);
                            GL.End();
                            GL.Begin(PrimitiveType.Lines);
                            GL.Color3(Color.Blue);
                            GL.Vertex3(v);
                            GL.Vertex3(v.X + (c.normals[i].x * 5), v.Y + (c.normals[i].y * 5), v.Z);
                            GL.End();
                            GL.Begin(PrimitiveType.Quads);
                        }

                        if (c.flag4)
                        {
                            color = Color.FromArgb(128, Color.Yellow);
                        }
                        else if (c.materials[i].getFlag(4) && Math.Abs(c.normals[i].x) > Math.Abs(c.normals[i].y))
                        {
                            color = Color.FromArgb(128, Color.Purple);
                        }
                        else if (Math.Abs(c.normals[i].x) > Math.Abs(c.normals[i].y))
                        {
                            color = Color.FromArgb(128, Color.Lime);
                        }
                        else if (c.normals[i].y < 0)
                        {
                            color = Color.FromArgb(128, Color.Red);
                        }
                        else
                        {
                            color = Color.FromArgb(128, Color.Cyan);
                        }

                        if ((colSelected || Runtime.LVDSelection == c.normals[i]) && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0))
                        {
                            color = ColorTools.invertColor(color);
                        }

                        GL.Color4(color);
                    }
                    else
                    {
                        GL.Color4(Color.FromArgb(128, Color.Gray));
                    }
                    GL.Vertex3(v1Pos);
                    GL.Vertex3(v1Neg);
                    GL.Vertex3(v2Neg);
                    GL.Vertex3(v2Pos);
                    GL.End();

                    GL.Begin(PrimitiveType.Lines);
                    if (c.materials.Count > i)
                    {
                        if (c.materials[i].getFlag(6) || (i > 0 && c.materials[i - 1].getFlag(7)))
                        {
                            color = Color.Purple;
                        }
                        else
                        {
                            color = Color.Orange;
                        }

                        if ((colSelected || Runtime.LVDSelection == c.verts[i]) && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0))
                        {
                            color = ColorTools.invertColor(color);
                        }
                        GL.Color4(color);
                    }
                    else
                    {
                        GL.Color4(Color.Gray);
                    }
                    GL.Vertex3(v1Pos);
                    GL.Vertex3(v1Neg);

                    if (i == c.verts.Count - 2)
                    {
                        if (c.materials.Count > i)
                        {
                            if (c.materials[i].getFlag(7))
                            {
                                color = Color.Purple;
                            }
                            else
                            {
                                color = Color.Orange;
                            }

                            if (Runtime.LVDSelection == c.verts[i + 1] && ((int)((timeSinceSelected.ElapsedMilliseconds % 1000) / 500) == 0))
                            {
                                color = ColorTools.invertColor(color);
                            }
                            GL.Color4(color);
                        }
                        else
                        {
                            GL.Color4(Color.Gray);
                        }
                        GL.Vertex3(v2Pos);
                        GL.Vertex3(v2Neg);
                    }
                    GL.End();
                }
                for (int i = 0; i < c.cliffs.Count; i++)
                {
                    Vector3 pos = c.cliffs[i].useStartPos ? c.cliffs[i].startPos : new Vector3(c.cliffs[i].pos.x, c.cliffs[i].pos.y, 0);

                    GL.Color3(Color.White);
                    GL.Begin(PrimitiveType.Lines);
                    GL.Vertex3(pos[0], pos[1], pos[2] + 10);
                    GL.Vertex3(pos[0], pos[1], pos[2] - 10);
                    GL.End();

                    GL.LineWidth(2);
                    GL.Color3(Color.Blue);
                    GL.Begin(PrimitiveType.Lines);
                    GL.Vertex3(pos);
                    GL.Vertex3(pos[0] + (c.cliffs[i].angle.x * 10), pos[1] + (c.cliffs[i].angle.y * 10), pos[2]);
                    GL.End();

                    GL.LineWidth(4);
                }
            }
        }
예제 #14
0
 public void setDifSaturation(float saturation)
 {
     this.difSaturation = saturation;
     ColorTools.HSV2RGB(difHue, saturation, difIntensity, out difR, out difG, out difB);
 }
예제 #15
0
 public void setDifHue(float hue)
 {
     this.difHue = hue;
     ColorTools.HSV2RGB(hue, difSaturation, difIntensity, out difR, out difG, out difB);
 }
예제 #16
0
 public void setSkyIntensity(float skyIntensity)
 {
     this.skyIntensity = skyIntensity;
     ColorTools.HSV2RGB(skyHue, skySaturation, skyIntensity, out skyR, out skyG, out skyB);
 }
예제 #17
0
 public void setGroundIntensity(float groundIntensity)
 {
     this.groundIntensity = groundIntensity;
     ColorTools.HSV2RGB(groundHue, groundSaturation, groundIntensity, out groundR, out groundG, out groundB);
 }
예제 #18
0
 public void setDifIntensity(float intensity)
 {
     this.difIntensity = intensity;
     ColorTools.HSV2RGB(difHue, difSaturation, difIntensity, out difR, out difG, out difB);
 }