Esempio n. 1
0
        internal void DrawLevel()
        {
            if (!loaded)
            {
                return;
            }
            d3ddevice.SetTransform(TransformType.Projection, Matrix.PerspectiveFovRH((float)(Math.PI / 4), panel1.Width / (float)panel1.Height, 1, cam.DrawDistance));
            d3ddevice.SetTransform(TransformType.View, cam.ToMatrix());
            Text = "X=" + cam.Position.X + " Y=" + cam.Position.Y + " Z=" + cam.Position.Z + " Pitch=" + cam.Pitch.ToString("X") + " Yaw=" + cam.Yaw.ToString("X") + " Interval=" + interval + (cam.mode == 1 ? " Distance=" + cam.Distance : "") + (animation != null ? " Animation=" + animation.Name + " Frame=" + animframe : "");
            d3ddevice.RenderState.FillMode = EditorOptions.RenderFillMode;
            d3ddevice.RenderState.CullMode = EditorOptions.RenderCullMode;
            d3ddevice.Material             = new Material {
                Ambient = Color.White
            };
            d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToArgb(), 1, 0);
            d3ddevice.RenderState.ZBufferEnable = true;
            d3ddevice.BeginScene();
            //all drawings after this line
            EditorOptions.RenderStateCommonSetup(d3ddevice);

            MatrixStack transform = new MatrixStack();

            if (animation != null)
            {
                RenderInfo.Draw(model.DrawModelTreeAnimated(d3ddevice, transform, Textures, meshes, animation, animframe), d3ddevice, cam);
            }
            else
            {
                RenderInfo.Draw(model.DrawModelTree(d3ddevice, transform, Textures, meshes), d3ddevice, cam);
            }

            if (selectedObject != null)
            {
                DrawSelectedObject(model, transform);
            }

            d3ddevice.EndScene();             //all drawings before this line
            d3ddevice.Present();
        }
Esempio n. 2
0
        internal void DrawEntireModel()
        {
            if (!loaded)
            {
                return;
            }
            d3ddevice.SetTransform(TransformState.Projection, Matrix.PerspectiveFovRH(cam.FOV, panel1.Width / (float)panel1.Height, 1, cam.DrawDistance));
            d3ddevice.SetTransform(TransformState.View, cam.ToMatrix());
            UpdateStatusString();
            d3ddevice.SetRenderState(RenderState.FillMode, EditorOptions.RenderFillMode);
            d3ddevice.SetRenderState(RenderState.CullMode, EditorOptions.RenderCullMode);
            d3ddevice.Material = new Material {
                Ambient = Color.White.ToRawColor4()
            };
            d3ddevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black.ToRawColorBGRA(), 1, 0);
            d3ddevice.SetRenderState(RenderState.ZEnable, true);
            d3ddevice.BeginScene();

            //all drawings after this line
            EditorOptions.RenderStateCommonSetup(d3ddevice);

            MatrixStack       transform  = new MatrixStack();
            List <RenderInfo> renderList = new List <RenderInfo>();

            for (int i = 0; i < @event.Scenes[0].Entities.Count; i++)
            {
                NJS_OBJECT model = @event.Scenes[0].Entities[i].Model;
                if (model == null)
                {
                    model = @event.Scenes[0].Entities[i].GCModel;
                }
                if (model != null)
                {
                    if (model.HasWeight)
                    {
                        renderList.AddRange(model.DrawModelTreeWeighted(EditorOptions.RenderFillMode, transform.Top, Textures, meshes[0][i]));
                        if (@event.Scenes[0].Entities[i] == selectedObject)
                        {
                            renderList.AddRange(model.DrawModelTreeWeightedInvert(transform.Top, meshes[0][i]));
                        }
                    }
                    else
                    {
                        renderList.AddRange(model.DrawModelTree(EditorOptions.RenderFillMode, transform, Textures, meshes[0][i]));
                        if (@event.Scenes[0].Entities[i] == selectedObject)
                        {
                            renderList.AddRange(model.DrawModelTreeInvert(transform, meshes[0][i]));
                        }
                    }
                }
            }
            if (scenenum > 0)
            {
                for (int i = 0; i < @event.Scenes[scenenum].Entities.Count; i++)
                {
                    NJS_OBJECT model = @event.Scenes[scenenum].Entities[i].Model;
                    if (model == null)
                    {
                        model = @event.Scenes[scenenum].Entities[i].GCModel;
                    }
                    if (model != null)
                    {
                        if (model.HasWeight)
                        {
                            if (animframe != -1 && @event.Scenes[scenenum].Entities[i].Motion != null)
                            {
                                transform.Push();
                                transform.NJTranslate(@event.Scenes[scenenum].Entities[i].Motion.Models[0].GetPosition(animframe));
                            }
                            renderList.AddRange(model.DrawModelTreeWeighted(EditorOptions.RenderFillMode, transform.Top, Textures, meshes[scenenum][i]));
                            if (@event.Scenes[scenenum].Entities[i] == selectedObject)
                            {
                                renderList.AddRange(model.DrawModelTreeWeightedInvert(transform.Top, meshes[scenenum][i]));
                            }
                            if (animframe != -1 && @event.Scenes[scenenum].Entities[i].Motion != null)
                            {
                                transform.Pop();
                            }
                        }
                        else if (animframe == -1 || @event.Scenes[scenenum].Entities[i].Motion == null)
                        {
                            renderList.AddRange(model.DrawModelTree(EditorOptions.RenderFillMode, transform, Textures, meshes[scenenum][i]));
                            if (@event.Scenes[scenenum].Entities[i] == selectedObject)
                            {
                                renderList.AddRange(model.DrawModelTreeInvert(transform, meshes[scenenum][i]));
                            }
                        }
                        else
                        {
                            renderList.AddRange(model.DrawModelTreeAnimated(EditorOptions.RenderFillMode, transform, Textures, meshes[scenenum][i], @event.Scenes[scenenum].Entities[i].Motion, animframe));
                            if (@event.Scenes[scenenum].Entities[i] == selectedObject)
                            {
                                renderList.AddRange(model.DrawModelTreeAnimatedInvert(transform, meshes[scenenum][i], @event.Scenes[scenenum].Entities[i].Motion, animframe));
                            }
                        }
                    }
                }
                if (@event.Scenes[scenenum].Big?.Model != null)
                {
                    if (@event.Scenes[scenenum].Big.Model.HasWeight)
                    {
                        renderList.AddRange(@event.Scenes[scenenum].Big.Model.DrawModelTreeWeighted(EditorOptions.RenderFillMode, transform.Top, Textures, bigmeshes[scenenum]));
                    }
                    else if (animframe == -1)
                    {
                        renderList.AddRange(@event.Scenes[scenenum].Big.Model.DrawModelTree(EditorOptions.RenderFillMode, transform, Textures, bigmeshes[scenenum]));
                    }
                    else
                    {
                        int an = 0;
                        int fr = animframe;
                        while (an < @event.Scenes[scenenum].Big.Motions.Count && @event.Scenes[scenenum].Big.Motions[an].a.Frames < fr)
                        {
                            fr -= @event.Scenes[scenenum].Big.Motions[an].a.Frames;
                            an++;
                        }
                        if (an < @event.Scenes[scenenum].Big.Motions.Count)
                        {
                            renderList.AddRange(@event.Scenes[scenenum].Big.Model.DrawModelTreeAnimated(EditorOptions.RenderFillMode, transform, Textures, bigmeshes[scenenum], @event.Scenes[scenenum].Big.Motions[an].a, fr));
                        }
                    }
                }
                if (!eventcamera && animframe != -1 && showCameraToolStripMenuItem.Checked)
                {
                    transform.Push();
                    transform.LoadMatrix(cammatrix);
                    renderList.AddRange(cammodel.DrawModel(EditorOptions.RenderFillMode, transform, null, cammesh, true));
                    transform.Pop();
                }
            }

            RenderInfo.Draw(renderList, d3ddevice, cam);
            d3ddevice.EndScene();             //all drawings before this line
            d3ddevice.Present();
        }