/// <summary>
 /// Initializes a new instance of the <see cref="VertexCompressor"/> class.
 /// </summary>
 /// <param name="info">The compression info to use.</param>
 public VertexCompressor(RenderModel.CompressionInfo info)
 {
     _info = info;
     _xScale = info.PositionMaxX - info.PositionMinX;
     _yScale = info.PositionMaxY - info.PositionMinY;
     _zScale = info.PositionMaxZ - info.PositionMinZ;
     _uScale = info.TextureMaxU - info.TextureMinU;
     _vScale = info.TextureMaxV - info.TextureMinV;
 }
        public static CommandContext Create(CommandContext parent, OpenTagCache info, TagInstance tag, RenderModel renderModel)
        {
            var groupName = info.StringIds.GetString(tag.GroupName);

            var context = new CommandContext(parent,
                string.Format("{0:X8}.{1}", tag.Index, groupName));

            Populate(context, info, tag, renderModel);

            return context;
        }
 public SpecifyShadersCommand(OpenTagCache info, TagInstance tag, RenderModel definition)
     : base(CommandFlags.Inherit,
           "SpecifyShaders",
           "Allows the shaders of a render_model to be respecified.",
           "SpecifyShaders",
           "Allows the shaders of a render_model to be respecified.")
 {
     Info = info;
     Tag = tag;
     Definition = definition;
 }
        /// <summary>
        /// Adds a node to the model.
        /// </summary>
        /// <param name="node">The node to add.</param>
        /// <returns>The node index.</returns>
        public byte AddNode(RenderModel.Node node)
        {
            _model.Nodes.Add(node);
            
            // Generate runtime data
            _model.RuntimeNodes.Add(new RenderModel.RuntimeNode
            {
                Translation = node.DefaultTranslation,
                Rotation = node.DefaultRotation,
                Scale = node.DefaultScale,
            });

            return (byte)(_model.Nodes.Count - 1);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get an Assimp matrix for the mesh of a rendermesh.
        /// This is an approximation of the logic applied by the 
        ///  game to scaling the model using the assigned node.
        /// </summary>
        public static Assimp.Matrix4x4 getMatForMesh(RenderModel model, Mesh mesh)
        {
            var rot_mat = Assimp.Matrix3x3.Identity;
            int node_idx = mesh.RigidNodeIndex;
            if (node_idx < 0) {
                node_idx = 0;
            }
            if (node_idx < model.Nodes.Count)
            {
                float s = model.Nodes[node_idx].DefaultScale;
                RenderModel.Node node = model.Nodes[node_idx];
                rot_mat = new Assimp.Matrix3x3(node.InverseForward.X *s , node.InverseForward.Y * s, node.InverseForward.Z*s,
                                                    node.InverseLeft.X*s, node.InverseLeft.Y*s, node.InverseLeft.Z*s,
                                                    node.InverseUp.X*s, node.InverseUp.Y*s, node.InverseUp.Z*s);
                //Console.WriteLine("Loaded matrix: {0}", rot_mat);

            }

            var matrix_local = new Assimp.Matrix4x4(rot_mat);
            return matrix_local;
        }
 public static void Populate(CommandContext context, OpenTagCache info, TagInstance tag, RenderModel renderModel)
 {
     context.AddCommand(new SpecifyShadersCommand(info, tag, renderModel));
 }
 /// <summary>
 /// Adds a material to the model.
 /// </summary>
 /// <param name="material">The material.</param>
 /// <returns>The material index.</returns>
 public short AddMaterial(RenderModel.Material material)
 {
     _model.Materials.Add(material);
     return (short)(_model.Materials.Count - 1);
 }