Exemplo n.º 1
0
        /// <summary>
        /// Create a new quadro
        /// </summary>
        /// <returns>The newly created quadro</returns>
        public override Frame CreateFrame(string name)
        {
            QuadroDerivado quadro = new QuadroDerivado();

            quadro.Name = name;
            quadro.TransformationMatrix         = Matrix.Identity;
            quadro.CombinedTransformationMatrix = Matrix.Identity;

            return(quadro);
        }
Exemplo n.º 2
0
        }         // ossos_ConfigurarMatrizes().fim

        /// <summary>
        /// Update the frames matrices and combine it with it's parents
        /// </summary>
        private void quadro_AtualizarMatrizes(QuadroDerivado frame, Matrix matrizPai)
        {
            frame.CombinedTransformationMatrix = frame.TransformationMatrix *
                                                 matrizPai;

            if (frame.FrameSibling != null)
            {
                quadro_AtualizarMatrizes((QuadroDerivado)frame.FrameSibling, matrizPai);
            }

            if (frame.FrameFirstChild != null)
            {
                quadro_AtualizarMatrizes((QuadroDerivado)frame.FrameFirstChild,
                                         frame.CombinedTransformationMatrix);
            }
        }
Exemplo n.º 3
0
        } // processaProximoQuadro().fim

        /// <summary>
        /// This method will set the bone matrices for a quadro
        /// </summary>
        private void ossos_ConfigurarMatrizes(QuadroDerivado frame)
        {
            if (frame.MeshContainer != null)
            {
                ossos_ConfigurarMatrizes((Packmesh)frame.MeshContainer);
            } // endif

            if (frame.FrameSibling != null)
            {
                ossos_ConfigurarMatrizes((QuadroDerivado)frame.FrameSibling);
            } // endif

            if (frame.FrameFirstChild != null)
            {
                ossos_ConfigurarMatrizes((QuadroDerivado)frame.FrameFirstChild);
            } // endif
        }     // ossos_ConfigurarMatrizes().fim
Exemplo n.º 4
0
        } // Renderizar().fim

        /// <summary>
        /// Draw a quadro and all child and sibling frames
        /// </summary>
        /// <param name="quadro">Frame to draw</param>
        private void desenharQuadro(QuadroDerivado frame)
        {
            Packmesh mesh = (Packmesh)frame.MeshContainer;

            while (mesh != null)
            {
                desenharPackmesh(mesh, frame);

                mesh = (Packmesh)mesh.NextContainer;
            } // endwhile

            if (frame.FrameSibling != null)
            {
                desenharQuadro((QuadroDerivado)frame.FrameSibling);
            } // endif

            if (frame.FrameFirstChild != null)
            {
                desenharQuadro((QuadroDerivado)frame.FrameFirstChild);
            } // endif
        }     // desenharQuadro().fim
Exemplo n.º 5
0
        }     // ossos_ConfigurarMatrizes().fim

        /// <summary>
        /// Sets the bone matrices for a packmesh container
        /// </summary>
        private void ossos_ConfigurarMatrizes(Packmesh mesh)
        {
            // Is there skin information?  If so, setup the matrices
            if (mesh.SkinInformation != null)
            {
                int nOssos = mesh.SkinInformation.NumberBones;

                QuadroDerivado[] frameMatrices = new QuadroDerivado[nOssos];
                for (int i = 0; i < nOssos; i++)
                {
                    QuadroDerivado frame = (QuadroDerivado)Frame.Find(
                        quadroRaiz.FrameHierarchy,
                        mesh.SkinInformation.GetBoneName(i));

                    if (frame == null)
                    {
                        throw new ArgumentException();
                    }

                    frameMatrices[i] = frame;
                } // endfor
                mesh.SetFrames(frameMatrices);
            }     // endif
        }         // ossos_ConfigurarMatrizes().fim
Exemplo n.º 6
0
        }     // desenharQuadro().fim

        /// <summary>
        /// Draw a meshcontainer
        /// </summary>
        /// <param name="packmesh">Mesh container to draw</param>
        /// <param name="quadro">Parent quadro of this container</param>
        private void desenharPackmesh(Packmesh mesh, QuadroDerivado frame)
        {
            // Is there skin information?
            if (mesh.SkinInformation != null)
            {
                int attribIdPrev = -1;

                // Draw
                for (int iattrib = 0; iattrib < mesh.nAtributos; iattrib++)
                {
                    int numBlend            = 0;
                    BoneCombination[] bones = mesh.GetBones();
                    for (int i = 0; i < mesh.nInfluencias; i++)
                    {
                        if (bones[iattrib].BoneId[i] != -1)
                        {
                            numBlend = i;
                        } // endif
                    }     // endfor

                    if (device.DeviceCaps.MaxVertexBlendMatrices >= numBlend + 1)
                    {
                        // first calculate the world matrices for the current set of
                        // blend weights and get the accurate count of the number of
                        // blends
                        Matrix[]         offsetMatrices = mesh.GetOffsetMatrices();
                        QuadroDerivado[] frameMatrices  = mesh.GetFrames();
                        for (int i = 0; i < mesh.nInfluencias; i++)
                        {
                            int matrixIndex = bones[iattrib].BoneId[i];
                            if (matrixIndex != -1)
                            {
                                Matrix tempMatrix = offsetMatrices[matrixIndex] *
                                                    frameMatrices[matrixIndex].CombinedTransformationMatrix;

                                device.Transform.SetWorldMatrixByIndex(i, tempMatrix);
                            } // endif
                        }     // endfor

                        device.RenderState.VertexBlend = (VertexBlend)numBlend;
                        // lookup the material used for this subset of faces
                        if ((attribIdPrev != bones[iattrib].AttribId) ||
                            (attribIdPrev == -1))
                        {
                            device.Material = mesh.GetMaterials()[
                                bones[iattrib].AttribId].Material3D;

                            device.SetTexture(0, mesh.GetTextures()[
                                                  bones[iattrib].AttribId]);

                            attribIdPrev = bones[iattrib].AttribId;
                        }// endif

                        mesh.MeshData.Mesh.DrawSubset(iattrib);
                    }
                }
            }    // endif
            else // standard packmesh, just draw it after setting material properties
            {
                device.Transform.World = frame.CombinedTransformationMatrix;

                ExtendedMaterial[] mtrl = mesh.GetMaterials();
                for (int iMaterial = 0; iMaterial < mtrl.Length; iMaterial++)
                {
                    device.Material = mtrl[iMaterial].Material3D;
                    device.SetTexture(0, mesh.GetTextures()[iMaterial]);
                    mesh.MeshData.Mesh.DrawSubset(iMaterial);
                } // endfor
            }     // endelse
        }         // desenharPackmesh().fim