Example #1
0
        private void DrawModels(SF.Shader shader, GL_ControlModern control)
        {
            shader.EnableVertexAttributes();
            for (int m = 0; m < models.Count; m++)
            {
                if (models[m].Checked)
                {
                    List <FSHP> opaque      = new List <FSHP>();
                    List <FSHP> transparent = new List <FSHP>();

                    for (int shp = 0; shp < models[m].shapes.Count; shp++)
                    {
                        if (models[m].shapes[shp].GetFMAT().isTransparent)
                        {
                            transparent.Add(models[m].shapes[shp]);
                        }
                        else
                        {
                            opaque.Add(models[m].shapes[shp]);
                        }
                    }

                    for (int shp = 0; shp < transparent.Count; shp++)
                    {
                        DrawModel(transparent[shp], models[m], shader, models[m].IsSelected);
                    }

                    for (int shp = 0; shp < opaque.Count; shp++)
                    {
                        DrawModel(opaque[shp], models[m], shader, models[m].IsSelected);
                    }
                }
            }

            shader.DisableVertexAttributes();
        }
Example #2
0
        public override void Draw(GL_ControlModern control, Pass pass, EditorSceneBase editorScene)
        {
            CheckBuffers();

            if (!Runtime.OpenTKInitialized || !Runtime.renderBones || !Visible)
            {
                return;
            }

            SF.Shader shader = OpenTKSharedResources.shaders["BONE"];
            shader.UseProgram();

            GL.Disable(EnableCap.CullFace);

            if (Runtime.boneXrayDisplay)
            {
                GL.Disable(EnableCap.DepthTest);
            }

            if (Runtime.renderBoundingBoxes)
            {
                DrawBoundingBoxes();
            }

            control.UpdateModelMatrix(
                Matrix4.CreateScale(Runtime.previewScale * PreviewScale) *
                Matrix4.CreateTranslation(Selected ? editorScene.CurrentAction.NewPos(position) : position));


            shader.EnableVertexAttributes();
            shader.SetMatrix4x4("rotation", ref prismRotation);

            Matrix4 camMat         = control.CameraMatrix;
            Matrix4 mdlMat         = control.ModelMatrix;
            Matrix4 projMat        = control.ProjectionMatrix;
            Matrix4 computedCamMtx = camMat * projMat;

            shader.SetMatrix4x4("mtxCam", ref computedCamMtx);
            shader.SetMatrix4x4("mtxMdl", ref mdlMat);

            foreach (STBone bn in bones)
            {
                if (!bn.Checked)
                {
                    continue;
                }

                shader.SetVector4("boneColor", ColorUtility.ToVector4(boneColor));
                shader.SetFloat("scale", Runtime.bonePointSize * BonePointScale);
                shader.SetMatrix4x4("ModelMatrix", ref bn.ModelMatrix);


                Matrix4 transform = bn.Transform;

                shader.SetMatrix4x4("bone", ref transform);
                shader.SetInt("hasParent", bn.parentIndex != -1 ? 1 : 0);

                if (bn.parentIndex != -1)
                {
                    var transformParent = ((STBone)bn.Parent).Transform;
                    shader.SetMatrix4x4("parent", ref transformParent);
                }

                Draw(shader);

                if (Runtime.SelectedBoneIndex == bn.GetIndex())
                {
                    shader.SetVector4("boneColor", ColorUtility.ToVector4(selectedBoneColor));
                }

                shader.SetInt("hasParent", 0);
                Draw(shader);
            }

            shader.DisableVertexAttributes();

            GL.UseProgram(0);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.DepthTest);
        }