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);
}
}
java类com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute的实例源码
GameObject.java 文件源码
项目:ZombieInvadersVR
阅读 17
收藏 0
点赞 0
评论 0
ShadowShader.java 文件源码
项目:origin
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void render(Renderable renderable, Attributes combinedAttributes)
{
// context.setCullFace(GL_BACK);
// Classic depth test
context.setDepthTest(GL20.GL_LEQUAL);
// Deactivate blending on first pass
context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
context.setDepthMask(true);
if (!combinedAttributes.has(BlendingAttribute.Type))
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
super.render(renderable, combinedAttributes);
// program.begin();
// super.render(renderable, combinedAttributes);
// program.end();
}
TerrainBuilder.java 文件源码
项目:ForgE
阅读 18
收藏 0
点赞 0
评论 0
private VoxelChunkRenderable buildFaceForChunkWithAssembler(Chunk chunk, VoxelsAssembler assembler, boolean haveTransparency) {
if (!assembler.isEmpty()) {
VoxelChunkRenderable renderable = new VoxelChunkRenderable();
renderable.primitiveType = GL30.GL_TRIANGLES;
if (ForgE.config.getBool(Config.Key.GenerateWireframe))
renderable.wireframe = assembler.wireframe();
renderable.triangleCount = assembler.getTriangleCount();
renderable.meshFactory = assembler.meshFactory(MeshVertexInfo.voxelTypes());
renderable.worldTransform.idt();
renderable.material = new Material(new SolidTerrainAttribute());
if (haveTransparency) {
renderable.material.set(new BlendingAttribute(true,1f));
}
chunk.addFace(renderable);
return renderable;
} else {
return null;
}
}
VoxelChunkRenderableFactorySerializer.java 文件源码
项目:ForgE
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void write(Kryo kryo, Output output, VoxelChunkRenderableFactory object) {
output.writeInt(object.triangleCount);
output.writeInt(object.primitiveType);
output.writeBoolean(object.material.has(SolidTerrainAttribute.Type));
output.writeBoolean(object.material.has(BlendingAttribute.Type));
output.writeBoolean(object.material.has(WaterAttribute.Type));
output.writeInt(object.attributes.length);
for (MeshVertexInfo.AttributeType attribute : object.attributes) {
kryo.writeObject(output, attribute);
}
output.writeInt(object.meshFactory.verties.length);
output.writeInt(object.meshFactory.indices.length);
output.writeFloats(object.meshFactory.verties);
output.writeShorts(object.meshFactory.indices);
}
DepthShader.java 文件源码
项目:libgdxcn
阅读 22
收藏 0
点赞 0
评论 0
@Override
public boolean canRender (Renderable renderable) {
if (renderable.material.has(BlendingAttribute.Type)) {
if ((materialMask & BlendingAttribute.Type) != BlendingAttribute.Type)
return false;
if (renderable.material.has(TextureAttribute.Diffuse) != ((materialMask & TextureAttribute.Diffuse) == TextureAttribute.Diffuse))
return false;
}
final boolean skinned = ((renderable.mesh.getVertexAttributes().getMask() & Usage.BoneWeight) == Usage.BoneWeight);
if (skinned != (numBones > 0)) return false;
if (!skinned) return true;
int w = 0;
final int n = renderable.mesh.getVertexAttributes().size();
for (int i = 0; i < n; i++) {
final VertexAttribute attr = renderable.mesh.getVertexAttributes().get(i);
if (attr.usage == Usage.BoneWeight) w |= (1 << attr.unit);
}
return w == weights;
}
DepthShader.java 文件源码
项目:libgdxcn
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void render (final Renderable renderable) {
if (renderable.material.has(BlendingAttribute.Type)) {
final BlendingAttribute blending = (BlendingAttribute)renderable.material.get(BlendingAttribute.Type);
renderable.material.remove(BlendingAttribute.Type);
final boolean hasAlphaTest = renderable.material.has(FloatAttribute.AlphaTest);
if (!hasAlphaTest)
renderable.material.set(alphaTestAttribute);
if (blending.opacity >= ((FloatAttribute)renderable.material.get(FloatAttribute.AlphaTest)).value)
super.render(renderable);
if (!hasAlphaTest)
renderable.material.remove(FloatAttribute.AlphaTest);
renderable.material.set(blending);
} else
super.render(renderable);
}
TileHighlightDisplayable.java 文件源码
项目:HelixEngine
阅读 16
收藏 0
点赞 0
评论 0
public TileHighlightDisplayable() {
ModelBuilder modelBuilder = new ModelBuilder();
Model model
= modelBuilder.createRect(0, 0, Z_OFFSET,
1, 0, Z_OFFSET,
1, 1, Z_OFFSET,
0, 1, Z_OFFSET,
0, 0, 1,
GL20.GL_TRIANGLES,
new Material(
new ColorAttribute(
ColorAttribute.createDiffuse(color)),
new BlendingAttribute(
GL20.GL_SRC_ALPHA,
GL20.GL_ONE_MINUS_SRC_ALPHA)),
VertexAttributes.Usage.Position |
VertexAttributes.Usage.TextureCoordinates);
instance = new ModelInstance(model);
}
AreaDisplayable.java 文件源码
项目:HelixEngine
阅读 18
收藏 0
点赞 0
评论 0
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);
}
}
Utils3D.java 文件源码
项目:bladecoder-adventure-engine
阅读 25
收藏 0
点赞 0
评论 0
public static void createFloor() {
ModelBuilder modelBuilder = new ModelBuilder();
modelBuilder.begin();
MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES,
Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(
ColorAttribute.createDiffuse(Color.WHITE)));
mpb.setColor(1f, 1f, 1f, 1f);
// mpb.box(0, -0.1f, 0, 10, .2f, 10);
mpb.rect(-10, 0, -10,
-10, 0, 10,
10, 0, 10,
10, 0, -10, 0, 1, 0);
floorModel = modelBuilder.end();
floorInstance = new ModelInstance(floorModel);
// TODO Set only when FBO is active
floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
}
LedEntity.java 文件源码
项目:BotLogic
阅读 23
收藏 0
点赞 0
评论 0
public LedEntity(Model model) {
super(model);
light = new PointLight();
light.set(new Color(1f,1f, 1f, 1f), Vector3.Zero, 2f);
for (Material material : instance.materials) {
if (material.id.contains("Led")) {
this.colorAttr = (ColorAttribute)material.get(ColorAttribute.Diffuse);
colorAttr.color.set(Color.WHITE);
this.blendingAttribute = (BlendingAttribute)material.get(BlendingAttribute.Type);
blendingAttribute.opacity = 1.0f;
blendingAttribute.sourceFunction = GL20.GL_ONE;
blendingAttribute.destFunction = GL20.GL_SRC_ALPHA;
}
}
}
ModelManager.java 文件源码
项目:gdx-proto
阅读 26
收藏 0
点赞 0
评论 0
public void createBillboardTest() {
ModelBuilder mb = new ModelBuilder();
mb.begin();
long attr = Usage.TextureCoordinates | Usage.Position | Usage.Normal;
TextureRegion region = Assets.getAtlas().findRegion("sprites/test-guy");
Material mat = new Material(TextureAttribute.createDiffuse(region.getTexture()));
boolean blended = true;
float opacity = 1f;
mat.set(new BlendingAttribute(blended, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, opacity));
MeshPartBuilder mpb = mb.part("rect", GL20.GL_TRIANGLES, attr, mat);
mpb.setUVRange(region);
// the coordinates are offset so that we can easily set the center position to align with the entity's body
float sz = 2f; // size
float b = -sz/2; // base
float max = sz/2; // max
Vector3 bl = new Vector3(b, b, 0f);
Vector3 br = new Vector3(b, max, 0f);
Vector3 tr = new Vector3(max, max, 0f);
Vector3 tl = new Vector3(max, b, 0f);
Vector3 norm = new Vector3(0f, 0f, 1f);
mpb.rect(bl, tl, tr, br, norm);
billboardTestModel = mb.end();
}
Shadow.java 文件源码
项目:gdx-proto
阅读 26
收藏 0
点赞 0
评论 0
public static void init() {
list = new Array<>();
ModelBuilder mb = new ModelBuilder();
Vector3 norm = new Vector3(0f, 1f, 0f);
Texture texture = Assets.manager.get("textures/shadow.png", Texture.class);
Material material = new Material(TextureAttribute.createDiffuse(texture));
material.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.7f));
//material.set(new DepthTestAttribute(0)); // disable depth testing
long attr = Usage.Position | Usage.TextureCoordinates;
float s = 1f;
model = mb.createRect(
-s, 0f, -s,// bl
-s, 0f, s, // tl
s, 0f, s, // tr
s, 0f, -s, // br
norm.x, norm.y, norm.z,
material,
attr
);
}
Assets.java 文件源码
项目:Cubes_2
阅读 22
收藏 0
点赞 0
评论 0
private static PackedTextureSheet getPackedTextureSheet(AssetType... assetType) {
if (Adapter.isDedicatedServer())
return null;
TexturePacker texturePacker = new TexturePacker(2048, 2048, 1, true);
Pixmap pixmap;
getPacketTextureSheetFor(assetType, texturePacker, pixmap);
FileHandle fileHandle = assetsFolder.child("packed");
fileHandle.mkdirs();
Compatibility.get().nomedia(fileHandle);
fileHandle = fileHandle.child(assetType[0].name() + ".cim");
try {
PixmapIO.writeCIM(fileHandle, texturePacker.getPixmap());
} catch (GdxRuntimeException e) {
Log.error("Failed to write packed image", e);
}
Texture texture = new Texture(fileHandle);
texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
PackedTextureSheet packedTextureSheet = new PackedTextureSheet(
new Material(TextureAttribute.createDiffuse(texture)));
packedTextureSheet.getMaterial().set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA));
Map<Asset, TexturePacker.PackRectangle> rectangles = texturePacker.getRectangles();
int num = 0;
for (Map.Entry<Asset, TexturePacker.PackRectangle> entry : rectangles.entrySet()) {
num++;
TextureRegion textureRegion = new TextureRegion(texture, entry.getValue().x, entry.getValue().y,
entry.getValue().width, entry.getValue().height);
entry.getKey().setPackedTextureRegion(textureRegion, packedTextureSheet);
packedTextureSheet.getPackedTextures().put(entry.getKey().toString(), textureRegion);
}
for (AssetType type : assetType) {
type.setPackedTextureSheet(packedTextureSheet);
}
return packedTextureSheet;
}
ParticleShader.java 文件源码
项目:nhglib
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable) {
if (!renderable.material.has(BlendingAttribute.Type)) {
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
bindMaterial(renderable);
super.render(renderable);
}
ParticleShader.java 文件源码
项目:nhglib
阅读 21
收藏 0
点赞 0
评论 0
protected void bindMaterial(final Renderable renderable) {
if (currentMaterial == renderable.material) return;
int cullFace = config.defaultCullFace == -1 ?
GL20.GL_BACK :
config.defaultCullFace;
int depthFunc = config.defaultDepthFunc == -1 ?
GL20.GL_LEQUAL :
config.defaultDepthFunc;
float depthRangeNear = 0f;
float depthRangeFar = 1f;
boolean depthMask = true;
currentMaterial = renderable.material;
for (final Attribute attr : currentMaterial) {
final long t = attr.type;
if (BlendingAttribute.is(t)) {
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
} else if ((t & DepthTestAttribute.Type) == DepthTestAttribute.Type) {
DepthTestAttribute dta = (DepthTestAttribute) attr;
depthFunc = dta.depthFunc;
depthRangeNear = dta.depthRangeNear;
depthRangeFar = dta.depthRangeFar;
depthMask = dta.depthMask;
} else if (!config.ignoreUnimplemented) {
throw new GdxRuntimeException("Unknown material attribute: " + attr.toString());
}
}
context.setCullFace(cullFace);
context.setDepthTest(depthFunc, depthRangeNear, depthRangeFar);
context.setDepthMask(depthMask);
}
DepthMapShader.java 文件源码
项目:nhglib
阅读 25
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable) {
if (!renderable.material.has(BlendingAttribute.Type)) {
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
} else {
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
updateBones(renderable);
super.render(renderable);
}
PointSpriteSoftParticleBatch.java 文件源码
项目:nhglib
阅读 23
收藏 0
点赞 0
评论 0
protected void allocRenderable() {
renderable = new Renderable();
renderable.meshPart.primitiveType = GL20.GL_POINTS;
renderable.meshPart.offset = 0;
renderable.material = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
new DepthTestAttribute(GL20.GL_LEQUAL, false), TextureAttribute.createDiffuse((Texture) null));
}
SimpleTextureShader.java 文件源码
项目:Argent
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable)
{
if (!renderable.material.has(BlendingAttribute.Type))
{
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
ShadowMapShader.java 文件源码
项目:Argent
阅读 17
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable)
{
if (!renderable.material.has(BlendingAttribute.Type))
{
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
VolumetricDepthShader.java 文件源码
项目:Argent
阅读 27
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable) {
if (!renderable.material.has(BlendingAttribute.Type)) {
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
} else {
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
DynamicShader.java 文件源码
项目:Argent
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable) {
if (!renderable.material.has(BlendingAttribute.Type)) {
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}else{
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
NormalTextureShader.java 文件源码
项目:Argent
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable)
{
if (!renderable.material.has(BlendingAttribute.Type))
{
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
DepthMapShader.java 文件源码
项目:Argent
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void render(final Renderable renderable)
{
if (!renderable.material.has(BlendingAttribute.Type))
{
context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
else
{
context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
super.render(renderable);
}
AttributeTypeAdapter.java 文件源码
项目:Argent
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void write(JsonWriter out, Attribute value) throws IOException {
if(value == null) {
out.nullValue();
return;
}
out.beginObject();
String alias = value.getClass().getSimpleName();
out.name("type").value(value.type);
alias += "::" + value.getAttributeAlias(value.type);
out.name("alias").value(alias);
out.name("attrData").beginObject();
if(value instanceof TextureAttribute) {
out.name("offsetU").value(((TextureAttribute) value).offsetU);
out.name("offsetV").value(((TextureAttribute) value).offsetV);
out.name("scaleU").value(((TextureAttribute) value).scaleU);
out.name("scaleV").value(((TextureAttribute) value).scaleV);
out.name("textureDescriptor").value(JSONSerializer.instance().serialize(((TextureAttribute) value).textureDescription));
}else if(value instanceof ColorAttribute) {
out.name("colour").value(((ColorAttribute) value).color.toString());
}else if(value instanceof BlendingAttribute) {
out.name("alpha").value(((BlendingAttribute) value).opacity);
}
out.endObject();
out.endObject();
}
AttributeTypeAdapter.java 文件源码
项目:Argent
阅读 25
收藏 0
点赞 0
评论 0
@Override
public Attribute read(JsonReader in) throws IOException {
Attribute attr = null;
long type = -1;
String alias = "";
in.beginObject();
while(in.hasNext()) {
switch(in.nextName()) {
case "type": type = in.nextLong(); break;
case "alias": alias = in.nextString(); break;
case "attrData":
attr = buildFromAlias(alias);
if(attr == null) break;
in.beginObject();
while(in.hasNext()) {
switch(in.nextName()) {
case "offsetU":
((TextureAttribute)attr).offsetU = (float) in.nextDouble(); break;
case "offsetV":
((TextureAttribute)attr).offsetV = (float) in.nextDouble(); break;
case "scaleU":
((TextureAttribute)attr).scaleU = (float) in.nextDouble(); break;
case "scaleV":
((TextureAttribute)attr).scaleV = (float) in.nextDouble(); break;
case "textureDescriptor":
((TextureAttribute)attr).textureDescription.set(JSONSerializer.instance().deserialize(in.nextString(), TextureDescriptor.class)); break;
case "colour":
((ColorAttribute)attr).color.set(Color.valueOf(in.nextString())); break;
case "alpha":
((BlendingAttribute)attr).opacity = (float) in.nextDouble(); break;
}
}
in.endObject();
break;
}
}
in.endObject();
return attr;
}
GridSpaceHighlighter.java 文件源码
项目:ChessGDX
阅读 22
收藏 0
点赞 0
评论 0
/**
* Typically transparent plane that covers a board grid space. Can change
* color to specify legal or illegal moves to the user.
*
* @param fullModelInstance
* @param indexPosition
* Chesspresso notation board location (0 to 63)
*/
public GridSpaceHighlighter(ModelInstance fullModelInstance, int indexPosition) {
super(fullModelInstance);
mGridState = GridState.NONE;
mAlphaBlend = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.0f);
// translate to starting board position
Vector3 initialPosition = getGridToPerspectiveTranslation(indexPosition);
setTranslation(initialPosition);
fullModelInstance.materials.get(0).set(mAlphaBlend);
}
GameRenderer.java 文件源码
项目:Radix
阅读 23
收藏 0
点赞 0
评论 0
private void drawBlockSelection() {
int curProgressInt = Math.round(RadixClient.getInstance().getPlayer().getBreakPercent() * 10) - 1;
if ((blockBreakModel == null || blockBreakStage != curProgressInt) && curProgressInt >= 0) {
if (blockBreakModel != null)
blockBreakModel.dispose();
blockBreakStage = curProgressInt;
ModelBuilder builder = new ModelBuilder();
blockBreakModel = builder.createBox(1f, 1f, 1f,
new Material(TextureAttribute.createDiffuse(blockBreakStages[blockBreakStage]),
new BlendingAttribute(),
FloatAttribute.createAlphaTest(0.25f)),
VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates);
blockBreakModelInstance = new ModelInstance(blockBreakModel);
}
Vec3i curBlk = RadixClient.getInstance().getSelectedBlock();
if (curBlk != null && curProgressInt >= 0) {
Gdx.gl.glPolygonOffset(100000, 2000000);
blockOverlayBatch.begin(RadixClient.getInstance().getCamera());
blockBreakModelInstance.transform.translate(curBlk.x + 0.5f, curBlk.y + 0.5f, curBlk.z + 0.5f);
blockOverlayBatch.render(blockBreakModelInstance);
blockBreakModelInstance.transform.translate(-(curBlk.x + 0.5f), -(curBlk.y + 0.5f), -(curBlk.z + 0.5f));
blockOverlayBatch.end();
Gdx.gl.glPolygonOffset(100000, -2000000);
}
}
ModelFactory.java 文件源码
项目:GdxDemo3D
阅读 34
收藏 0
点赞 0
评论 0
public static Model buildBillboardModel(Texture texture, float width, float height) {
TextureRegion textureRegion = new TextureRegion(texture, texture.getWidth(), texture.getHeight());
Material material = new Material();
material.set(new TextureAttribute(TextureAttribute.Diffuse, textureRegion));
material.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
material.set(new BlendingAttribute());
return ModelFactory.buildPlaneModel(width, height, material, 0, 0, 1, 1);
}
Rocket.java 文件源码
项目:Alien-Ark
阅读 25
收藏 0
点赞 0
评论 0
public void drawModel(ModelBatch modelBatch, Environment environment, ParticleEffect[] thrustEffect,
ParticleEffect effectExplosion) {
if (!exploded) {
modelBatch.render(rocketModelInstance, environment);
long damageDelay = System.currentTimeMillis() - lastDamageTime;
if (damageDelay < MIN_DAMAGE_DELAY_MILLIS) {
float opacity = (float) damageDelay / (float) (MIN_DAMAGE_DELAY_MILLIS);
((BlendingAttribute) shieldModelInstance.materials.get(0).get(BlendingAttribute.Type)).opacity = opacity;
modelBatch.render(shieldModelInstance, environment);
}
if (tractorBeamVisible) {
modelBatch.render(tractorBeamModelInstance, environment);
}
}
thrustMatrix1.set(rocketModelInstance.transform);
tmpMatrix.setToRotation(0, 1, 0, drill);
tmpMatrix.trn(0, 1, 0.35f);
thrustMatrix1.mul(tmpMatrix);
thrustEffect[0].setTransform(thrustMatrix1);
thrustMatrix2.set(rocketModelInstance.transform);
tmpMatrix.setToRotation(0, 1, 0, drill);
tmpMatrix.trn(-0.35f, 1, -0.20f);
thrustMatrix2.mul(tmpMatrix);
thrustEffect[1].setTransform(thrustMatrix2);
thrustMatrix3.set(rocketModelInstance.transform);
tmpMatrix.setToRotation(0, 1, 0, drill);
tmpMatrix.trn(0.350f, 1, -0.25f);
thrustMatrix3.mul(tmpMatrix);
thrustEffect[2].setTransform(thrustMatrix3);
effectExplosion.setTransform(rocketModelInstance.transform);
}
CameraRenderableSorter.java 文件源码
项目:ForgE
阅读 18
收藏 0
点赞 0
评论 0
public int compare (final Renderable o1, final Renderable o2) {
final boolean b1 = o1.material != null && o1.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o1.material.get(BlendingAttribute.Type)).blended;
final boolean b2 = o2.material != null && o2.material.has(BlendingAttribute.Type) && ((BlendingAttribute)o2.material.get(BlendingAttribute.Type)).blended;
if (b1 != b2) return b1 ? 1 : -1;
o1.worldTransform.getTranslation(tmpV1);
o2.worldTransform.getTranslation(tmpV2);
final float dst = (int)(SORT_FACTOR * camera.position.dst2(tmpV1)) - (int)(SORT_FACTOR * camera.position.dst2(tmpV2));
final int result = dst < 0 ? -1 : (dst > 0 ? 1 : 0);
return b1 ? -result : result;
}