Ejemplo n.º 1
0
        public Light Transform(Matrix44 mat)
        {
            Light ret = new Light(this);

            if (position != null)
            {
                ret.position = position.MultMat(mat);
            }
            if (direction != null)
            {
                ret.direction = direction.MultMat(mat.DtMat());
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public void UpdateDispParam(SimulatorInterface simif, double dt)
        {
            Matrix44 mtemp   = new Matrix44();
            Matrix44 mat_aft = new Matrix44();

            BoundingBox bbx = locus.locusBBox;
            double      v   = bbx.DiagonalSize() / moveingTime;
            double      w   = 6.283185307179586D / rotationTime;

            double acc = 1.0D;

            if (simif.ctrl_sw == 1)
            {
                acc = 0.1D;
            }
            if (simif.locus_action_sw[0] == 1)
            {
                mtemp.SetRzMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[1] == 1)
            {
                mtemp.SetRzMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[2] == 1)
            {
                mtemp.SetRxMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[3] == 1)
            {
                mtemp.SetRxMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[4] == 1)
            {
                mtemp.SetRyMat(w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[5] == 1)
            {
                mtemp.SetRyMat(-w * dt * acc);
                rmat = rmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[6] == 1)
            {
                dist -= v * dt * 3.0D * acc;
                mtemp.SetTMat(0.0D, 0.0D, -v * dt * 3.0D * acc);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[7] == 1)
            {
                dist += v * dt * 3.0D * acc;
                mtemp.SetTMat(0.0D, 0.0D, v * dt * 3.0D * acc);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[10] == 1)
            {
                mtemp.SetTMat(v * dt * acc, 0.0D, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[11] == 1)
            {
                mtemp.SetTMat(-v * dt * acc, 0.0D, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[8] == 1)
            {
                mtemp.SetTMat(0.0D, v * dt * acc, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }
            if (simif.locus_action_sw[9] == 1)
            {
                mtemp.SetTMat(0.0D, -v * dt * acc, 0.0D);
                tmat = tmat.MultMat(mtemp);
            }

            if (simif.param_reset_sw == 1)
            {
                InitDispParam();
                simif.locusImageMake = 1;
                simif.param_reset_sw = 0;
            }

            int flag_move_data = 0;

            if (simif.data_foword_sw == 1)
            {
                flag_move_data = 1;
                if (simif.ctrl_sw == 1)
                {
                    currentDataIndex += fastMoveStep;
                }
                else
                {
                    currentDataIndex += 1;
                }
                if (currentDataIndex >= recorder.N_record())
                {
                    currentDataIndex = (recorder.N_record() - 1);
                }
            }
            if (simif.data_back_sw == 1)
            {
                flag_move_data = 1;
                if (simif.ctrl_sw == 1)
                {
                    currentDataIndex -= fastMoveStep;
                }
                else
                {
                    currentDataIndex -= 1;
                }
                if (currentDataIndex < 0)
                {
                    currentDataIndex = 0;
                }
            }
            if (flag_move_data == 1)
            {
                RecordData data = recorder.GetData(currentDataIndex);
                mtemp.SetMat(mat_bef);
                mat_bef.SetTMat(-data.wpos.x, -data.wpos.y, -data.wpos.z);
                mat_aft = mat_bef.InvMat().MultMat(mtemp).MultMat(rmat).MultMat(tmat);
                rmat    = mat_aft.DtMat();
                tmat.SetTMat(mat_aft.element[3, 0], mat_aft.element[3, 1], mat_aft.element[3, 2]);
            }
        }