• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.jme3.network.serializing.serializers;
2 
3 import com.jme3.math.Vector3f;
4 import com.jme3.network.serializing.Serializer;
5 import java.io.IOException;
6 import java.nio.ByteBuffer;
7 
8 /**
9  * @author Kirill Vainer
10  */
11 @SuppressWarnings("unchecked")
12 public class Vector3Serializer extends Serializer {
13 
readObject(ByteBuffer data, Class c)14     public Vector3f readObject(ByteBuffer data, Class c) throws IOException {
15         Vector3f vec3 = new Vector3f();
16         vec3.x = data.getFloat();
17         vec3.y = data.getFloat();
18         vec3.z = data.getFloat();
19         return vec3;
20     }
21 
writeObject(ByteBuffer buffer, Object object)22     public void writeObject(ByteBuffer buffer, Object object) throws IOException {
23         Vector3f vec3 = (Vector3f) object;
24         buffer.putFloat(vec3.x);
25         buffer.putFloat(vec3.y);
26         buffer.putFloat(vec3.z);
27     }
28 }
29