Package com.jme3.scene.plugins.blender.file

Examples of com.jme3.scene.plugins.blender.file.Structure


        app.start();
    }

    @Override
    public void simpleInitApp() {
        Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
      
        teapot.setLocalScale(2f);
        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat.setFloat("m_Shininess", 32f);
        mat.setBoolean("m_UseMaterialColors", true);

        mat.setColor("m_Ambient",  ColorRGBA.Black);
        mat.setColor("m_Diffuse",  ColorRGBA.Green);
        mat.setColor("m_Specular", ColorRGBA.Red);
       
        teapot.setMaterial(mat);
        rootNode.attachChild(teapot);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        lightMdl.getMesh().setStatic();
View Full Code Here


        try {
          // trows an Exception if lod is not supported
          modelGeom.setLodLevel(0);

          LodControl control = new LodControl();
          modelGeom.addControl(control);
        } catch (Exception e) {}
        assetLogger.modelFinished();
        camNode.detachAllChildren();
        camNode.attachChild(model);
View Full Code Here

        Map<String, Map<String, Ipo>> constraintsIpos = new HashMap<String, Map<String, Ipo>>();
        Pointer pActions = (Pointer) objectStructure.getFieldValue("action");
        if (pActions.isNotNull()) {
            List<Structure> actions = pActions.fetchData();
            for (Structure action : actions) {
                Structure chanbase = (Structure) action.getFieldValue("chanbase");
                List<Structure> actionChannels = chanbase.evaluateListBase();
                for (Structure actionChannel : actionChannels) {
                    Map<String, Ipo> ipos = new HashMap<String, Ipo>();
                    Structure constChannels = (Structure) actionChannel.getFieldValue("constraintChannels");
                    List<Structure> constraintChannels = constChannels.evaluateListBase();
                    for (Structure constraintChannel : constraintChannels) {
                        Pointer pIpo = (Pointer) constraintChannel.getFieldValue("ipo");
                        if (pIpo.isNotNull()) {
                            String constraintName = constraintChannel.getFieldValue("name").toString();
                            Ipo ipo = animationHelper.fromIpoStructure(pIpo.fetchData().get(0), blenderContext);
View Full Code Here

    public Constraint(Structure constraintStructure, Long ownerOMA, Ipo influenceIpo, BlenderContext blenderContext) throws BlenderFileException {
        this.blenderContext = blenderContext;
        name = constraintStructure.getFieldValue("name").toString();
        Pointer pData = (Pointer) constraintStructure.getFieldValue("data");
        if (pData.isNotNull()) {
            Structure data = pData.fetchData().get(0);
            constraintDefinition = ConstraintDefinitionFactory.createConstraintDefinition(data, ownerOMA, blenderContext);
            Pointer pTar = (Pointer) data.getFieldValue("tar");
            if (pTar != null && pTar.isNotNull()) {
                targetOMA = pTar.getOldMemoryAddress();
                targetSpace = Space.valueOf(((Number) constraintStructure.getFieldValue("tarspace")).byteValue());
                Object subtargetValue = data.getFieldValue("subtarget");
                if (subtargetValue != null) {// not all constraint data have the
                                             // subtarget field
                    subtargetName = subtargetValue.toString();
                }
            }
View Full Code Here

     * @throws BlenderFileException
     *             this exception is thrown when the blender file is somehow
     *             corrupted
     */
    public ArmatureModifier(Structure objectStructure, Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException {
        Structure meshStructure = ((Pointer) objectStructure.getFieldValue("data")).fetchData().get(0);
        if (this.validate(modifierStructure, blenderContext)) {
            Pointer pArmatureObject = (Pointer) modifierStructure.getFieldValue("object");
            if (pArmatureObject.isNotNull()) {
                armatureObject = pArmatureObject.fetchData().get(0);

                // load skeleton
                Structure armatureStructure = ((Pointer) armatureObject.getFieldValue("data")).fetchData().get(0);
                List<Structure> bonebase = ((Structure) armatureStructure.getFieldValue("bonebase")).evaluateListBase();
                List<Bone> bonesList = new ArrayList<Bone>();
                for (int i = 0; i < bonebase.size(); ++i) {
                    this.buildBones(armatureObject.getOldMemoryAddress(), bonebase.get(i), null, bonesList, objectStructure.getOldMemoryAddress(), blenderContext);
                }
                bonesList.add(0, new Bone(""));
View Full Code Here

     * @throws BlenderFileException
     *             this exception is thrown when the blend file structure is
     *             somehow invalid or corrupted
     */
    private VertexBuffer[] readVerticesWeightsData(Structure objectStructure, Structure meshStructure, Skeleton skeleton, int materialIndex, int[] bonesGroups, BlenderContext blenderContext) throws BlenderFileException {
        Structure defBase = (Structure) objectStructure.getFieldValue("defbase");
        Map<Integer, Integer> groupToBoneIndexMap = this.getGroupToBoneIndexMap(defBase, skeleton);

        MeshContext meshContext = blenderContext.getMeshContext(meshStructure.getOldMemoryAddress());

        return this.getBoneWeightAndIndexBuffer(meshStructure, meshContext.getVertexCount(materialIndex), bonesGroups, meshContext.getVertexReferenceMap(materialIndex), groupToBoneIndexMap);
View Full Code Here

                    break;
                case 2:// FITCURVE
                    Pointer pCurveOb = (Pointer) modifierStructure.getFieldValue("curve_ob");
                    float length = 0;
                    if (pCurveOb.isNotNull()) {
                        Structure curveStructure = pCurveOb.fetchData().get(0);
                        ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
                        Node curveObject = (Node) objectHelper.toObject(curveStructure, blenderContext);
                        Set<Number> referencesToCurveLengths = new HashSet<Number>(curveObject.getChildren().size());
                        for (Spatial spatial : curveObject.getChildren()) {
                            if (spatial instanceof Geometry) {
View Full Code Here

            Pointer pOffsetObject = (Pointer) modifierData.get("offsetob");
            if (pOffsetObject != null) {
                FileBlockHeader offsetObjectBlock = blenderContext.getFileBlock(pOffsetObject.getOldMemoryAddress());
                ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
                try {// we take the structure in case the object was not yet loaded
                    Structure offsetStructure = offsetObjectBlock.getStructure(blenderContext);
                    Vector3f translation = objectHelper.getTransformation(offsetStructure, blenderContext).getTranslation();
                    objectOffset[0] = translation.x;
                    objectOffset[1] = translation.y;
                    objectOffset[2] = translation.z;
                } catch (BlenderFileException e) {
                    LOGGER.log(Level.WARNING, "Problems in blender file structure! Object offset cannot be applied! The problem: {0}", e.getMessage());
                }
            }
   
            // getting start and end caps
            Node[] caps = new Node[] { null, null };
            Pointer[] pCaps = new Pointer[] { (Pointer) modifierData.get("startcap"), (Pointer) modifierData.get("endcap") };
            for (int i = 0; i < pCaps.length; ++i) {
                if (pCaps[i] != null) {
                    caps[i] = (Node) blenderContext.getLoadedFeature(pCaps[i].getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE);
                    if (caps[i] != null) {
                        caps[i] = (Node) caps[i].clone();
                    } else {
                        FileBlockHeader capBlock = blenderContext.getFileBlock(pOffsetObject.getOldMemoryAddress());
                        try {// we take the structure in case the object was not yet loaded
                            Structure capStructure = capBlock.getStructure(blenderContext);
                            ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
                            caps[i] = (Node) objectHelper.toObject(capStructure, blenderContext);
                            if (caps[i] == null) {
                                LOGGER.log(Level.WARNING, "Cap object ''{0}'' couldn''t be loaded!", capStructure.getName());
                            }
                        } catch (BlenderFileException e) {
                            LOGGER.log(Level.WARNING, "Problems in blender file structure! Cap object cannot be applied! The problem: {0}", e.getMessage());
                        }
                    }
View Full Code Here

    public static boolean canBeAppliedMultipleTimes(String modifierType) {
        return !(ARMATURE_MODIFIER_DATA.equals(modifierType) || OBJECT_ANIMATION_MODIFIER_DATA.equals(modifierType));
    }

    protected boolean validate(Structure modifierStructure, BlenderContext blenderContext) {
        Structure modifierData = (Structure) modifierStructure.getFieldValue("modifier");
        Pointer pError = (Pointer) modifierData.getFieldValue("error");
        invalid = pError.isNotNull();
        return !invalid;
    }
View Full Code Here

     *             corrupted
     */
    public Collection<Modifier> readModifiers(Structure objectStructure, BlenderContext blenderContext) throws BlenderFileException {
        Set<String> alreadyReadModifiers = new HashSet<String>();
        Collection<Modifier> result = new ArrayList<Modifier>();
        Structure modifiersListBase = (Structure) objectStructure.getFieldValue("modifiers");
        List<Structure> modifiers = modifiersListBase.evaluateListBase();
        for (Structure modifierStructure : modifiers) {
            String modifierType = modifierStructure.getType();
            if (!Modifier.canBeAppliedMultipleTimes(modifierType) && alreadyReadModifiers.contains(modifierType)) {
                LOGGER.log(Level.WARNING, "Modifier {0} can only be applied once to object: {1}", new Object[] { modifierType, objectStructure.getName() });
            } else {
View Full Code Here

TOP

Related Classes of com.jme3.scene.plugins.blender.file.Structure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.