Log in or register to post comments

Teapot on Fire tutorial files

April 23, 2012 - 1:10pm #10

Hi there-

On the Qualcomm developer site (https://developer.qualcomm.com/develop/mobile-technologies/augmented-reality-vuforia/videos) there is a tutorial video from July 2011 showing a sample app built in unity where you can drag a teapot onto a fire and it starts to steam. Watching the tutorial he references some scripts and some tutorial assets to make this work.

I was interested in picking these apart to learn how it all works...does anyone know where I could find this to download?

Thanks!

Re: Teapot on Fire tutorial files

April 24, 2012 - 6:17pm #9

This demo isn't part of our offering of sample apps, sorry!

If you have any specific questions about how to build something similar let us know. Thanks,

- Kim

Re: Teapot on Fire tutorial files

May 10, 2012 - 3:15pm #8

During the Vuforia demo at ARE 2012 Day 1, someone asked Roy this exact question and his reply was essentially, "Check the discussion boards, there are a few threads that tell you where to get this." In essence, he did not say that the assets for this demo are unavailable.

What gives? The only thing that seems to be needed are fire and steam animations, since teapots, markers, etc. ARE available in the distributed packages. My guess is that fire and steam are commercial packages from the Unity asset store and therefore not OK to distribute freely. If that's the case, why not just tell us?

Re: Teapot on Fire tutorial files

May 11, 2012 - 11:27am #7

I think the fire and steam are just Unity particle systems. If you import the standard "Particles" package you should find some similar ones. I'll look into sharing some code snippets here.

- Kim

Re: Teapot on Fire tutorial files

May 13, 2012 - 7:42pm #6

The code is pretty simple. Here is a VirtualButtonEventHandler that starts and stops the steam:

using UnityEngine;

public class VirtualButtonEventHandler :    MonoBehaviour,
                                            IVirtualButtonEventHandler
{
    private ParticleEmitter mSteamEmitter = null;

    void Start()
    {
        // Register with the virtual buttons TrackableBehaviour
        VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
        for (int i = 0; i < vbs.Length; ++i)
        {
            vbs[i].RegisterEventHandler(this);
        }

        // Get handle to the teapot object
        mSteamEmitter = GetComponentInChildren<ParticleEmitter>();
        
        if (mSteamEmitter)
            mSteamEmitter.emit = false;
    }


    // Called when the virtual button has just been pressed:
    public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
        if (mSteamEmitter)
            mSteamEmitter.emit = true;
    }


    // Called when the virtual button has just been released:
    public void OnButtonReleased(VirtualButtonBehaviour vb)
    {
        if (mSteamEmitter)
            mSteamEmitter.emit = false;
    }
}

And here's a behavior that finds the distance between two targets to start the steam when the teapot gets close to the fire:

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleEmitter))]
public class BoilingBehaviour : MonoBehaviour
{
    public float heatingDistance = 0.0f;  // set in inspector
    public GameObject m_Fireplace = null;  // set in inspector
    private GameObject m_Teapot = null;

    void Start ()
    {
        m_Teapot = this.transform.root.gameObject;
    }

    void Update ()
    {        
        float teapotToFireDistance = Vector2.Distance(new Vector2(m_Teapot.transform.position.x, m_Teapot.transform.position.z),
                                                      new Vector2(m_Fireplace.transform.position.x, m_Fireplace.transform.position.z));

        if (teapotToFireDistance < heatingDistance)
        {
            this.particleEmitter.emit = true;
        }
        else
        {
            this.particleEmitter.emit = false;
        }
    }
}

- Kim

Teapot on Fire tutorial files

July 21, 2012 - 6:16am #5

Hi,Ksiva.

 float teapotToFireDistance = Vector2.Distance(new Vector2(m_Teapot.transform.position.x, m_Teapot.transform.position.z), new Vector2(m_Fireplace.transform.position.x, m_Fireplace.transform.position.z));

teapotToFireDistance changed when my iphone camera(ARCamrea) far or near from the Image Target, but I want to a fixed value that just distance between teapot and fire, and unaffected by ARCamrea.

so how to modify the code?

Thanks!

Teapot on Fire tutorial files

July 22, 2012 - 6:09pm #4

Please see my response to your other post on this question.

Teapot on Fire tutorial files

July 23, 2012 - 9:28am #3

Thanks DavidBeard, now my code is"

using UnityEngine;

using System.Collections;

[RequireComponent(typeof(ParticleEmitter))]

public class BoilingBehaviour : MonoBehaviour {

    public float heatingDistance = 0.0f;  // set in inspector

    public GameObject m_Fireplace = null;  // set in inspector

    public GameObject m_Teapot = null// set in inspector

 

    void Update (){

        float teapotToFireDistance = Vector3.Distance(m_Teapot.transform.position, m_Fireplace.transform.position);

        Debug.Log(teapotToFireDistance);

 

        if (teapotToFireDistance < heatingDistance) {

            this.particleEmitter.emit = true;

        } else {

            this.particleEmitter.emit = false;

        }

    }

}

 

I check the distance from debug log, when the distance between teapot and fireplace was fixed, the distance value still change by the position of the ARCamera. when ARcamera was near, the value reduce, and when ARcamera was far away, the value increase.

So what I want is the value unaffected by ARCamrea.

Teapot on Fire tutorial files

July 23, 2012 - 2:53pm #2

Hello,

It sounds like you set the camera object where you want to set the teapot object. Check in the Unity inspector for your script that the m_teapot is set as your teapot and not the arcamera. Where have you attached this script? 

Thank you,

-Peter

Teapot on Fire tutorial files

July 23, 2012 - 10:40pm #1

Let's consolidate this question to a single thread so that we can track the responses. Please respond to - https://ar.qualcomm.at/content/calculate-distance-between-two-3d-object

Log in or register to post comments