TreeViewItem LoadActorsRecursive(Actor actor, TreeViewItem item)
        {
            foreach (Actor actorx in actor.Children)
            {
                TreeViewItem itemx = new TreeViewItem();
                itemx = LoadActorsRecursive(actorx, itemx);
                itemx.Header = actorx.ID;
                item.Items.Add(itemx);
            }

            return item;
        }
        private void GizmoScaleEvent(Actor transformable, TransformationEventArgs e)
        {
            Vector3 delta = (Vector3)e.Value;

            if (gizmo.ActiveMode == GizmoMode.UniformScale)
                transformable.Scale *= 1 + ((delta.X + delta.Y + delta.Z) / 3);
            else
                transformable.Scale += delta;

            transformable.Scale = Vector3.Clamp(transformable.Scale, Vector3.Zero, transformable.Scale);
        }
 void gizmo_TranslateEvent(Actor transformable, GizmoModules.TransformationEventArgs e)
 {
     transformable.Position += (Vector3)e.Value;
 }
Example #4
0
        /// <summary>
        /// Helper function to apply rotation to objects using the built-in method.
        /// </summary>
        public void RotationHelper(Actor entity, TransformationEventArgs e)
        {
            Vector3 pos = _position;
              if (ActivePivot == PivotType.ObjectCenter)
            pos = entity.Position;

              Matrix localRot = Matrix.Identity;
              localRot.Forward = entity.Forward;
              localRot.Up = entity.Up;
              localRot.Right = Vector3.Cross(entity.Forward, entity.Up);
              localRot.Right.Normalize();
              localRot.Translation = entity.Position - pos;

              Matrix newRot = localRot * (Matrix)e.Value;

              entity.Forward = newRot.Forward;
              entity.Up = newRot.Up;
              entity.Position = newRot.Translation + pos;
        }
 private void GizmoRotateEvent(Actor transformable, TransformationEventArgs e)
 {
     gizmo.RotationHelper(transformable, e);
 }
Example #6
0
 private void OnRotateEvent(Actor transformable, Matrix delta)
 {
     if (RotateEvent != null)
     RotateEvent(transformable, new TransformationEventArgs(delta));
 }
Example #7
0
 private void OnTranslateEvent(Actor transformable, Vector3 delta)
 {
     if (TranslateEvent != null)
     TranslateEvent(transformable, new TransformationEventArgs(delta));
 }
 public void Draw(Actor node)
 {
     drawDepthNormalMap(node);
     drawLightMap();
     prepareMainPass(node);
 }
        void prepareMainPassRecursive(Actor node)
        {
            if (node.GetType() == typeof(MeshObject))
            {
                foreach (ModelMesh mesh in ((MeshObject)node).Model.Meshes)
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        // Set the light map and viewport parameters to each model's effect
                        if (part.Effect.Parameters["LightTexture"] != null)
                            part.Effect.Parameters["LightTexture"].SetValue(lightTarg);

                        if (part.Effect.Parameters["viewportWidth"] != null)
                            part.Effect.Parameters["viewportWidth"].SetValue(viewWidth);

                        if (part.Effect.Parameters["viewportHeight"] != null)
                            part.Effect.Parameters["viewportHeight"].SetValue(viewHeight);
                    }
            }

            foreach (Actor child_node in node.Children)
                this.prepareMainPassRecursive(child_node);
        }
 void prepareMainPass(Actor rootNode)
 {
     prepareMainPassRecursive(rootNode);
 }
        void drawDepthNormalMapRecursive(Actor actor)
        {
            if (actor.GetType() == typeof(MeshObject))
            {
                ((MeshObject)actor).CacheEffects();
                ((MeshObject)actor).SetModelEffect(depthNormalEffect, false);

                ((MeshObject)actor).Render(this.sceneGraph);
                ((MeshObject)actor).RestoreCachedEffects();
            }

            foreach (Actor node in actor.Children)
                drawDepthNormalMapRecursive(node);
        }
        void drawDepthNormalMap(Actor rootNode)
        {
            // Set the render targets to 'slots' 1 and 2
            graphicsDevice.SetRenderTargets(normalTarg, depthTarg);

            // Clear the render target to 1 (infinite depth)
            graphicsDevice.Clear(Color.White);

            //render recursive
            drawDepthNormalMapRecursive(rootNode);

            // Un-set the render targets
            graphicsDevice.SetRenderTargets(null);
        }