×

Discussion Board

Results 1 to 10 of 10

Hybrid View

  1. #1
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Kista, Sweden
    Posts
    267

    How to get the current position from a M3G animation?

    I use AnimationController, AnimationTrack and KeyframeSequence to move the camera in 3D space. I need to get the current position, but I can't find any way to retrieve the current x,y and z values. I don't find any method that I can use for this in AnimationController, AnimationTrack and KeyframeSequence. This is very easy to do in OpenGL, but I find no way of solving this problem in M3G. Does anyone know how I can get the current position?

  2. #2
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: How to get the current position from a M3G animation?

    Hi MobileVisuals,

    You can get the angle and the axis from a Camera or a Mesh with the method getOrientation(float[] angleAxis).

    For example

    Code:
    float angleAndAxis[] = new float[4];//(angle x y z) 
    mesh.getOrientation(angleAndAxis);
    System.out.println(angleAndAxis[0]+" , "+angleAndAxis[1]+" , "+angleAndAxis[2]+" , "+angleAndAxis[3]);
    Regards,
    tiviinik

  3. #3
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Kista, Sweden
    Posts
    267

    Re: How to get the current position from a M3G animation?

    Thanks, I can get the current position now. I want to calculate the alpha transparency values of objects based on their distance to the camera in real time. I tried to make a AnimationTrack.ALPHA for this. I have to set the keyframe values for KeyframeSequence in animationInitialization().

    This doesn't seem to work because animationInitialization() is only called one time in the beginning of the app and from there, I have no way of setting the keyframe values based on the objects distance to the camera in real time. I have to set the keyframe values to fixed values. Do you know if there is any way to calculate the alpha transparency values of objects based on their distance to
    the camera in real time?

    I have got this to work in OpenGL, but I can't get it to work in M3G.

  4. #4
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: How to get the current position from a M3G animation?

    Hi MobileVisuals,

    You have to make a alpha apperance for your node and then use the setAlphaFactor(float) to set the alpha transparency. Below an example how to make the apperance.

    Code:
    		private Appearance alphaAppearance  = new Appearance();;
                      public void alphaAppearanceInit(Texture2D texture)
    		{
    		    PolygonMode alphaPolygonMode = new PolygonMode();
    		    alphaPolygonMode.setPerspectiveCorrectionEnable(true);
    
    		    alphaAppearance.setPolygonMode(alphaPolygonMode);
    
    		    CompositingMode alphaCompositeMode = new CompositingMode();
    		    alphaCompositeMode.setBlending(CompositingMode.ALPHA_ADD);
    		    alphaAppearance.setCompositingMode(alphaCompositeMode);
    		    
    		    alphaAppearance.setTexture(0, texture);
    			
    		}
    And then just set the appearance to your mesh and set the alpha factor.

    Code:
    mesh.setAppearance(0, alphaAppearance);
    mesh.setAlphaFactor(0.3f);
    -tiviinik

  5. #5
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Kista, Sweden
    Posts
    267

    Re: How to get the current position from a M3G animation?

    I see, but I want to calculate the alpha transparency values of objects based on their distance to the camera in real time. I have to set the keyframe values for KeyframeSequence in animationInitialization().

    AnimationInitialization() is only called one time in the beginning of the app. How can I set the keyframe values based on the objects distance to the camera in real time? This distance changes all the time. It seems like I only can set the keyframe values to fixed values in AnimationInitialization().

  6. #6
    Regular Contributor
    Join Date
    Dec 2011
    Posts
    174

    Re: How to get the current position from a M3G animation?

    Once you set and start the animation you can't change the values in real time by setting the keyframes in the KeyframeSequence. So they are fixed. But you can use methods like setTranslation(float,float,float), setOrientation(float,float,float), setAlphaFactor(float) in your thread to set values to objects.

    More on node methods see

    http://library.developer.nokia.com/i.../m3g/Node.html

    -tiviinik

Similar Threads

  1. Replies: 8
    Last Post: 2012-02-28, 04:39
  2. Showing the current position using the Google Maps API
    By chandran.biju007 in forum Symbian
    Replies: 0
    Last Post: 2010-04-29, 07:47
  3. Replies: 2
    Last Post: 2009-04-08, 06:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×