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

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


        if (invalid) {
            LOGGER.log(Level.WARNING, "Mirror modifier is invalid! Cannot be applied to: {0}", node.getName());
        } else {
            Vector3f mirrorPlaneCenter = new Vector3f();
            if (pMirrorObject.isNotNull()) {
                Structure objectStructure;
                try {
                    objectStructure = pMirrorObject.fetchData().get(0);
                    ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
                    Node object = (Node) objectHelper.toObject(objectStructure, blenderContext);
                    if (object != null) {
View Full Code Here


    public ParticlesModifier(Structure modifierStructure, BlenderContext blenderContext) throws BlenderFileException {
        if (this.validate(modifierStructure, blenderContext)) {
            Pointer pParticleSystem = (Pointer) modifierStructure.getFieldValue("psys");
            if (pParticleSystem.isNotNull()) {
                ParticlesHelper particlesHelper = blenderContext.getHelper(ParticlesHelper.class);
                Structure particleSystem = pParticleSystem.fetchData().get(0);
                particleEmitter = particlesHelper.toParticleEmitter(particleSystem);
            }
        }
    }
View Full Code Here

        // getting or creating bevel object
        List<Geometry> bevelObject = null;
        Pointer pBevelObject = (Pointer) curveStructure.getFieldValue("bevobj");
        if (pBevelObject.isNotNull()) {
            Pointer pBevelStructure = (Pointer) pBevelObject.fetchData().get(0).getFieldValue("data");
            Structure bevelStructure = pBevelStructure.fetchData().get(0);
            bevelObject = this.toCurve(bevelStructure, blenderContext);
        } else {
            int bevResol = ((Number) curveStructure.getFieldValue("bevresol")).intValue();
            float extrude = ((Number) curveStructure.getFieldValue("ext1")).floatValue();
            float bevelDepth = ((Number) curveStructure.getFieldValue("ext2")).floatValue();
            if (bevelDepth > 0.0f) {
                float handlerLength = bevelDepth / 2.0f;

                List<Vector3f> conrtolPoints = new ArrayList<Vector3f>(extrude > 0.0f ? 19 : 13);
                if (extrude > 0.0f) {
                    conrtolPoints.add(new Vector3f(-bevelDepth, 0, extrude));
                    conrtolPoints.add(new Vector3f(-bevelDepth, 0, -handlerLength + extrude));
                    conrtolPoints.add(new Vector3f(-bevelDepth, 0, handlerLength - extrude));
                }

                conrtolPoints.add(new Vector3f(-bevelDepth, 0, -extrude));
                conrtolPoints.add(new Vector3f(-bevelDepth, 0, -handlerLength - extrude));

                conrtolPoints.add(new Vector3f(-handlerLength, 0, -bevelDepth - extrude));
                conrtolPoints.add(new Vector3f(0, 0, -bevelDepth - extrude));
                conrtolPoints.add(new Vector3f(handlerLength, 0, -bevelDepth - extrude));

                if (extrude > 0.0f) {
                    conrtolPoints.add(new Vector3f(bevelDepth, 0, -extrude - handlerLength));
                    conrtolPoints.add(new Vector3f(bevelDepth, 0, -extrude));
                    conrtolPoints.add(new Vector3f(bevelDepth, 0, -extrude + handlerLength));
                }

                conrtolPoints.add(new Vector3f(bevelDepth, 0, extrude - handlerLength));
                conrtolPoints.add(new Vector3f(bevelDepth, 0, extrude));
                conrtolPoints.add(new Vector3f(bevelDepth, 0, extrude + handlerLength));

                conrtolPoints.add(new Vector3f(handlerLength, 0, bevelDepth + extrude));
                conrtolPoints.add(new Vector3f(0, 0, bevelDepth + extrude));
                conrtolPoints.add(new Vector3f(-handlerLength, 0, bevelDepth + extrude));

                conrtolPoints.add(new Vector3f(-bevelDepth, 0, handlerLength + extrude));
                conrtolPoints.add(new Vector3f(-bevelDepth, 0, extrude));

                Spline bevelSpline = new Spline(SplineType.Bezier, conrtolPoints, 0, false);
                Curve bevelCurve = new Curve(bevelSpline, bevResol);
                bevelObject = new ArrayList<Geometry>(1);
                bevelObject.add(new Geometry("", bevelCurve));
            } else if (extrude > 0.0f) {
                Spline bevelSpline = new Spline(SplineType.Linear, new Vector3f[] { new Vector3f(0, 0, -extrude), new Vector3f(0, 0, extrude) }, 1, false);
                Curve bevelCurve = new Curve(bevelSpline, bevResol);
                bevelObject = new ArrayList<Geometry>(1);
                bevelObject.add(new Geometry("", bevelCurve));
            }
        }

        // getting taper object
        Spline taperObject = null;
        Pointer pTaperObject = (Pointer) curveStructure.getFieldValue("taperobj");
        if (bevelObject != null && pTaperObject.isNotNull()) {
            Pointer pTaperStructure = (Pointer) pTaperObject.fetchData().get(0).getFieldValue("data");
            Structure taperStructure = pTaperStructure.fetchData().get(0);
            taperObject = this.loadTaperObject(taperStructure);
        }

        Vector3f loc = this.getLoc(curveStructure);
        // creating the result curves
View Full Code Here

    public void loadAnimations() throws BlenderFileException {
        LOGGER.info("Loading animations that will be later applied to scene features.");
        List<FileBlockHeader> actionHeaders = blenderContext.getFileBlocks(Integer.valueOf(FileBlockHeader.BLOCK_AC00));
        if (actionHeaders != null) {
            for (FileBlockHeader header : actionHeaders) {
                Structure actionStructure = header.getStructure(blenderContext);
                LOGGER.log(Level.INFO, "Found animation: {0}.", actionStructure.getName());
                actions.put(actionStructure.getName(), this.getTracks(actionStructure, blenderContext));
            }
        }
    }
View Full Code Here

     * @throws BlenderFileException
     *             this exception is thrown when the blender file is somehow
     *             corrupted
     */
    public Ipo fromIpoStructure(Structure ipoStructure, BlenderContext blenderContext) throws BlenderFileException {
        Structure curvebase = (Structure) ipoStructure.getFieldValue("curve");

        // preparing bezier curves
        Ipo result = null;
        List<Structure> curves = curvebase.evaluateListBase();// IpoCurve
        if (curves.size() > 0) {
            BezierCurve[] bezierCurves = new BezierCurve[curves.size()];
            int frame = 0;
            for (Structure curve : curves) {
                Pointer pBezTriple = (Pointer) curve.getFieldValue("bezt");
View Full Code Here

     *             an exception is thrown when there are problems with the blend
     *             file
     */
    private BlenderAction getTracks250(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException {
        LOGGER.log(Level.FINE, "Getting tracks!");
        Structure groups = (Structure) actionStructure.getFieldValue("groups");
        List<Structure> actionGroups = groups.evaluateListBase();// bActionGroup
        BlenderAction blenderAction = new BlenderAction(blenderContext.getBlenderKey().getFps());
        int lastFrame = 1;
        for (Structure actionGroup : actionGroups) {
            String name = actionGroup.getFieldValue("name").toString();
            List<Structure> channels = ((Structure) actionGroup.getFieldValue("channels")).evaluateListBase();
View Full Code Here

     *             an exception is thrown when there are problems with the blend
     *             file
     */
    private BlenderAction getTracks249(Structure actionStructure, BlenderContext blenderContext) throws BlenderFileException {
        LOGGER.log(Level.FINE, "Getting tracks!");
        Structure chanbase = (Structure) actionStructure.getFieldValue("chanbase");
        List<Structure> actionChannels = chanbase.evaluateListBase();// bActionChannel
        BlenderAction blenderAction = new BlenderAction(blenderContext.getBlenderKey().getFps());
        int lastFrame = 1;
        for (Structure bActionChannel : actionChannels) {
            String animatedFeatureName = bActionChannel.getFieldValue("name").toString();
            Pointer p = (Pointer) bActionChannel.getFieldValue("ipo");
            if (!p.isNull()) {
                Structure ipoStructure = p.fetchData().get(0);
                Ipo ipo = this.fromIpoStructure(ipoStructure, blenderContext);
                if(ipo != null) {//this can happen when ipo with no curves appear in blender file
                    lastFrame = Math.max(lastFrame, ipo.getLastFrame());
                    blenderAction.featuresTracks.put(animatedFeatureName, ipo);
                }
View Full Code Here

     */
    private CameraNode toCamera250(Structure structure, Structure sceneStructure) throws BlenderFileException {
        int width = DEFAULT_CAM_WIDTH;
        int height = DEFAULT_CAM_HEIGHT;
        if (sceneStructure != null) {
            Structure renderData = (Structure) sceneStructure.getFieldValue("r");
            width = ((Number) renderData.getFieldValue("xsch")).shortValue();
            height = ((Number) renderData.getFieldValue("ysch")).shortValue();
        }
        Camera camera = new Camera(width, height);
        int type = ((Number) structure.getFieldValue("type")).intValue();
        if (type != 0 && type != 1) {
            LOGGER.log(Level.WARNING, "Unknown camera type: {0}. Perspective camera is being used!", type);
View Full Code Here

        switch (type) {
            case TEX_IMAGE:// (it is first because probably this will be most commonly used)
                Pointer pImage = (Pointer) tex.getFieldValue("ima");
                if (pImage.isNotNull()) {
                    Structure image = pImage.fetchData().get(0);
                    Texture loadedTexture = this.loadTexture(image, imaflag, blenderContext);
                    if (loadedTexture != null) {
                        result = loadedTexture;
                        this.applyColorbandAndColorFactors(tex, result.getImage(), blenderContext);
                    }
View Full Code Here

            if (pPackedFile.isNull()) {
                LOGGER.log(Level.FINE, "Reading texture from file: {0}", texturePath);
                result = this.loadImageFromFile(texturePath, imaflag, blenderContext);
            } else {
                LOGGER.fine("Packed texture. Reading directly from the blend file!");
                Structure packedFile = pPackedFile.fetchData().get(0);
                Pointer pData = (Pointer) packedFile.getFieldValue("data");
                FileBlockHeader dataFileBlock = blenderContext.getFileBlock(pData.getOldMemoryAddress());
                blenderContext.getInputStream().setPosition(dataFileBlock.getBlockPosition());
                ImageLoader imageLoader = new ImageLoader();

                // Should the texture be flipped? It works for sinbad ..
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.