Example #1
0
        public static BMD GetModel(string name)
        {
            if (Program.m_ROM == null)
            {
                return(null);
            }

            if (m_Models.ContainsKey(name))
            {
                CachedModel found = m_Models[name];
                found.m_References++;
                return(found.m_Model);
            }

            NitroFile mdfile = Program.m_ROM.GetFileFromName(name);

            if (mdfile == null)
            {
                return(null);
            }

            BMD model = new BMD(mdfile);

            model.PrepareToRender();

            CachedModel cmdl = new CachedModel();

            cmdl.m_Model        = model;
            cmdl.m_DisplayLists = null;
            cmdl.m_References   = 1;
            m_Models.Add(name, cmdl);

            return(model);
        }
Example #2
0
        private void PrerenderModel()
        {
            if (m_DisplayLists[0] == 0)
            {
                m_DisplayLists[0] = GL.GenLists(1);
            }
            GL.NewList(m_DisplayLists[0], ListMode.Compile);

            Vector3 previewScale = new Vector3(m_ModelImportSettings.m_Scale * m_ModelImportSettings.m_InGameModelScale);

            if (m_MdlLoaded)
            {
                GL.Disable(EnableCap.Lighting);
                GL.PushMatrix();
                GL.Scale(previewScale);
                GL.FrontFace(FrontFaceDirection.Ccw);

                m_ImportedModel.PrepareToRender();

                m_ImportedModel.Render(RenderMode.Opaque, 1f);
                m_ImportedModel.Render(RenderMode.Translucent, 1f);

                GL.PopMatrix();
            }
            GL.EndList();

            m_EarlyClosure = false;
        }
        private void PrerenderModel()
        {
            if (m_DisplayLists[0] == 0)
            {
                m_DisplayLists[0] = GL.GenLists(1);
            }
            GL.NewList(m_DisplayLists[0], ListMode.Compile);

            GL.FrontFace(FrontFaceDirection.Ccw);

            GL.Enable(EnableCap.Lighting);
            GL.Light(LightName.Light0, LightParameter.Position, new Vector4(1.0f, 1.0f, 1.0f, 0.0f));
            GL.Light(LightName.Light0, LightParameter.Ambient, Color.White);
            GL.Light(LightName.Light0, LightParameter.Diffuse, Color.White);
            GL.Light(LightName.Light0, LightParameter.Specular, Color.White);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.PushMatrix();

            GL.Scale(1f, 1f, 1f);
            GL.FrontFace(FrontFaceDirection.Ccw);

            m_BMD.PrepareToRender();

            int[] dl = new int[2];

            dl[0] = GL.GenLists(1);
            GL.NewList(dl[0], ListMode.Compile);
            m_BMD.Render(RenderMode.Opaque, m_ModelPreviewScale, m_BCA, m_AnimationFrameNumber);
            //GL.EndList();

            dl[1] = GL.GenLists(1);
            GL.NewList(dl[1], ListMode.Compile);
            m_BMD.Render(RenderMode.Translucent, m_ModelPreviewScale, m_BCA, m_AnimationFrameNumber);
            GL.EndList();

            GL.PopMatrix();

            glModelView.Refresh();
        }
Example #4
0
        private void PrerenderModel()
        {
            if (m_DisplayLists[0] == 0)
            {
                m_DisplayLists[0] = GL.GenLists(1);
            }
            GL.NewList(m_DisplayLists[0], ListMode.Compile);

            GL.FrontFace(FrontFaceDirection.Ccw);

            GL.Disable(EnableCap.Lighting);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            GL.Disable(EnableCap.Lighting);
            GL.PushMatrix();

            GL.Scale(1f, 1f, 1f);
            GL.FrontFace(FrontFaceDirection.Ccw);

            m_BMD.PrepareToRender();

            int[] dl = new int[2];

            dl[0] = GL.GenLists(1);
            GL.NewList(dl[0], ListMode.Compile);
            m_BMD.Render(RenderMode.Opaque, 1f, m_BCA, m_AnimationFrameNumber);
            //GL.EndList();

            dl[1] = GL.GenLists(1);
            GL.NewList(dl[1], ListMode.Compile);
            m_BMD.Render(RenderMode.Translucent, 1f, m_BCA, m_AnimationFrameNumber);
            GL.EndList();

            GL.PopMatrix();

            glModelView.Refresh();
        }
Example #5
0
        public static BMD GetModel(string name)
        {
            if (m_Models.ContainsKey(name))
            {
                CachedModel found = m_Models[name];
                found.m_References++;
                return found.m_Model;
            }

            NitroFile mdfile = Program.m_ROM.GetFileFromName(name);
            if (mdfile == null)
                return null;

            BMD model = new BMD(mdfile);
            model.PrepareToRender();

            CachedModel cmdl = new CachedModel();
            cmdl.m_Model = model;
            cmdl.m_DisplayLists = null;
            cmdl.m_References = 1;
            m_Models.Add(name, cmdl);

            return model;
        }
Example #6
0
        private void PrerenderModel()
        {
            m_MarioHeadModel = ModelCache.GetModel("data/player/mario_head_cap.bmd");
            m_MarioBodyModel = ModelCache.GetModel("data/player/mario_model.bmd");
            int[] mheaddl = ModelCache.GetDisplayLists(m_MarioHeadModel);
            int[] mbodydl = ModelCache.GetDisplayLists(m_MarioBodyModel);

            Vector3 mariopos = Vector3.Multiply(m_MarioPosition, m_Scale);

            if (m_DisplayList == 0)
            {
                m_DisplayList = GL.GenLists(1);
            }
            GL.NewList(m_DisplayList, ListMode.Compile);

            GL.FrontFace(FrontFaceDirection.Ccw);

            GL.Disable(EnableCap.Lighting);
            GL.BindTexture(TextureTarget.Texture2D, 0);
            GL.Begin(BeginMode.Lines);
            GL.Color3(1f, 0f, 0f);
            GL.Vertex3(0f, 0f, 0f);
            GL.Vertex3(500f, 0f, 0f);
            GL.Color3(0f, 1f, 0f);
            GL.Vertex3(0f, 0f, 0f);
            GL.Vertex3(0f, 500f, 0f);
            GL.Color3(0f, 0f, 1f);
            GL.Vertex3(0f, 0f, 0f);
            GL.Vertex3(0f, 0f, 500f);
            GL.End();

            GL.PushMatrix();
            GL.Translate(mariopos);
            GL.Begin(BeginMode.Lines);
            GL.Color3(1f, 1f, 0f);
            GL.Vertex3(0f, 0f, 0f);
            GL.Vertex3(0f, -500f, 0f);
            GL.End();
            GL.Rotate(m_MarioRotation, Vector3.UnitY);
            GL.Scale(0.008f, 0.008f, 0.008f);
            GL.CallList(mbodydl[0]);
            GL.CallList(mbodydl[1]);
            GL.Translate(0f, 11.25f, 0f);
            GL.Rotate(-90f, Vector3.UnitY);
            GL.Rotate(180f, Vector3.UnitX);
            GL.CallList(mheaddl[0]);
            GL.CallList(mheaddl[1]);
            GL.PopMatrix();

            Vector3 previewScale = m_Scale;

            previewScale = Vector3.Multiply(m_Scale, m_InGameModelScale);

            if (m_MdlLoaded)
            {
                GL.Disable(EnableCap.Lighting);
                GL.PushMatrix();
                GL.Scale(previewScale);
                GL.FrontFace(FrontFaceDirection.Ccw);

                m_ImportedModel.PrepareToRender();

                // Render model converted to BMD
                int[] dl = new int[2];

                dl[0] = GL.GenLists(1);
                GL.NewList(dl[0], ListMode.Compile);
                m_ImportedModel.Render(RenderMode.Opaque, 1f);
                //GL.EndList();

                dl[1] = GL.GenLists(1);
                GL.NewList(dl[1], ListMode.Compile);
                m_ImportedModel.Render(RenderMode.Translucent, 1f);
                GL.EndList();

                GL.PopMatrix();

                //GL.EndList();

                //GL.CallList(dl[0]);
                //GL.CallList(dl[1]);
                // End
            }

            if (m_PDisplayList == 0)
            {
                m_PDisplayList = GL.GenLists(1);
            }
            GL.NewList(m_PDisplayList, ListMode.Compile);

            GL.Color4(Color.FromArgb(0x66666666));
            GL.PushMatrix();
            GL.Translate(mariopos);
            GL.Rotate(m_MarioRotation, Vector3.UnitY);
            GL.Scale(0.008f, 0.008f, 0.008f);
            GL.CallList(mbodydl[2]);
            GL.Translate(0f, 11.25f, 0f);
            GL.Rotate(-90f, Vector3.UnitY);
            GL.Rotate(180f, Vector3.UnitX);
            GL.CallList(mheaddl[2]);
            GL.PopMatrix();

            GL.EndList();
        }