java类com.badlogic.gdx.graphics.g3d.model.Node的实例源码

Word.java 文件源码 项目:ZombieInvadersVR 阅读 22 收藏 0 点赞 0 评论 0
private void init() {
    float centerX = 0f;
    float centerY = ((((float) words.length) * FONT_HEIGHT) - FONT_HEIGHT) / 2f;

    nodes.clear();
    nodesPosition = new Array<Vector3>();
    if(words != null && words.length > 0){
        for(int y = 0; y < words.length; y++){
            String[] word = translateSpecialCharacters(words[y]);
            centerX = (((float) word.length) * FONT_WIDTH) / 2f;
            for(int x = 0; x < word.length; x++){
                String letter = String.valueOf(word[x]);

                Node node = model.getNode(letter);
                if(node != null){
                    Vector3 position = new Vector3((FONT_WIDTH*x) - centerX,(-FONT_HEIGHT*y) + centerY,0);
                    node = node.copy();
                    node.globalTransform.setTranslation(position);
                    nodes.add(node);
                    nodesPosition.add(position.cpy());
                }
            }
        }
    }
}
NodeComponent.java 文件源码 项目:nhglib 阅读 46 收藏 0 点赞 0 评论 0
public NodeComponent() {
    node = new Node();

    tempVec = new Vector3();
    tempVec2 = new Vector3();
    tempQuat = new Quaternion();

    translation = new Vector3();
    rotation = new Vector3();
    scale = new Vector3(1, 1, 1);

    localTranslation = new Vector3();
    localRotation = new Vector3();
    localScale = new Vector3(1, 1, 1);

    translationDelta = new Vector3();
    rotationDelta = new Vector3();
    scaleDelta = new Vector3();

    localRotationQuaternion = new Quaternion();
    rotationQuaternion = new Quaternion();
}
Ragdoll.java 文件源码 项目:GdxDemo3D 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Updates the rigid body parts to follow nodes of the model instance
 */
private void updateBodiesToArmature() {
    // Ragdoll parts should follow the model animation.
    // Loop over each part and set it to the global transform of the armature node it should follow.
    capsuleTransform.set(modelTransform);
    for (Iterator<ObjectMap.Entry<btRigidBody, RigidBodyNodeConnection>> iterator
         = bodyPartMap.iterator(); iterator.hasNext(); ) {
        ObjectMap.Entry<btRigidBody, RigidBodyNodeConnection> entry = iterator.next();
        RigidBodyNodeConnection data = entry.value;
        btRigidBody body = entry.key;
        Node followNode = data.followNode;
        Vector3 offset = data.bodyNodeOffsets.get(followNode);

        body.proceedToTransform(tmpMatrix.set(capsuleTransform)
                .mul(followNode.globalTransform).translate(offset));
    }
}
Ragdoll.java 文件源码 项目:GdxDemo3D 阅读 20 收藏 0 点赞 0 评论 0
/**
 * @param bodyPart The rigid body which is to be synchronized with a node
 * @param node     The node which is to be synchronized with a body
 */
private void addPart(btRigidBody bodyPart, Node node) {
    if (!bodyPartMap.containsKey(bodyPart)) {
        bodyPartMap.put(bodyPart, new RigidBodyNodeConnection());
    }
    RigidBodyNodeConnection conn = bodyPartMap.get(bodyPart);
    conn.followNode = node;
    // Set the follow offset to the middle of the armature bone
    Vector3 offsetTranslation = new Vector3();
    node.getChild(0).localTransform.getTranslation(offsetTranslation).scl(0.5f);
    conn.bodyNodeOffsets.put(node, offsetTranslation);

    if (!ragdollMappedNodes.contains(node, true)) {
        ragdollMappedNodes.add(node);
    }
}
GameScene.java 文件源码 项目:GdxDemo3D 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Creates and adds the navmesh to this scene.
 */
private void setNavmesh(GameObjectBlueprint bp) {
    // We need to set the node transforms before calculating the navmesh shape
    GameModel gameModel = new GameModel(bp.model, bp.name, bp.position, bp.rotation, bp.scale);

    Array<NodePart> nodes = gameModel.modelInstance.model.getNode("navmesh").parts;
    // Sort the model meshParts array according to material name
    nodes.sort(new NavMeshNodeSorter());

    // The model transform must be applied to the meshparts for shape generation to work correctly.
    gameModel.modelInstance.calculateTransforms();
    Matrix4 transform = new Matrix4();
    for (Node node : gameModel.modelInstance.nodes) {
        transform.set(node.globalTransform).inv();
        for (NodePart nodePart : node.parts) {
            nodePart.meshPart.mesh.transform(transform);
        }
    }
    navMesh = new NavMesh(gameModel.modelInstance.model);
    btCollisionShape shape = navMesh.getShape();

    navmeshBody = new InvisibleBody("navmesh",
            shape, 0, gameModel.modelInstance.transform, GameEngine.NAVMESH_FLAG, GameEngine.NAVMESH_FLAG, false, false);
    worldBounds.set(gameModel.boundingBox);
    gameModel.dispose();
}
ArmatureDebugDrawer.java 文件源码 项目:GdxDemo3D 阅读 35 收藏 0 点赞 0 评论 0
private void drawArmatureNodes(Node currentNode, Vector3 modelPos,
                               Quaternion modelRot,
                               Vector3 parentNodePos, Vector3 currentNodePos) {
    currentNode.globalTransform.getTranslation(currentNodePos);
    modelRot.transform(currentNodePos);
    currentNodePos.add(modelPos);
    drawVertex(currentNodePos, 0.02f, Color.GREEN);
    shapeRenderer.setColor(Color.YELLOW);
    if (currentNode.hasParent()) {
        shapeRenderer.line(parentNodePos, currentNodePos);
    }
    if (currentNode.hasChildren()) {
        float x = currentNodePos.x;
        float y = currentNodePos.y;
        float z = currentNodePos.z;
        for (Node child : currentNode.getChildren()) {
            drawArmatureNodes(child, modelPos, modelRot, currentNodePos, parentNodePos);
            currentNodePos.set(x, y, z);
        }
    }
}
ModelBuilder.java 文件源码 项目:libgdxcn 阅读 37 收藏 0 点赞 0 评论 0
@Deprecated
public static Model createFromMesh (final Mesh mesh, int indexOffset, int vertexCount, int primitiveType,
    final Material material) {
    Model result = new Model();
    MeshPart meshPart = new MeshPart();
    meshPart.id = "part1";
    meshPart.indexOffset = indexOffset;
    meshPart.numVertices = vertexCount;
    meshPart.primitiveType = primitiveType;
    meshPart.mesh = mesh;

    NodePart partMaterial = new NodePart();
    partMaterial.material = material;
    partMaterial.meshPart = meshPart;
    Node node = new Node();
    node.id = "node1";
    node.parts.add(partMaterial);

    result.meshes.add(mesh);
    result.materials.add(material);
    result.nodes.add(node);
    result.meshParts.add(meshPart);
    result.manageDisposable(mesh);
    return result;
}
ModelBuilder.java 文件源码 项目:libgdxcn 阅读 23 收藏 0 点赞 0 评论 0
/** Convenience method to create a model with three orthonormal vectors shapes. The resources the Material might contain are not
 * managed, use {@link Model#manageDisposable(Disposable)} to add those to the model.
 * @param axisLength Length of each axis.
 * @param capLength is the height of the cap in percentage, must be in (0,1)
 * @param stemThickness is the percentage of stem diameter compared to cap diameter, must be in (0,1]
 * @param divisions the amount of vertices used to generate the cap and stem ellipsoidal bases */
public Model createXYZCoordinates (float axisLength, float capLength, float stemThickness, int divisions, int primitiveType,
    Material material, long attributes) {
    begin();
    MeshPartBuilder partBuilder;
    Node node = node();

    partBuilder = part("xyz", primitiveType, attributes, material);
    partBuilder.setColor(Color.RED);
    partBuilder.arrow(0, 0, 0, axisLength, 0, 0, capLength, stemThickness, divisions);
    partBuilder.setColor(Color.GREEN);
    partBuilder.arrow(0, 0, 0, 0, axisLength, 0, capLength, stemThickness, divisions);
    partBuilder.setColor(Color.BLUE);
    partBuilder.arrow(0, 0, 0, 0, 0, axisLength, capLength, stemThickness, divisions);

    return end();
}
Model.java 文件源码 项目:libgdxcn 阅读 33 收藏 0 点赞 0 评论 0
private void loadAnimations (Iterable<ModelAnimation> modelAnimations) {
    for (final ModelAnimation anim : modelAnimations) {
        Animation animation = new Animation();
        animation.id = anim.id;
        for (ModelNodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.nodeId);
            if (node == null) continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (ModelNodeKeyframe kf : nanim.keyframes) {
                if (kf.keytime > animation.duration) animation.duration = kf.keytime;
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation == null ? node.rotation : kf.rotation);
                keyframe.scale.set(kf.scale == null ? node.scale : kf.scale);
                keyframe.translation.set(kf.translation == null ? node.translation : kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0) animations.add(animation);
    }
}
ModelInstance.java 文件源码 项目:libgdxcn 阅读 35 收藏 0 点赞 0 评论 0
/** @param model The source {@link Model}
 * @param transform The {@link Matrix4} instance for this ModelInstance to reference or null to create a new matrix.
 * @param nodeId The ID of the {@link Node} within the {@link Model} for the instance to contain
 * @param recursive True to recursively search the Model's node tree, false to only search for a root node
 * @param parentTransform True to apply the parent's node transform to the instance (only applicable if recursive is true).
 * @param mergeTransform True to apply the source node transform to the instance transform, resetting the node transform. */
public ModelInstance (final Model model, final Matrix4 transform, final String nodeId, boolean recursive,
    boolean parentTransform, boolean mergeTransform, boolean shareKeyframes) {
    this.model = model;
    this.transform = transform == null ? new Matrix4() : transform;
    nodePartBones.clear();
    Node copy, node = model.getNode(nodeId, recursive);
    this.nodes.add(copy = copyNode(node));
    if (mergeTransform) {
        this.transform.mul(parentTransform ? node.globalTransform : node.localTransform);
        copy.translation.set(0, 0, 0);
        copy.rotation.idt();
        copy.scale.set(1, 1, 1);
    } else if (parentTransform && copy.hasParent()) this.transform.mul(node.getParent().globalTransform);
    setBones();
    copyAnimations(model.animations, shareKeyframes);
    calculateTransforms();
}
ModelInstance.java 文件源码 项目:libgdxcn 阅读 27 收藏 0 点赞 0 评论 0
private Node copyNode (Node node) {
    Node copy = new Node();
    copy.id = node.id;
    copy.inheritTransform = node.inheritTransform;
    copy.translation.set(node.translation);
    copy.rotation.set(node.rotation);
    copy.scale.set(node.scale);
    copy.localTransform.set(node.localTransform);
    copy.globalTransform.set(node.globalTransform);
    for (NodePart nodePart : node.parts) {
        copy.parts.add(copyNodePart(nodePart));
    }
    for (Node child : node.getChildren()) {
        copy.addChild(copyNode(child));
    }
    return copy;
}
ModelBuilder2.java 文件源码 项目:gaiasky 阅读 24 收藏 0 点赞 0 评论 0
@Deprecated
public static Model createFromMesh(final Mesh mesh, int indexOffset, int vertexCount, int primitiveType, final Material material) {
    Model result = new Model();
    MeshPart meshPart = new MeshPart();
    meshPart.id = "part1";
    meshPart.offset = indexOffset;
    meshPart.size = vertexCount;
    meshPart.primitiveType = primitiveType;
    meshPart.mesh = mesh;

    NodePart partMaterial = new NodePart();
    partMaterial.material = material;
    partMaterial.meshPart = meshPart;
    Node node = new Node();
    node.id = "node1";
    node.parts.add(partMaterial);

    result.meshes.add(mesh);
    result.materials.add(material);
    result.nodes.add(node);
    result.meshParts.add(meshPart);
    result.manageDisposable(mesh);
    return result;
}
ModelManager.java 文件源码 项目:gdx-proto 阅读 33 收藏 0 点赞 0 评论 0
/** players are represented by cubes, with another cube marking the direction it is facing */
public void createPlayerModel() {
    ModelBuilder mb = new ModelBuilder();
    ModelBuilder mb2 = new ModelBuilder();
    long attr = Usage.Position | Usage.Normal;
    float r = 0.5f;
    float g = 1f;
    float b = 0.75f;
    Material material = new Material(ColorAttribute.createDiffuse(new Color(r, g, b, 1f)));
    Material faceMaterial = new Material(ColorAttribute.createDiffuse(Color.BLUE));
    float w = 1f;
    float d = w;
    float h = 2f;
    mb.begin();
    //playerModel = mb.createBox(w, h, d, material, attr);
    Node node = mb.node("box", mb2.createBox(w, h, d, material, attr));
    // the face is just a box to show which direction the player is facing
    Node faceNode = mb.node("face", mb2.createBox(w/2, h/2, d/2, faceMaterial, attr));
    faceNode.translation.set(0f, 0f, d/2);
    playerModel = mb.end();
}
LevelBuilder.java 文件源码 项目:gdx-proto 阅读 21 收藏 0 点赞 0 评论 0
/** client builds statics, probably based on info from server */
public static void buildStatics(LevelStatic[] statics) {
    if (staticGeometry == null) {
        staticGeometry = new Array<>();
    }
    Log.debug("client building statics received from server: " + statics.length);
    ModelBuilder mb = new ModelBuilder();
    mb.begin();
    for (LevelStatic stat : statics) {
        Model model = Assets.manager.get(stat.modelName, Model.class);
        setupStaticModel(model.meshParts, stat.mtx, true);
        Node node = mb.node("piece", model);
        stat.mtx.getTranslation(tmp);
        node.translation.set(tmp);
        node.rotation.set(stat.mtx.getRotation(q));
    }
    Model finalModel = mb.end();
    ModelInstance instance = new ModelInstance(finalModel);
    staticGeometry.add(instance);
}
HeadlessModel.java 文件源码 项目:gdx-proto 阅读 35 收藏 0 点赞 0 评论 0
private void loadAnimations (Iterable<ModelAnimation> modelAnimations) {
    for (final ModelAnimation anim : modelAnimations) {
        Animation animation = new Animation();
        animation.id = anim.id;
        for (ModelNodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.nodeId);
            if (node == null) continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (ModelNodeKeyframe kf : nanim.keyframes) {
                if (kf.keytime > animation.duration) animation.duration = kf.keytime;
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation == null ? node.rotation : kf.rotation);
                keyframe.scale.set(kf.scale == null ? node.scale : kf.scale);
                keyframe.translation.set(kf.translation == null ? node.translation : kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0) animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0) animations.add(animation);
    }
}
SharedModel.java 文件源码 项目:vtm 阅读 83 收藏 0 点赞 0 评论 0
/** @param model The source {@link Model}
 * @param transform The {@link Matrix4} instance for this ModelInstance to reference or null to create a new matrix. 
 * @param nodeId The ID of the {@link Node} within the {@link Model} for the instance to contain
 * @param recursive True to recursively search the Model's node tree, false to only search for a root node
 * @param parentTransform True to apply the parent's node transform to the instance (only applicable if recursive is true).
 * @param mergeTransform True to apply the source node transform to the instance transform, resetting the node transform. */
public SharedModel(final Model model, final Matrix4 transform, final String nodeId, boolean recursive, boolean parentTransform, boolean mergeTransform) {
    this.model = model;
    this.transform = transform == null ? new Matrix4() : transform; 
    nodePartBones.clear();
    Node copy, node = model.getNode(nodeId, recursive);
    this.nodes.add(copy = copyNode(null, node));
    if (mergeTransform) {
        this.transform.mul(parentTransform ? node.globalTransform : node.localTransform);
        copy.translation.set(0,0,0);
        copy.rotation.idt();
        copy.scale.set(1,1,1);
    } else if (parentTransform && copy.parent != null)
        this.transform.mul(node.parent.globalTransform);
    setBones();
    copyAnimations(model.animations);
    calculateTransforms();
}
SharedModel.java 文件源码 项目:vtm 阅读 33 收藏 0 点赞 0 评论 0
private Node copyNode(Node parent, Node node) {
    Node copy = new Node();
    copy.id = node.id;
    //copy.boneId = node.boneId;
    copy.parent = parent;
    copy.translation.set(node.translation);
    copy.rotation.set(node.rotation);
    copy.scale.set(node.scale);
    copy.localTransform.set(node.localTransform);
    copy.globalTransform.set(node.globalTransform);
    for(NodePart nodePart: node.parts) {
        copy.parts.add(copyNodePart(nodePart));
    }
    for(Node child: node.children) {
        copy.children.add(copyNode(copy, child));
    }
    return copy;
}
SharedModel.java 文件源码 项目:vtm 阅读 48 收藏 0 点赞 0 评论 0
private void copyAnimations (final Iterable<Animation> source) {
    for (final Animation anim : source) {
        Animation animation = new Animation();
        animation.id = anim.id;
        animation.duration = anim.duration;
        for (final NodeAnimation nanim : anim.nodeAnimations) {
            final Node node = getNode(nanim.node.id);
            if (node == null)
                continue;
            NodeAnimation nodeAnim = new NodeAnimation();
            nodeAnim.node = node;
            for (final NodeKeyframe kf : nanim.keyframes) {
                NodeKeyframe keyframe = new NodeKeyframe();
                keyframe.keytime = kf.keytime;
                keyframe.rotation.set(kf.rotation);
                keyframe.scale.set(kf.scale);
                keyframe.translation.set(kf.translation);
                nodeAnim.keyframes.add(keyframe);
            }
            if (nodeAnim.keyframes.size > 0)
                animation.nodeAnimations.add(nodeAnim);
        }
        if (animation.nodeAnimations.size > 0)
            animations.add(animation);
    }
}
GdxModelLayer.java 文件源码 项目:vtm 阅读 33 收藏 0 点赞 0 评论 0
private void doneLoading() {
    Model model = assets.get("data/g3d/test.g3db", Model.class);
    for (int i = 0; i < model.nodes.size; i++) {
        Node node = model.nodes.get(i);
        log.debug("loader node " + node.id);

        if (node.id.equals("test_root")) {
            node = node.getChild("Building", false, false);
            log.debug("loader node " + node.id);

            node.rotation.setFromAxis(1, 0, 0, 90);
            mModel = model;

            break;
        }

        //}
    }

    loading = false;
}
BaseModelTileMesh.java 文件源码 项目:gdx-tilemap3d 阅读 30 收藏 0 点赞 0 评论 0
protected void collectModelNodeVertexPositions(Node node, Array<Vector3> destVertices, Vector3 scaleFactor, Vector3 positionOffset) {
    final Matrix4 transform = node.globalTransform;

    for (int i = 0; i < node.parts.size; ++i) {
        NodePart nodePart = node.parts.get(i);
        MeshPart meshPart = nodePart.meshPart;
        ShortBuffer indices = meshPart.mesh.getIndicesBuffer();
        FloatBuffer vertices = meshPart.mesh.getVerticesBuffer();
        final int strideInFloats = meshPart.mesh.getVertexSize() / (Float.SIZE / 8);

        for (int j = 0; j < meshPart.numVertices; ++j) {
            int index = indices.get(meshPart.indexOffset + j);
            int offset = index * strideInFloats;

            tmpPosition.set(vertices.get(offset), vertices.get(offset + 1), vertices.get(offset + 2))
                       .add(positionOffset)
                       .scl(scaleFactor)
                       .mul(transform);
            destVertices.add(new Vector3(tmpPosition));
        }
    }

    for (int i = 0; i < node.children.size; ++i)
        collectModelNodeVertexPositions(node.children.get(i), destVertices, scaleFactor, positionOffset);
}
Gun.java 文件源码 项目:Tower-Defense-Galaxy 阅读 25 收藏 0 点赞 0 评论 0
public Gun(Matrix4 transform, int hp, int health, int range, float cooldown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, String attack, EntityTemplate<Bullet> projectile, Vector3 attackOffset, Map<String, Sound> sounds) {
    super(transform, hp, health, range, cooldown, types, effects, instance, shape, world, entities, attack, projectile, attackOffset, sounds);
    nodes = new HashMap<String, Node>();
    /*for(Node node: instance.model.nodes) {
        System.out.println(node.id);
        if (node.id.startsWith("Leg")) {
            legs.add(node);
        }
    }*/
    //legs.get(0).rotation.setEulerAngles(100, 0, 0);

    for(Node node: instance.getNode("Gun_root").getChildren())
        nodes.put(node.id, node);
}
Bullet.java 文件源码 项目:gdx-bullet-gwt 阅读 22 收藏 0 点赞 0 评论 0
public static btCollisionShape obtainStaticNodeShape (final Node node, final boolean applyTransform) {
    getShapeParts(node, applyTransform, shapePartArray, 0, shapePartPool);
    btCollisionShape result = obtainStaticShape(shapePartArray);
    shapePartPool.freeAll(shapePartArray);
    shapePartArray.clear();
    return result;
}
Bullet.java 文件源码 项目:gdx-bullet-gwt 阅读 24 收藏 0 点赞 0 评论 0
public static btCollisionShape obtainStaticNodeShape (final Array<Node> nodes) {
    getShapeParts(nodes, shapePartArray, 0, shapePartPool);
    btCollisionShape result = obtainStaticShape(shapePartArray);
    shapePartPool.freeAll(shapePartArray);
    shapePartArray.clear();
    return result;
}
MaterialPanel.java 文件源码 项目:Argent 阅读 22 收藏 0 点赞 0 评论 0
private NodePart getPart(int index) {
    ModelInstance inst = gameWorld.renderer().getRenderable(selected());
    int i = 0;
    for (Node node : inst.nodes) {
        for (NodePart part : node.parts) {
            if(i == index) return part;
            i++;
        }
    }
    return null;
}
Hydrogen.java 文件源码 项目:Chemtris 阅读 19 收藏 0 点赞 0 评论 0
public Hydrogen(int ve, boolean[][][] mtx, PerspectiveCamera cam) {
    super(ve, mtx, cam);

    //begin building the model
    hydrogen_builder.begin();

    //first node
    Node electron_1 = hydrogen_builder.node();
    electron_1.id = Hydrogen.VE_1;

    //make the cube
    hydrogen_builder.part(Hydrogen.VE_1, GL20.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal,
            new Material(ColorAttribute.createDiffuse(new Color(195f/255f,207f/255f,255f/255f,1f))))
            .box(1f, 1f, 1f);

    //end the model
    Model hModel = hydrogen_builder.end();

    atom = new ModelInstance(hModel,2,10,2);
    shadow = new ModelInstance(hModel,2,10,2);
    frame = new ModelInstance(hModel,2,10,2);
    frame.transform.scl(.01f);

    for(int i = 0; i < shadow.materials.size; ++i){
        shadow.materials.get(i).set(ColorAttribute.createDiffuse(105/255f,105/255f,105/255f,1f));
        frame.materials.get(i).set(ColorAttribute.createDiffuse(Color.WHITE));
    }
}
Builder.java 文件源码 项目:Skyland 阅读 39 收藏 0 点赞 0 评论 0
private static void buildCave(Matrix4 transform) {
    Model caveModel = Assets.get(CURR_MODEL, Model.class);
    if (WORLD.getConstructor("cave") == null) {
        for (Node n : caveModel.nodes) n.scale.set(.6f, .6f, .6f);
        btCollisionShape collisionShape = Bullet.obtainStaticNodeShape(caveModel.nodes);
        collisionShape.setLocalScaling(new Vector3(.6f, .6f, .6f));
        WORLD.addConstructor("cave", new BulletConstructor(caveModel, 0, collisionShape));
    }
    BulletEntity cave = WORLD.add("cave", transform);
    cave.body.setCollisionFlags(cave.body.getCollisionFlags()
            | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
    cave.body.setActivationState(Collision.DISABLE_DEACTIVATION);
    cave.body.userData = new BulletUserData("cave", cave);
}
Bullet.java 文件源码 项目:gdx-bullet-gwt 阅读 26 收藏 0 点赞 0 评论 0
public static btCollisionShape obtainStaticNodeShape (final Node node, final boolean applyTransform) {
    getShapeParts(node, applyTransform, shapePartArray, 0, shapePartPool);
    btCollisionShape result = obtainStaticShape(shapePartArray);
    shapePartPool.freeAll(shapePartArray);
    shapePartArray.clear();
    return result;
}
Bullet.java 文件源码 项目:gdx-bullet-gwt 阅读 44 收藏 0 点赞 0 评论 0
public static btCollisionShape obtainStaticNodeShape (final Array<Node> nodes) {
    getShapeParts(nodes, shapePartArray, 0, shapePartPool);
    btCollisionShape result = obtainStaticShape(shapePartArray);
    shapePartPool.freeAll(shapePartArray);
    shapePartArray.clear();
    return result;
}
UsefulMeshs.java 文件源码 项目:Mundus 阅读 22 收藏 0 点赞 0 评论 0
public static Model createArrowStub(Material mat, Vector3 from, Vector3 to) {
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder meshBuilder;
    // line
    meshBuilder = modelBuilder.part("line", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, mat);
    meshBuilder.line(from.x, from.y, from.z, to.x, to.y, to.z);
    // stub
    Node node = modelBuilder.node();
    node.translation.set(to.x, to.y, to.z);
    meshBuilder = modelBuilder.part("stub", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, mat);
    BoxShapeBuilder.build(meshBuilder, 2, 2, 2);
    return modelBuilder.end();
}
GameModel.java 文件源码 项目:GdxDemo3D 阅读 26 收藏 0 点赞 0 评论 0
public static void applyTransform(Vector3 location, Vector3 rotation, Vector3 scale,
                                  ModelInstance modelInstance) {
    for (Node node : modelInstance.nodes) {
        node.scale.set(Math.abs(scale.x), Math.abs(scale.y), Math.abs(scale.z));
    }
    modelInstance.transform.rotate(Vector3.X, rotation.x);
    modelInstance.transform.rotate(Vector3.Z, rotation.z);
    modelInstance.transform.rotate(Vector3.Y, rotation.y);
    modelInstance.transform.setTranslation(location);

    modelInstance.calculateTransforms();
}


问题


面经


文章

微信
公众号

扫码关注公众号