Search in sources :

Example 91 with Type

use of com.jme3.scene.VertexBuffer.Type in project jmonkeyengine by jMonkeyEngine.

the class RmiHostedService method shareGlobal.

/**
     *  Shares a server-wide object associated with the specified name over the specified
     *  channel.  All connections with RMI hosting started will have access to this shared 
     *  object as soon as they connect and they will all share the same instance.  It is up 
     *  to the shared object to handle any multithreading that might be required.
     *  All network communcation associated with the shared object will be done over
     *  the specified channel. 
     */
public <T> void shareGlobal(byte channel, String name, T object, Class<? super T> type) {
    GlobalShare share = new GlobalShare(channel, object, type);
    GlobalShare existing = globalShares.put(name, share);
    if (existing != null) {
    // Shouldn't need to do anything actually.
    }
    // Go through all of the children
    for (HostedConnection conn : getServer().getConnections()) {
        RmiRegistry child = getRmiRegistry(conn);
        if (child == null) {
            continue;
        }
        child.share(channel, name, object, type);
    }
}
Also used : HostedConnection(com.jme3.network.HostedConnection)

Example 92 with Type

use of com.jme3.scene.VertexBuffer.Type in project jmonkeyengine by jMonkeyEngine.

the class MapSerializer method readObject.

/*

    Structure:

    struct Map {
        INT length
        BYTE flags = { 0x01 = all keys have the same type,
                       0x02 = all values have the same type }
        if (flags has 0x01 set)
            SHORT keyType
        if (flags has 0x02 set)
            SHORT valType

        struct MapEntry[length] entries {
            if (flags does not have 0x01 set)
                SHORT keyType
            OBJECT key

            if (flags does not have 0x02 set)
                SHORT valType
            OBJECT value
        }
    }

     */
@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
    int length = data.getInt();
    Map map;
    try {
        map = (Map) c.newInstance();
    } catch (Exception e) {
        log.log(Level.WARNING, "[Serializer][???] Could not determine map type. Using HashMap.");
        map = new HashMap();
    }
    if (length == 0)
        return (T) map;
    int flags = data.get() & 0xff;
    boolean uniqueKeys = (flags & 0x01) == 0;
    boolean uniqueVals = (flags & 0x02) == 0;
    Class keyClazz = null;
    Class valClazz = null;
    Serializer keySerial = null;
    Serializer valSerial = null;
    if (!uniqueKeys) {
        SerializerRegistration reg = Serializer.readClass(data);
        keyClazz = reg.getType();
        keySerial = reg.getSerializer();
    }
    if (!uniqueVals) {
        SerializerRegistration reg = Serializer.readClass(data);
        valClazz = reg.getType();
        valSerial = reg.getSerializer();
    }
    for (int i = 0; i < length; i++) {
        Object key;
        Object value;
        if (uniqueKeys) {
            key = Serializer.readClassAndObject(data);
        } else {
            key = keySerial.readObject(data, keyClazz);
        }
        if (uniqueVals) {
            value = Serializer.readClassAndObject(data);
        } else {
            value = valSerial.readObject(data, valClazz);
        }
        map.put(key, value);
    }
    return (T) map;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) IOException(java.io.IOException) SerializerRegistration(com.jme3.network.serializing.SerializerRegistration) Serializer(com.jme3.network.serializing.Serializer)

Example 93 with Type

use of com.jme3.scene.VertexBuffer.Type in project jmonkeyengine by jMonkeyEngine.

the class FieldSerializer method readObject.

@SuppressWarnings("unchecked")
public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException {
    // Read the null/non-null marker
    if (data.get() == 0x0)
        return null;
    SavedField[] fields = savedFields.get(c);
    T object;
    try {
        Constructor<T> ctor = (Constructor<T>) savedCtors.get(c);
        object = ctor.newInstance();
    } catch (Exception e) {
        throw new SerializerException("Error creating object of type:" + c, e);
    }
    for (SavedField savedField : fields) {
        Field field = savedField.field;
        Serializer serializer = savedField.serializer;
        if (log.isLoggable(Level.FINER)) {
            log.log(Level.FINER, "Reading field:{0} using serializer:{1}", new Object[] { field, serializer });
        }
        Object value;
        if (serializer != null) {
            value = serializer.readObject(data, field.getType());
        } else {
            value = Serializer.readClassAndObject(data);
        }
        try {
            field.set(object, value);
        } catch (IllegalAccessException e) {
            throw new SerializerException("Error reading object", e);
        }
    }
    return object;
}
Also used : Field(java.lang.reflect.Field) Constructor(java.lang.reflect.Constructor) SerializerException(com.jme3.network.serializing.SerializerException) BufferOverflowException(java.nio.BufferOverflowException) IOException(java.io.IOException) SerializerException(com.jme3.network.serializing.SerializerException) Serializer(com.jme3.network.serializing.Serializer)

Example 94 with Type

use of com.jme3.scene.VertexBuffer.Type in project jmonkeyengine by jMonkeyEngine.

the class FbxLoader method connectObjects.

private void connectObjects(FbxElement element) {
    if (objectMap.isEmpty()) {
        logger.log(Level.WARNING, "FBX file is missing object information");
        return;
    } else if (objectMap.size() == 1) {
        // Only root node (automatically added by jME3)
        logger.log(Level.WARNING, "FBX file has no objects");
        return;
    }
    for (FbxElement el : element.children) {
        if (!el.id.equals("C") && !el.id.equals("Connect")) {
            continue;
        }
        String type = (String) el.properties.get(0);
        FbxId childId;
        FbxId parentId;
        if (type.equals("OO")) {
            childId = FbxId.create(el.properties.get(1));
            parentId = FbxId.create(el.properties.get(2));
            FbxObject child = objectMap.get(childId);
            FbxObject parent;
            if (parentId.isNull()) {
                // TODO: maybe clean this up a bit..
                parent = objectMap.get(FbxId.ROOT);
            } else {
                parent = objectMap.get(parentId);
            }
            if (parent == null) {
                throw new UnsupportedOperationException("Cannot find parent object ID \"" + parentId + "\"");
            }
            parent.connectObject(child);
        } else if (type.equals("OP")) {
            childId = FbxId.create(el.properties.get(1));
            parentId = FbxId.create(el.properties.get(2));
            String propName = (String) el.properties.get(3);
            FbxObject child = objectMap.get(childId);
            FbxObject parent = objectMap.get(parentId);
            parent.connectObjectProperty(child, propName);
        } else {
            logger.log(Level.WARNING, "Unknown connection type: {0}. Ignoring.", type);
        }
    }
}
Also used : FbxElement(com.jme3.scene.plugins.fbx.file.FbxElement) FbxObject(com.jme3.scene.plugins.fbx.obj.FbxObject) FbxId(com.jme3.scene.plugins.fbx.file.FbxId)

Example 95 with Type

use of com.jme3.scene.VertexBuffer.Type in project jmonkeyengine by jMonkeyEngine.

the class SceneLoader method loadDeformer.

private FbxObject loadDeformer(FbxElement element) {
    String type = (String) element.properties.get(2);
    switch(type) {
        case "Skin":
            FbxSkin skinData = new FbxSkin(this, element);
            skinMap.put(skinData.id, skinData);
            return skinData;
        case "Cluster":
            FbxCluster clusterData = new FbxCluster(this, element);
            return clusterData;
    }
    return null;
}
Also used : FbxCluster(com.jme3.scene.plugins.fbx.objects.FbxCluster) FbxSkin(com.jme3.scene.plugins.fbx.objects.FbxSkin)

Aggregations

ArrayList (java.util.ArrayList)18 Structure (com.jme3.scene.plugins.blender.file.Structure)12 Vector3f (com.jme3.math.Vector3f)11 Pointer (com.jme3.scene.plugins.blender.file.Pointer)10 IOException (java.io.IOException)10 List (java.util.List)9 ColorRGBA (com.jme3.math.ColorRGBA)8 Texture (com.jme3.texture.Texture)8 Geometry (com.jme3.scene.Geometry)6 Image (com.jme3.texture.Image)6 BoundingBox (com.jme3.bounding.BoundingBox)5 BoundingSphere (com.jme3.bounding.BoundingSphere)5 Light (com.jme3.light.Light)5 TemporalMesh (com.jme3.scene.plugins.blender.meshes.TemporalMesh)5 Uniform (com.jme3.shader.Uniform)5 Material (com.jme3.material.Material)4 Quaternion (com.jme3.math.Quaternion)4 Transform (com.jme3.math.Transform)4 Mesh (com.jme3.scene.Mesh)4 BlenderFileException (com.jme3.scene.plugins.blender.file.BlenderFileException)4