MeshAnimation.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2009-2010 jMonkeyEngine
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are
  7. * met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. *
  12. * * Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  22. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  23. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  28. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. package com.jme3.animation;
  33. import java.io.IOException;
  34. import com.jme3.export.InputCapsule;
  35. import com.jme3.export.JmeExporter;
  36. import com.jme3.export.JmeImporter;
  37. import com.jme3.export.OutputCapsule;
  38. import com.jme3.scene.Mesh;
  39. /**
  40. *
  41. * @author Kirill Vainer
  42. * @deprecated use Animation instead with tracks of selected type (ie. BoneTrack, SpatialTrack, MeshTrack)
  43. */
  44. @Deprecated
  45. public class MeshAnimation extends Animation {
  46. private String name;
  47. private float length;
  48. private PoseTrack[] tracks;
  49. public MeshAnimation(String name, float length){
  50. this.name = name;
  51. this.length = length;
  52. }
  53. public String getName(){
  54. return name;
  55. }
  56. public float getLength(){
  57. return length;
  58. }
  59. public void setTracks(PoseTrack[] tracks){
  60. this.tracks = tracks;
  61. }
  62. public PoseTrack[] getTracks(){
  63. return tracks;
  64. }
  65. public void setTime(float time, Mesh[] targets, float weight){
  66. for (int i = 0; i < tracks.length; i++){
  67. tracks[i].setTime(time, targets, weight);
  68. }
  69. }
  70. @Override
  71. public void setTime(float time, float blendAmount, AnimControl control, AnimChannel channel) {
  72. // TODO: ...
  73. }
  74. public void write(JmeExporter e) throws IOException {
  75. OutputCapsule out = e.getCapsule(this);
  76. out.write(name, "name", "");
  77. out.write(length, "length", -1f);
  78. out.write(tracks, "tracks", null);
  79. }
  80. public void read(JmeImporter i) throws IOException {
  81. InputCapsule in = i.getCapsule(this);
  82. name = in.readString("name", "");
  83. length = in.readFloat("length", -1f);
  84. tracks = (PoseTrack[]) in.readSavableArray("tracks", null);
  85. }
  86. }