mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Fixed various rendering issue with spheres
This commit is contained in:
parent
34c924d758
commit
bbcfba31b7
4 changed files with 28 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.model;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.GLU;
|
||||
import org.lwjgl.util.glu.Sphere;
|
||||
|
||||
|
@ -61,16 +62,10 @@ public class ModelSphere {
|
|||
|
||||
private void bake() {
|
||||
displayList = GLAllocation.generateDisplayLists(1);
|
||||
GlStateManager.glNewList(displayList, 4864);
|
||||
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.glNewList(displayList, GL11.GL_COMPILE);
|
||||
|
||||
drawShape();
|
||||
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
|
||||
GlStateManager.glEndList();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.particle.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -7,7 +8,6 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.minelittlepony.unicopia.model.ModelSphere;
|
||||
import com.minelittlepony.unicopia.particle.IAttachableParticle;
|
||||
import com.minelittlepony.unicopia.spell.ICaster;
|
||||
|
@ -25,7 +25,7 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
|||
private static final ModelSphere model = new ModelSphere();
|
||||
|
||||
public ParticleSphere(int id, World w, double x, double y, double z, double vX, double vY, double vZ, int... args) {
|
||||
this(w, x, y, z, args[0] / 1000F, args[1], args[2]/255F);
|
||||
this(w, x, y, z, args[0] / 1000F, args[1], args[2]/100F);
|
||||
|
||||
this.motionX = vX;
|
||||
this.motionY = vY;
|
||||
|
@ -78,24 +78,28 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
|||
return;
|
||||
}
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
|
||||
|
||||
if (alpha < 1) {
|
||||
GlStateManager.depthMask(false);
|
||||
GlStateManager.shadeModel(GL11.GL_SMOOTH);
|
||||
GlStateManager.tryBlendFuncSeparate(
|
||||
GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
}
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap();
|
||||
GlStateManager.enableLighting();
|
||||
|
||||
Color.glColor(tint, alpha);
|
||||
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
GlStateManager.disableTexture2D();
|
||||
|
||||
model.setPosition(posX, posY, posZ);
|
||||
model.render(radius);
|
||||
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
GlStateManager.enableTexture2D();
|
||||
GlStateManager.disableLighting();
|
||||
Minecraft.getMinecraft().entityRenderer.enableLightmap();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.depthMask(true);
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,6 +107,12 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
|
|||
if (key == 0) {
|
||||
radius = (float)value;
|
||||
}
|
||||
if (key == 1) {
|
||||
tint = (int)value;
|
||||
}
|
||||
if (key == 3) {
|
||||
alpha = (float)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,9 +173,9 @@ public class SpellDarkness extends AbstractAttachableSpell {
|
|||
public void render(ICaster<?> source) {
|
||||
int radius = 7 + (source.getCurrentLevel() * 3);
|
||||
|
||||
boolean tamed = hasTarget();
|
||||
boolean tamed = !searching;
|
||||
|
||||
int tint = tamed ? 0xFFFFFF : getTint();
|
||||
int tint = tamed ? 0xFFFFFF : 0x000000;
|
||||
|
||||
if (tamed) {
|
||||
radius /= 3;
|
||||
|
@ -231,7 +231,7 @@ public class SpellDarkness extends AbstractAttachableSpell {
|
|||
double vX = (source.getWorld().rand.nextFloat() - 0.5) * particleSpeed;
|
||||
double vZ = (source.getWorld().rand.nextFloat() - 0.5) * particleSpeed;
|
||||
|
||||
Particles.instance().spawnParticle(UParticles.SPHERE, false, pos, vX, 0, vZ, (int)(size * 1000), tint, 100);
|
||||
Particles.instance().spawnParticle(UParticles.SPHERE, false, pos, vX, 0, vZ, (int)(size * 1000), tint, 30);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
|||
});
|
||||
|
||||
particlEffect
|
||||
.ifMissing(source, () -> Particles.instance().spawnParticle(UParticles.SPHERE, true, source.getOriginVector(), 0, 0, 0, 1, getTint(), 30))
|
||||
.ifMissing(source, () -> Particles.instance().spawnParticle(UParticles.SPHERE, true, source.getOriginVector(), 0, 0, 0, 1, getTint(), 10))
|
||||
.ifPresent(p -> p.setAttribute(0, radius));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue