public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) { super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds); ((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90))); //System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id); listener = new AnimationController.AnimationListener() { @Override public void onEnd(AnimationController.AnimationDesc animationDesc) { } @Override public void onLoop(AnimationController.AnimationDesc animationDesc) { } }; //animation.setAnimation("Spider_Armature|walk_ani_vor"); //animation.animate("Spider_Armature|walk_ani_vor", -1); //animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0); //animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0); //animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0); }
public GameObject(ScreenBase context, Model model, BoundingBox bounds) { super(model); this.context = context; this.customBounds = bounds; this.bounds = this.customBounds != null ? this.customBounds : new BoundingBox(); this.center = new Vector3(); this.enabled = true; updateBox(); this.animations = new AnimationController(this); this.blending = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); for(Material item : materials){ item.set(new DepthTestAttribute(GL20.GL_LEQUAL, 0.01f, 25f, true)); item.set(FloatAttribute.createAlphaTest(0.01f)); item.set(blending); } }
public Shark() { hasPhysics = true; vitesse = (float) (4f+Math.random()*6f); if(animations==null) { animations = new Hashtable<String, Shark.Animation>(); for(Animation anim : anims) { animations.put(anim.id, anim); } } targetDir.setToRandomDirection(); targetDir.y=0; targetDir.nor(); size.set(0.016f, 0.016f, 0.016f); model = new ModelInstance(Assets.requin); transform = model.transform; animation = new AnimationController(model); animation.allowSameAnimation=true; animation.setAnimation( getNomAnimation(), -1); }
protected void switchAnimation () { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) { int animIndex = 0; if (e.value.current != null) { for (int i = 0; i < e.key.animations.size; i++) { final Animation animation = e.key.animations.get(i); if (e.value.current.animation == animation) { animIndex = i; break; } } } animIndex = (animIndex + 1) % e.key.animations.size; e.value.animate(e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f); } }
@Override protected void onLoaded () { if (currentlyLoading == null || currentlyLoading.length() == 0) return; instances.clear(); animationControllers.clear(); final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class)); instance.transform = transform; instances.add(instance); if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance)); currentlyLoading = null; instance.calculateBoundingBox(bounds); cam.position.set(1, 1, 1).nor().scl(bounds.getDimensions().len() * 0.75f + bounds.getCenter().len()); cam.up.set(0, 1, 0); cam.lookAt(0, 0, 0); cam.far = 50f + bounds.getDimensions().len() * 2.0f; cam.update(); }
protected void switchAnimation () { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) { int animIndex = 0; if (e.value.current != null) { for (int i = 0; i < e.key.animations.size; i++) { final Animation animation = e.key.animations.get(i); if (e.value.current.animation == animation) { animIndex = i; break; } } } animIndex = (animIndex + 1) % (e.key.animations.size + 1); e.value.animate((animIndex == e.key.animations.size) ? null : e.key.animations.get(animIndex).id, -1, 1f, null, 0.2f); } }
public AreaDisplayable(Model model) { instance = new ModelInstance(model); animationController = new AnimationController(instance); instance.transform.rotate(new Vector3(1, 0, 0), 90); for (Material material : instance.materials) { TextureAttribute ta = (TextureAttribute) material.get(TextureAttribute.Diffuse); ta.textureDescription.magFilter = Texture.TextureFilter.Nearest; ta.textureDescription.minFilter = Texture.TextureFilter.Nearest; material.set(ta); material.set(ColorAttribute.createDiffuse(Color.WHITE)); BlendingAttribute ba = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); material.set(ba); } }
private void retrieveSource(String source) { ModelCacheEntry entry = (ModelCacheEntry)sourceCache.get(source); if (entry == null || entry.refCounter < 1) { loadSource(source); EngineAssetManager.getInstance().finishLoading(); entry = (ModelCacheEntry)sourceCache.get(source); } if (entry.modelInstance == null) { Model model3d = EngineAssetManager.getInstance().getModel3D(source); entry.modelInstance = new ModelInstance(model3d); entry.controller = new AnimationController(entry.modelInstance); entry.camera3d = getCamera(entry.modelInstance); } }
public RobotEntity(Model model) { super(model); //scale.set(0.35f, 0.35f, 0.35f); animation = new AnimationController(instance); animation.setAnimation(ANIMATION_IDLE); this.headBone = instance.getNode("Head"); this.frontRightBone = instance.getNode("FrontRightWheel"); this.frontLeftBone = instance.getNode("FrontLeftWheel"); this.backLeftBone = instance.getNode("BackLeftWheel"); this.backRightBone = instance.getNode("BackRightWheel"); this.sonarSprite = BotLogic.sprites.sonarDecal(); }
public Entity(Matrix4 transform, int hp, int health, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds){ this.instance = instance; this.transform = transform; this.hp = hp; this.types = types; this.health = health; this.effects = effects; this.sounds = sounds; animation = new AnimationController(instance); this.instance.transform.set(transform); this.shape = shape; body = new btCollisionObject(); body.setCollisionShape(shape); body.setWorldTransform(this.instance.transform); this.world = world; tempVector = new Vector3(); tempVector2 = new Vector3(); this.entities = entities; tempQuaternion = new Quaternion(); quaternion = new Quaternion(); if(this instanceof Enemy || this instanceof Projectile) body.setCollisionFlags(body.getCollisionFlags()); int index = getNextIndex(); entities.put(index, this); body.setUserValue(index); world.addCollisionObject(body); boundingBox = instance.calculateBoundingBox(new BoundingBox()); //for(Node node: instance.nodes) //System.out.println(); }
public void buildWithModel(ModelInstance m) { model = m; boundingBox = new BoundingBox(); model.calculateBoundingBox(boundingBox); Vector3 dimensions = boundingBox.getDimensions(new Vector3()); radius = dimensions.len() / 2f; state = ModelComponent.State.READY; if (m.animations.size > 0) { animationController = new AnimationController(model); } }
public Monster() { hasPhysics = true; vitesse = (float) (1f+Math.random()*4f); // gravity = 100f; if(animations==null) { animations = new Hashtable<String, Shark.Animation>(); for(Animation anim : anims) { animations.put(anim.id, anim); } } dir.setToRandomDirection(); targetDir.setToRandomDirection(); targetDir.y=0; targetDir.nor(); size.set(2f, 2f, 2f); model = new ModelInstance(Assets.golem); transform = model.transform; baseRotationY = 15f; animation = new AnimationController(model); animation.allowSameAnimation=true; animation.setAnimation( getNomAnimation(), -1); }
public DogCharacter(Model model, String name, Vector3 location, Vector3 rotation, Vector3 scale, btCollisionShape shape, float mass, short belongsToFlag, short collidesWithFlag, boolean callback, boolean noDeactivate) { super(model, name, location, rotation, scale, shape, mass, belongsToFlag, collidesWithFlag, callback, noDeactivate, new DogSteerSettings()); // Create behavior tree through the library BehaviorTreeLibraryManager btlm = BehaviorTreeLibraryManager.getInstance(); this.tree = btlm.createBehaviorTree("btrees/dog.btree", this); // Create animation controller animations = new AnimationController(modelInstance); // Create path follower followPathSteerer = new FollowPathSteerer(this); // Create wander steerer wanderSteerer = new WanderSteerer(this); // Init flags humanWantToPlay = false; stickThrown = false; alreadyCriedForHumanDeath = false; humanIsDead = false; }
public HumanCharacter(Model model, String name, Vector3 location, Vector3 rotation, Vector3 scale, btCollisionShape shape, float mass, short belongsToFlag, short collidesWithFlag, boolean callback, boolean noDeactivate, Array<BlenderEmpty> ragdollEmpties, String armatureNodeId) { super(model, name, location, rotation, scale, shape, mass, belongsToFlag, collidesWithFlag, callback, noDeactivate, ragdollEmpties, armatureNodeId, new HumanSteerSettings()); // Create path follower followPathSteerer = new FollowPathSteerer(this); // Create the animation controllers animations = new AnimationController(modelInstance); // Create animation listeners for states that need one stateAnimationListeners = new EnumMap<HumanState, AnimationListener>(HumanState.class); stateAnimationListeners.put(HumanState.THROW, new AnimationListener()); // Create the state machine stateMachine = new DefaultStateMachine<HumanCharacter, HumanState>(this); // Set the steering variables associated with default move state (walking) stateMachine.changeState(moveState); // Then make the character idle stateMachine.changeState(moveState.idleState); }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) e.value.update(Gdx.graphics.getDeltaTime()); for (final ModelInstance instance : instances) renderSkeleton(instance); batch.render(instances); }
@Override protected void onLoaded () { if (currentlyLoading == null || currentlyLoading.isEmpty()) return; instances.clear(); animationControllers.clear(); final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class)); for (Material m : instance.materials) m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f)); instances.add(instance); if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance)); currentlyLoading = null; }
@Override public void render (Array<ModelInstance> instances) { lights.directionalLights.get(0).direction.rotate(dirLightRotAxis, Gdx.graphics.getDeltaTime() * 45f); super.render(null); for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) e.value.update(Gdx.graphics.getDeltaTime()); shaderBatch.begin(cam); shaderBatch.render(instances, lights); shaderBatch.end(); }
public Actor3d(Model model, float x, float y, float z){ super(model); setPosition(x,y,z); //boundBox = model.meshes.get(0).calculateBoundingBox(); calculateBoundingBox(boundBox); center.set(boundBox.getCenter()); dimensions.set(boundBox.getDimensions()); radius = dimensions.len() / 2f; animation = new AnimationController(this); }
public Entity(float x, float y, float z, String model) { id = classToIdMap.get(getClass()); modelInstance = new ModelInstance(Vloxlands.assets.get("models/" + model, Model.class)); modelInstance.calculateBoundingBox(boundingBox = new BoundingBox()); if (boundingBox.getDimensions().x % 1 != 0 || boundingBox.getDimensions().y % 1 != 0 || boundingBox.getDimensions().z % 1 != 0) { blockTrn.set(((float) Math.ceil(boundingBox.getDimensions().x) - boundingBox.getDimensions().x) / 2, 1 - boundingBox.getCenter().y, ((float) Math.ceil(boundingBox.getDimensions().z) - boundingBox.getDimensions().z) / 2); } blockTrn.add(boundingBox.getDimensions().cpy().scl(0.5f)); modelInstance.transform.translate(x, y, z).translate(blockTrn); animationController = new AnimationController(modelInstance); markedForRemoval = false; subs = new Array<ModelInstance>(); for (Node n : modelInstance.nodes.get(0).children) { if (n.id.startsWith("model:")) { subs.add(new ModelInstance(Vloxlands.assets.get("models/" + model.replace(model.substring(model.lastIndexOf("/") + 1), n.id.replace("model:", "")) + ".vxi", Model.class), n.translation)); } } modelInstance.transform.getTranslation(posCache); level = 0; modelVisible = true; additionalVisible = true; visible = true; dimensions.set(Math.max(Math.round(boundingBox.getDimensions().x), 1), Math.max(Math.round(boundingBox.getDimensions().y), 1), Math.max(Math.round(boundingBox.getDimensions().z), 1)); Game.instance.addListener(this); }
@Override protected void onLoaded () { if (currentlyLoading == null || currentlyLoading.isEmpty()) return; instances.clear(); animationControllers.clear(); final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class)); instance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.5f)); instances.add(instance); if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance)); currentlyLoading = null; }
@Override public void render () { float delta = Gdx.graphics.getDeltaTime(); gl.glClearColor(0, 0, 0, 0); gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); if(!assetsLoaded){ assetsLoaded = manager.update(); if(assetsLoaded){ splash_img.remove(); stage.addActor(cameraPrefsButton); createModelsinstances(); } }else { if(!arToolKitManager.arRunning())return; /* * Actualizar los controladores de animación */ for (AnimationController controller : animationControllers) { controller.update(delta); } /* Actualizar la matriz de proyección de la cámara * Update camera projection matrix */ camera.projection.set(arToolKitManager.getProjectionMatrix()); /* * Renderizar los modelos si el marcador está activo */ for (String markerName : instances.keys()) { if (arToolKitManager.markerVisible(markerName)) { transform.set(arToolKitManager.getTransformMatrix(markerName)); /* Actualizar Cámara * Update camera */ transform.getTranslation(camera.position); camera.position.scl(-1); camera.update(); /* Dependiendo de las coordenadas del modelo puede necesitar rotarlo * Depending from model coordinates it may be desired to apply a rotation */ transform.rotate(1, 0, 0, 90); ModelInstance instance = instances.get(markerName); instance.transform.set(transform); batch_3d.begin(camera); batch_3d.render(instance, environment); batch_3d.end(); } } } stage.act(); stage.draw(); }
@Override public void SetModel(Model model) { super.SetModel(model); _controller = new AnimationController(_modelInstance); }
public AnimationController GetAnimationController() { return _controller; }
@Override public void onEnd(AnimationController.AnimationDesc animation) { animationCompleted = true; }
@Override public void onLoop(AnimationController.AnimationDesc animation) { }
@Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { for (ObjectMap.Entry<ModelInstance, AnimationController> e : animationControllers.entries()) e.value.update(Gdx.graphics.getDeltaTime()); batch.render(instances, environment); }
public AnimationController getAnimationController() { return animationController; }
@Override public void onLoop(com.badlogic.gdx.graphics.g3d.utils.AnimationController.AnimationDesc animation) { }
@Override public void onEnd(com.badlogic.gdx.graphics.g3d.utils.AnimationController.AnimationDesc animation) { if (animationCb != null) { ActionCallbackQueue.add(animationCb); } }
@Override public void create() { /* * Libgdx objects */ //Create the maps for our model instances treeModelInstances = new HashMap<String, ModelInstance>(); treeModelAnimationControllers = new HashMap<String, AnimationController>(); modelBatch = new ModelBatch(); //Create asset manager and load our model assets = new AssetManager(); loading = true; assets.load("models/funky_palm_tree/funky_palm_tree.g3db", Model.class); //Create the environment and set the light in there environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, 0f, 0f, 100f)); //Create the objects needed to render text spriteBatch = new SpriteBatch(); font = new BitmapFont(); font.setColor(Color.RED); font.setScale(2); //Create the GL Camera camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.position.set(0.0f,0.0f,0.0f); //Camera position camera.up.set(0.0f,-1.0f,0.0f); //Up vector camera.lookAt(0.0f, 0.0f, 1.0f); //Forward vector camera.far = 10000.0f; //Far clipping plane distance camera.near = 0.1f; //Near clipping plane distance camera.update(); /* * Device camera controller */ deviceCameraControl.init(); /* * Chilitags object */ //Get the camera image size Size2D cameraSize = deviceCameraControl.getCameraSize(); //Get the image size that will be processed by Chilitags Size2D processingSize = deviceCameraControl.getProcessingSize(); //Create the actual Chilitags object chilitags = new Chilitags3D( cameraSize.width,cameraSize.height, processingSize.width,processingSize.height, Chilitags3D.InputType.values()[deviceCameraControl.getImageFormat().ordinal()]); double[] cc = { 270*processingSize.width/640, 0, processingSize.width/2, 0, 270*processingSize.width/640, processingSize.height/2, 0, 0, 1}; double[] dc = {}; chilitags.setCalibration(cc,dc); }
public AnimationController getAnimation(){ return animation; }