Пример #1
0
        //ya rab ostor
        //update vertex button
        private void updateButtonAnimation_Click(object sender, EventArgs e)
        {
            string selectedVertex   = currentVerticesAnimationListBox.SelectedItem.ToString();
            string selectedKeyFrame = keyFarmesAnimationListBox.SelectedItem.ToString();

            // Dictionary<string, List<float>> keyFrameData = new Dictionary<string, List<float>>();

            #region updating
            if (xPosAnimationTextBox.Text != "")
            {
                xPos = (float)Convert.ToDouble(xPosAnimationTextBox.Text);
            }

            if (yPosAnimationTextBox.Text != "")
            {
                yPos = (float)Convert.ToDouble(yPosAnimationTextBox.Text);
            }

            if (zPosAnimationTextBox.Text != "")
            {
                zPos = (float)Convert.ToDouble(zPosAnimationTextBox.Text);
            }

            if (rColorAnimationTextBox.Text != "")
            {
                rColor = (float)Convert.ToDouble(rColorAnimationTextBox.Text);
            }

            if (gColorAnimationTextBox.Text != "")
            {
                gColor = (float)Convert.ToDouble(gColorAnimationTextBox.Text);
            }

            if (bColorAnimationTextBox.Text != "")
            {
                bColor = (float)Convert.ToDouble(bColorAnimationTextBox.Text);
            }

            if (normalXAnimationTextBox.Text != "")
            {
                normalX = (float)Convert.ToDouble(normalXAnimationTextBox.Text);
            }

            if (normalYAnimationTextBox.Text != "")
            {
                normalY = (float)Convert.ToDouble(normalYAnimationTextBox.Text);
            }

            if (normalZAnimationTextBox.Text != "")
            {
                normalZ = (float)Convert.ToDouble(normalZAnimationTextBox.Text);
            }

            if (UdataAnimationTextBox.Text != "")
            {
                udata = (float)Convert.ToDouble(UdataAnimationTextBox.Text);
            }

            if (VdataAnimationTextBox.Text != "")
            {
                vdata = (float)Convert.ToDouble(VdataAnimationTextBox.Text);
            }

            List <float> vertexList = new List <float>();
            vertexList.Add(xPos);
            vertexList.Add(yPos);
            vertexList.Add(zPos);
            vertexList.Add(rColor);
            vertexList.Add(gColor);
            vertexList.Add(bColor);
            vertexList.Add(udata);
            vertexList.Add(vdata);
            vertexList.Add(normalX);
            vertexList.Add(normalY);
            vertexList.Add(normalZ);
            #endregion

            //3shan a7otha ll keyframe ely ba3do
            upTodateVertexDict[selectedVertex] = vertexList;
            //hashof law h3ml keda 3shan mayb2ash bt referece w kolohom byboso 3la nfs el dic
            Dictionary <string, List <float> > newDict = new Dictionary <string, List <float> >(upTodateVertexDict);

            KeyFrame updatedKeyFrame = new KeyFrame(newDict, Convert.ToInt32(InterpolateFrametextBox.Text));

            vertexKeyFramesDict[selectedKeyFrame] = updatedKeyFrame;

            //// vertexDict[selectedVertex] = vertexList;
            MessageBox.Show("Keyframe updated");
        }
Пример #2
0
        public void importData(string[] data)
        {
            int verticesCount = Convert.ToInt32(data[0]);

            for (int i = 0; i < verticesCount; i++)
            {
                string[]     vertexData = data[i + 1].Split(' ');
                List <float> vertexList = new List <float>();

                vertexList.Add(float.Parse(vertexData[1]));
                vertexList.Add(float.Parse(vertexData[2]));
                vertexList.Add(float.Parse(vertexData[3]));
                vertexList.Add(float.Parse(vertexData[4]));
                vertexList.Add(float.Parse(vertexData[5]));
                vertexList.Add(float.Parse(vertexData[6]));
                vertexList.Add(float.Parse(vertexData[7]));
                vertexList.Add(float.Parse(vertexData[8]));
                vertexList.Add(float.Parse(vertexData[9]));
                vertexList.Add(float.Parse(vertexData[10]));
                vertexList.Add(float.Parse(vertexData[11]));

                vertexDict[vertexData[0]] = vertexList;
            }

            // import indices
            int indicesCount = Convert.ToInt32(data[verticesCount + 1]);

            string[] indices = data[verticesCount + 2].Split(' ');
            for (int i = 0; i < indicesCount; i++)
            {
                vertexIndices.Add(Convert.ToUInt16(indices[i]));
            }

            // import mode
            int modesCount = Convert.ToInt32(data[verticesCount + 3]);

            for (int i = 0; i < modesCount; i++)
            {
                string[]         modess       = data[modesCount + verticesCount + 3 + i].Split(' ');
                string           modeName     = modess[0] + " " + modess[1];
                int              startIndex   = Convert.ToInt32(modess[2]);
                int              countIndices = Convert.ToInt32(modess[3]);
                Tuple <int, int> t            = new Tuple <int, int>(startIndex, countIndices);
                modesDict[modeName] = t;
            }
            // import light
            string[] lightData = data[verticesCount + 3 + modesCount + 1].Split(' ');
            lightDataList = new List <float>();
            lightDataList.Add(float.Parse(lightData[0]));
            lightDataList.Add(float.Parse(lightData[1]));
            lightDataList.Add(float.Parse(lightData[2]));
            lightDataList.Add(float.Parse(lightData[3]));
            lightDataList.Add(float.Parse(lightData[4]));
            lightDataList.Add(float.Parse(lightData[5]));
            lightDataList.Add(float.Parse(lightData[6]));
            lightDataList.Add(float.Parse(lightData[7]));
            lightDataList.Add(float.Parse(lightData[8]));
            lightDataList.Add(float.Parse(lightData[9]));
            lightDataList.Add(float.Parse(lightData[10]));
            lightDataList.Add(float.Parse(lightData[11]));
            lightDataList.Add(float.Parse(lightData[12]));

            // import texture path
            texturePath = data[verticesCount + 3 + modesCount + 1 + 1];

            // import key frames
            int          keyFrameCount = Convert.ToInt32(data[verticesCount + 3 + modesCount + 1 + 1 + 1]);
            List <float> vertexListt;

            for (int i = 0; i < keyFrameCount; i++)
            {
                string[] keyFrameData = data[verticesCount + 3 + modesCount + 1 + 1 + 1 + i + 1].Split(' ');
                string   keyFrameName = keyFrameData[0] + " " + keyFrameData[1];
                Dictionary <string, List <float> > newDict = new Dictionary <string, List <float> >();

                for (int j = 0; j < verticesCount; j++)
                {
                    vertexListt = new List <float>();
                    vertexListt.Add(float.Parse(keyFrameData[3 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[4 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[5 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[6 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[7 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[8 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[9 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[10 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[11 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[12 + (12 * j)]));
                    vertexListt.Add(float.Parse(keyFrameData[13 + (12 * j)]));
                    newDict[keyFrameData[2 + (12 * j)]] = vertexListt;
                }
                KeyFrame updatedKeyFrame = new KeyFrame(newDict, Convert.ToInt32(keyFrameData[keyFrameData.Length - 2]));
                vertexKeyFramesDict[keyFrameName] = updatedKeyFrame;
            }
        }