示例#1
0
    // Update is called once per frame
    public override void OnFlexUpdate(FlexContainer.ParticleData _particleData)
    {
        //base.OnFlexUpdate(_particleData);

        if (m_actor && m_actor.container)
        {
            m_actor.container.AddFluidIndices(m_actor.indices, m_actor.indexCount);
        }

        if (Application.IsPlaying(this))
        {
            Vector4[] particles = new Vector4[10000];
            //_particleData.GetParticles(0, 9999, particles);
            _particleData.GetRestParticles(0, 9999, particles);

            Array.Sort <Vector4>(particles, new Comparison <Vector4>(
                                     (i1, i2) => Vector4.SqrMagnitude(i2).CompareTo(Vector4.SqrMagnitude(i1))));

            //RMMemoryManager rmm = Camera.main.GetComponent<RMMemoryManager>();
            //List<RMPrimitive> prims = rmm.RM_Prims;
            RayMarcher   rayMarcher = Camera.main.GetComponent <RayMarcher>();
            List <RMObj> renderList = rayMarcher.RenderList;
            Vector4      force;

            for (int i = 0; i < 28; ++i)
            {
                force  = particles[i];
                force += new Vector4(0.0f, -9.81f, 0.0f, 0.0f);
                renderList[i].transform.position += new Vector3(force.x, force.y, force.z) * Time.deltaTime;
            }
        }
    }
示例#2
0
    // It can be used to configure render targets and their clear state. Also to create temporary render target textures.
    // When empty this render pass will render to the active camera render target.
    // You should never call CommandBuffer.SetRenderTarget. Instead call <c>ConfigureTarget</c> and <c>ConfigureClear</c>.
    // The render pipeline will ensure target setup and clearing happens in an performance manner.
    protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd)
    {
        // Setup code here
        _rayMarcher = RayMarcher.Instance;

        _rayMarchMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("Standard"));

        customMaterialProperties = new MaterialPropertyBlock();

        //colourBuffer = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension,
        //                                colorFormat: GraphicsFormat.)
        _distTex = RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension,
                                   colorFormat: GraphicsFormat.R32_SFloat);
    }
示例#3
0
文件: RMObj.cs 项目: MBE2FL/GDW
    protected virtual void OnEnable()
    {
        _drawOrder         = serializedObject.FindProperty("_drawOrder");
        _static            = serializedObject.FindProperty("_static");
        _combineOpType     = serializedObject.FindProperty("_combineOpType");
        _combineSmoothness = serializedObject.FindProperty("_combineSmoothness");

        // Alteration stuff
        _displaceFormula = serializedObject.FindProperty("_displaceFormula");

        // Store all alterations for later use.
        for (int i = 1; i <= 5; ++i)
        {
            _alts.Add(serializedObject.FindProperty("alt" + i));
        }

        _boundShape   = serializedObject.FindProperty("_boundShape");
        _boundGeoInfo = serializedObject.FindProperty("_boundGeoInfo");

        _rayMarcher = Camera.main.GetComponent <RayMarcher>();
    }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        _rayMarcher = Camera.main.GetComponent <RayMarcher>();

        Flex.Params param = new Flex.Params();
        param.radius            = 10.0f;
        param.fluidRestDistance = 1.0f;
        param.gravity           = new Vector3(0.0f, -9.81f, 0.0f);
        //param.viscosity = 10.0f;

        Flex.SetParams(_solver, ref param);


        // Map buffers for reading / writing.
        particles  = Flex.Map(_particleBuffer);
        velocities = Flex.Map(_velocityBuffer);
        phases     = Flex.Map(_phaseBuffer);

        // Spawn particles.
        spawnParticles(particles, velocities, phases);
    }
示例#5
0
 // Start is called before the first frame update
 void Start()
 {
     // Retrieve a reference to the ray marcher from the main camera.
     //_rayMarcher = Camera.main.GetComponent<RayMarcher>();
     _rayMarcher = RayMarcher.Instance;
 }