Package com.ardor3d.scenegraph

Examples of com.ardor3d.scenegraph.Spatial


    }

    protected void clearOver() {
        _openButton.switchState(_openButton.getDefaultState());
        for (int i = _valuesMenu.getNumberOfChildren(); --i >= 0;) {
            final Spatial item = _valuesMenu.getChild(i);
            if (item instanceof UIButton) {
                final UIButton over = (UIButton) item;
                over.switchState(over.getDefaultState());
            }
        }
View Full Code Here


            for (final String key : data.keySet()) {
                final Object value = data.get(key);
                if (value instanceof JointData) { // ignore
                } else if (value instanceof TransformData) {
                    final TransformData transformData = (TransformData) value;
                    final Spatial applyTo = findChild(root, key);
                    if (applyTo != null) {
                        transformData.applyTo(applyTo);
                    }
                }
            }
View Full Code Here

        }
        if (key.equals(root.getName())) {
            _spatialCache.put(key, root);
            return root;
        } else if (root instanceof Node) {
            final Spatial spat = ((Node) root).getChild(key);
            if (spat != null) {
                _spatialCache.put(key, spat);
                return spat;
            }
        }
View Full Code Here

        return makeCopy(source, null, logic);
    }

    private static Spatial makeCopy(final Spatial source, final Spatial parent, final CopyLogic logic) {
        final AtomicBoolean recurse = new AtomicBoolean();
        final Spatial result = logic.copy(source, recurse);
        if (recurse.get() && source instanceof Node && result instanceof Node
                && ((Node) source).getNumberOfChildren() > 0) {
            for (final Spatial child : ((Node) source).getChildren()) {
                final Spatial copy = makeCopy(child, result, logic);
                if (copy != null) {
                    ((Node) result).attachChild(copy);
                }
            }
        }
View Full Code Here

     *            The Node that this tree should represent.
     * @param doSort
     *            true to sort primitives during creation, false otherwise
     */
    public void construct(final int childIndex, final int section, final Node parent, final boolean doSort) {
        final Spatial spat = parent.getChild(childIndex);
        if (spat instanceof Mesh) {
            _mesh = makeRef((Mesh) spat);
            _primitiveIndices = new int[((Mesh) spat).getMeshData().getPrimitiveCount(section)];
            for (int i = 0; i < _primitiveIndices.length; i++) {
                _primitiveIndices[i] = i;
View Full Code Here

        spat.onDraw(_parentRenderer);
    }

    protected void doDraw(final List<? extends Spatial> toDraw) {
        for (int x = 0, max = toDraw.size(); x < max; x++) {
            final Spatial spat = toDraw.get(x);
            doDraw(spat);
        }
    }
View Full Code Here

    public void render(final Renderer renderer) {
        // Grab our render context - used to enforce renderstates
        final RenderContext context = ContextManager.getCurrentContext();

        // go through our bucket contents
        Spatial spatial;
        for (int i = 0; i < _currentListSize; i++) {
            spatial = _currentList[i];

            // make sure we have a real spatial
            if (spatial == null) {
                continue;
            }

            // we only care about altering the Mesh... perhaps could be altered later to some interface shared by Mesh
            // and other leaf nodes.
            if (spatial instanceof Mesh) {

                // get our transparency rendering type.
                final TransparencyType renderType = spatial.getSceneHints().getTransparencyType();

                // check for one of the two pass types...
                if (renderType != TransparencyType.OnePass) {

                    // get handle to Mesh
                    final Mesh mesh = (Mesh) spatial;

                    // check if we have a Cull state set or enforced. If one is explicitly set and is not Face.None,
                    // we'll not do two-pass transparency.
                    RenderState setState = context.hasEnforcedStates() ? context.getEnforcedState(StateType.Cull)
                            : null;
                    if (setState == null) {
                        setState = mesh.getWorldRenderState(RenderState.StateType.Cull);
                    }

                    // Do the described check.
                    if (setState == null || ((CullState) setState).getCullFace() == Face.None) {

                        // pull any currently enforced cull or zstate. We'll put them back afterwards
                        final RenderState oldCullState = context.getEnforcedState(StateType.Cull);
                        final RenderState oldZState = context.getEnforcedState(StateType.ZBuffer);

                        // enforce our cull and zstate. The zstate is setup to respect depth, but not write to it.
                        context.enforceState(_tranparentCull);
                        context.enforceState(_transparentZBuff);

                        // first render back-facing tris only
                        _tranparentCull.setCullFace(CullState.Face.Front);
                        mesh.draw(renderer);

                        // revert z state
                        context.clearEnforcedState(StateType.ZBuffer);
                        if (oldZState != null) {
                            context.enforceState(oldZState);
                        }

                        // render front-facing tris
                        _tranparentCull.setCullFace(CullState.Face.Back);
                        mesh.draw(renderer);

                        // revert cull state
                        if (oldCullState != null) {
                            context.enforceState(oldCullState);
                        } else {
                            context.clearEnforcedState(StateType.Cull);
                        }
                        continue;
                    }
                }
            }

            // go ahead and draw as usual
            spatial.draw(renderer);
        }
    }
View Full Code Here

    private static final long serialVersionUID = 1L;

    @Override
    public void doRender(final Renderer r) {
        for (int i = 0, sSize = _spatials.size(); i < sSize; i++) {
            final Spatial s = _spatials.get(i);
            r.draw(s);
        }
        r.renderBuckets();
    }
View Full Code Here

        spat.onDraw(_parentRenderer);
    }

    protected void doDraw(final List<? extends Spatial> toDraw) {
        for (int x = 0, max = toDraw.size(); x < max; x++) {
            final Spatial spat = toDraw.get(x);
            doDraw(spat);
        }
    }
View Full Code Here

            return;
        }

        propagateDirtyDown(ON_DIRTY_TRANSFORM);
        for (int i = 0, cSize = getNumberOfChildren(); i < cSize; i++) {
            final Spatial child = getChild(i);
            if (child != null) {
                child.updateGeometricState(_lastTime, false);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.ardor3d.scenegraph.Spatial

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.