本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.ModelInstance类的典型用法代码示例。如果您正苦于以下问题:Java ModelInstance类的具体用法?Java ModelInstance怎么用?Java ModelInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelInstance类属于com.badlogic.gdx.graphics.g3d包,在下文中一共展示了ModelInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Basic
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
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);
}
示例2: tick
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public void tick(float delta, GameScreen screen) {
if (!started && screen.isPaused()) {
started = true;
prevTime = System.currentTimeMillis();
}
if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) {
prevTime = System.currentTimeMillis();
String name = spawns.get(enemyIndex).getName();
ModelInstance instance;
try {
Class<?> c = enemyClasses.get(name);
Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class);
enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds));
} catch (Exception e) {
Gdx.app.log("EnemySpawner spawn enemy", e.toString());
}
enemyIndex++;
}
//for (Enemy enemy : enemies)
// enemy.tick(delta, path);
}
示例3: Shark
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
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);
}
示例4: addBackground
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
private void addBackground(){
decalBackground = Decal.newDecal(new TextureRegion(managerAssets.getAssetsCrafting().getTexture(NameFiles.backgroundCrafting)));
decalBackground.setDimensions(100,200);
decalBackground.setPosition(0,0,0);
environment = new Environment();
// environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1f));
environment.set(new ColorAttribute(ColorAttribute.Diffuse));
environment.set(new ColorAttribute(ColorAttribute.Specular));
environment.set(new ColorAttribute(ColorAttribute.Reflection));
environment.add(new DirectionalLight().set(0.51f, 0.5f, 0.5f, 0f, -2f, -30f));
Model model = managerAssets.getAssetsRaider().getModel(NameFiles.raiderFull);
model.nodes.get(2).translation.set(-12,28.6f,-5.5f);
// model.nodes.get(0).translation.set(0,28f,29.2f);
// model.nodes.get(2).translation.set(0,13,-1);
instance = new ModelInstance(model);
instance.transform.trn(0,-20,25).rotate(0,1,0,-25);
instance.transform.scale(1.5f,1.5f,1.5f);
}
示例5: ScreenCrafting
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public ScreenCrafting(GameManager game) {
this.gameManager = game;
informationProfile = InformationProfile.getInstance();
managerAssets = ManagerAssets.getInstance();
queue = QueueBuildCraft.getInstance();
intances = new Array<ModelInstance>();
camera = new PerspectiveCamera(45,WIDTH,HEIGHT);
camera.position.set(0,0,1020);
camera.lookAt(0, 0, 0);
camera.near = 1;
camera.far = 1500;
camera.update();
nameRes.add("SCRAP");
nameRes.add("BRICK");
nameRes.add("CELL");
arrayDecal = new Array<Decal>();
}
示例6: getObject
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public GameObject getObject (int screenX, int screenY) {
Ray ray = camera.getPickRay(screenX, screenY);
GameObject result = null;
float distance = -1;
for (ModelInstance item : instances) {
if(item instanceof GameObject){
GameObject gameObject = (GameObject) item;
if(gameObject.enabled){
Vector3 position = gameObject.transform.getTranslation(new Vector3());
gameObject.updateBox();
position.add(gameObject.center);
float dist2 = ray.origin.dst2(position);
if (distance >= 0f && dist2 > distance) continue;
if (Intersector.intersectRayBoundsFast(ray, gameObject.bounds)) {
result = gameObject;
distance = dist2;
}
}
}
}
return result;
}
示例7: alphaToAnimation
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public void alphaToAnimation(float alpha, float time, final GameObject.OnAnimationComplete onAnimationComplete) {
final GameObject object = this;
Tween.registerAccessor(ModelInstance.class, new GameObjectAccessor());
if(alpha > 1) alpha = 1;
if(alpha < 0) alpha = 0;
context.tweenManager.killTarget(this, GameObjectAccessor.ALPHA);
Tween.to(this, GameObjectAccessor.ALPHA, time)
.target(alpha)
.ease(TweenEquations.easeNone)
.start(context.tweenManager)
.setCallback(new TweenCallback() {
@Override public void onEvent(int arg0, BaseTween<?> arg1) {
if(onAnimationComplete != null) onAnimationComplete.run(object);
}
});
}
示例8: createEntity
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
@Deprecated //Only for creating the first one
private void createEntity(float f, float g, float h) {
Vector3 position=new Vector3(f,g,h);
List<EntityStatic> collidingEntities=space.getWithin(position, 0.03);
if(collidingEntities.size() == 0) {
EntityStatic entity=new EntityStatic(new ModelInstance(
Assets.modelBuilder.createBox(0.03f, 0.03f, 0.06f,
new Material(StrategyGame.blueAttr),
Usage.Normal | Usage.Position)),
position);
space.addEntity(entity);
} else {
for(EntityStatic e:collidingEntities){
e.damage(2);
}
}
}
示例9: create
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
/** Инициализация и загрузка ресурсов */
@Override
public void create () {
// Размеры экрана
scrHalfWidth = Gdx.graphics.getWidth() / 2;
scrHeight = Gdx.graphics.getHeight();
// Загрузка модели из файла
modelBatch = new ModelBatch();
assets = new AssetManager();
assets.load("room.g3db", Model.class);
assets.finishLoading();
Model roomModel = assets.get("room.g3db");
roomInstance = new ModelInstance(roomModel);
// Создание камеры (fov, parallax, near, far) и установка позиции
vrCamera = new VRCamera(90, 0.4f, 0.1f, 30f);
vrCamera.setPosition(-1.7f, 3f, 3f);
// Разрешаем коррекцию дрифта при помощи компаса
vrSensorManager.useDriftCorrection(true);
}
示例10: render
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
@Override
public void render(float delta) {
dynamicsWorld.setGravity(new Vector3(0, -100, 0));
// Restricts physics update to a maximum of 5 per frame.
// Should only do 1 though, but will do more to maintain physics simulation independent of frame rate
dynamicsWorld.stepSimulation(delta, 5, 1/60f);
for (T obj : instances) {
btRigidBody body = renderer.getBulletBody(obj);
ModelInstance inst = renderer.getRenderable(obj);
if(body != null) {
body.getWorldTransform(inst.transform);
}
}
super.render(delta);
debugRenderer.update(renderer().camera());
}
示例11: constructCells
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public void constructCells() {
builder.begin();
int vertAttrs = Position | Normal | TextureCoordinates;
for(int x = 0; x < cells.length; x++) {
for (int z = 0; z < cells[x].length; z++) {
MeshPartBuilder partBuilder = builder.part("cell"+x+","+z, GL30.GL_TRIANGLES, vertAttrs, Reference.Defaults.Models.material());
partBuilder.rect(getPoint("D", x, z), getPoint("C", x, z), getPoint("B", x, z), getPoint("A", x, z), Vector3.Y);
cells[x][z].setCellPart(partBuilder.getMeshPart());
cells[x][z].init();
}
}
model = builder.end();
instance = new ModelInstance(model);
}
示例12: draw
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
@Override
public GLFrameBuffer draw(List<ModelInstance> renderables) {
applyToShader(shaderProgram);
if(fbo == null) buildFBO();
fbo.begin();
while(((FrameBufferCubemap)fbo).nextSide()) {
camera().direction.set(
((FrameBufferCubemap) fbo)
.getSide()
.direction);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
batch.begin(camera());
batch.render(renderables);
batch.end();
if (Gdx.input.isKeyJustPressed(Input.Keys.F3))
ScreenshotFactory.saveScreenshot(DEPTHMAPSIZE, DEPTHMAPSIZE, "PointLight");
}
fbo.end();
return fbo;
}
示例13: select
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
@Override
protected AbstractPanel select(T obj) {
super.select(obj);
if(obj == null) {
matList.clearItems();
selectMtl(null);
return this;
}
ModelInstance inst = gameWorld.renderer().getRenderable(obj);
matList.clearItems();
inst.nodes.forEach(n -> n.parts.forEach(p -> {
ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(p.material, this::selectMtl);
e.getString = () -> String.format("[%s] %s", n.id, e.obj.id);
matList.addItem(e);
}));
// inst.materials.forEach(m -> {
// ArgentList.ArgentListElement<Material> e = new ArgentList.ArgentListElement<>(m, this::selectMtl);
// e.getString = () -> e.obj.id;
// matList.addItem(e);
// });
selectMtl(null);
return this;
}
示例14: shift_row
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public void shift_row(Array<ModelInstance> level, Array<ModelInstance> addRow, boolean wire){
try {
for (ModelInstance part : level) {
Vector3 v = new Vector3();
part.transform.getTranslation(v);
int x = Math.round(v.x);
int z = Math.round(v.z);
int y = Math.round(v.y);
part.transform.translate(0f, -1f, 0f);
if (!wire) {
matrix[x][y][z] = false;
matrix[x][y - 1][z] = true;
}
addRow.add(part);
}
level.clear();
}catch (Exception e){
return;
}
}
示例15: BoxThree
import com.badlogic.gdx.graphics.g3d.ModelInstance; //导入依赖的package包/类
public BoxThree(PerspectiveCamera cam, boolean[][][] collision) {
super(cam,collision);
for(float x = 2f; x < 5f; ++x){
for(float z = 2f; z < 5f; ++z){
for(float y = 10f; y < 13f; ++y){
ModelInstance p = new ModelInstance(white,x,y,z);
ModelInstance s = new ModelInstance(gray,x,y,z);
ModelInstance f = new ModelInstance(wire,x,y,z);
parts.add(p);
shadow.add(s);
frame.add(f);
}
}
}
traceShadow();
}