mesh now looks right
This commit is contained in:
parent
b879ceaf05
commit
d64dc8a4d1
@ -23,7 +23,7 @@ public class BasicVisualizer extends VisualizerCore {
|
|||||||
private int smoothRange;
|
private int smoothRange;
|
||||||
private float barHeightMultiplier;
|
private float barHeightMultiplier;
|
||||||
private float rotation;
|
private float rotation;
|
||||||
private Vector2 angleRad;
|
private Vector2 angleRot;
|
||||||
|
|
||||||
public BasicVisualizer() {
|
public BasicVisualizer() {
|
||||||
super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0);
|
super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0);
|
||||||
@ -36,7 +36,7 @@ public class BasicVisualizer extends VisualizerCore {
|
|||||||
spaceBetweenBars = (barWidth-7);
|
spaceBetweenBars = (barWidth-7);
|
||||||
barWidth -= spaceBetweenBars;
|
barWidth -= spaceBetweenBars;
|
||||||
smoothRange = 4;
|
smoothRange = 4;
|
||||||
angleRad = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
angleRot = new Vector2(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
||||||
textures = new Texture[barCount];
|
textures = new Texture[barCount];
|
||||||
bars = new Sprite[barCount];
|
bars = new Sprite[barCount];
|
||||||
|
|
||||||
@ -100,11 +100,16 @@ public class BasicVisualizer extends VisualizerCore {
|
|||||||
|
|
||||||
public void updatePositionInfo() {
|
public void updatePositionInfo() {
|
||||||
int barSpace;
|
int barSpace;
|
||||||
angleRad.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation));
|
||||||
|
|
||||||
|
barWidth = MathUtils.ceil((float) width/(float) barCount);
|
||||||
|
spaceBetweenBars = (barWidth-7);
|
||||||
|
barWidth -= spaceBetweenBars;
|
||||||
|
|
||||||
for (int i = 0; i < bars.length; i++) {
|
for (int i = 0; i < bars.length; i++) {
|
||||||
barSpace = i*(barWidth+spaceBetweenBars);
|
barSpace = i*(barWidth+spaceBetweenBars);
|
||||||
bars[i].setRotation(rotation);
|
bars[i].setRotation(rotation);
|
||||||
bars[i].setPosition(xPos + barSpace*angleRad.x, yPos + barSpace*angleRad.y);
|
bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,26 +58,26 @@ public class TitleBarMesh implements Disposable {
|
|||||||
private int idx = 0;
|
private int idx = 0;
|
||||||
|
|
||||||
public void draw() {
|
public void draw() {
|
||||||
if (idx >= verts.length) {
|
if (idx == verts.length) {
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
float c = color.toFloatBits();
|
float c = color.toFloatBits();
|
||||||
|
|
||||||
verts[idx++] = 0;
|
verts[idx++] = 0;
|
||||||
verts[idx++] = Gdx.graphics.getHeight()/2;
|
verts[idx++] = height;
|
||||||
verts[idx++] = c;
|
|
||||||
|
|
||||||
verts[idx++] = Gdx.graphics.getWidth();
|
|
||||||
verts[idx++] = Gdx.graphics.getHeight()-height;
|
|
||||||
verts[idx++] = c;
|
verts[idx++] = c;
|
||||||
|
|
||||||
verts[idx++] = Gdx.graphics.getWidth();
|
verts[idx++] = Gdx.graphics.getWidth();
|
||||||
verts[idx++] = Gdx.graphics.getHeight();
|
verts[idx++] = Gdx.graphics.getHeight();
|
||||||
verts[idx++] = c;
|
verts[idx++] = c;
|
||||||
|
|
||||||
|
verts[idx++] = Gdx.graphics.getWidth();
|
||||||
|
verts[idx++] = Gdx.graphics.getHeight() - height;
|
||||||
|
verts[idx++] = c;
|
||||||
|
|
||||||
|
verts[idx++] = 0;
|
||||||
verts[idx++] = 0;
|
verts[idx++] = 0;
|
||||||
verts[idx++] = Gdx.graphics.getHeight()/2 + height;
|
|
||||||
verts[idx++] = c;
|
verts[idx++] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ public class TitleBarMesh implements Disposable {
|
|||||||
|
|
||||||
shader.setUniformMatrix("u_projTrans", cam.combined);
|
shader.setUniformMatrix("u_projTrans", cam.combined);
|
||||||
|
|
||||||
mesh.render(shader, GL20.GL_TRIANGLES, 0, vertCount);
|
mesh.render(shader, GL20.GL_TRIANGLE_FAN, 0, vertCount);
|
||||||
|
|
||||||
shader.end();
|
shader.end();
|
||||||
|
|
||||||
|
@ -4,10 +4,9 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.assets.AssetManager;
|
import com.badlogic.gdx.assets.AssetManager;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||||
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Group;
|
import com.badlogic.gdx.scenes.scene2d.Group;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Image;
|
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
import zero1hd.rhythmbullet.graphics.meshes.TitleBarMesh;
|
import zero1hd.rhythmbullet.graphics.meshes.TitleBarMesh;
|
||||||
@ -15,22 +14,20 @@ import zero1hd.rhythmbullet.graphics.meshes.TitleBarMesh;
|
|||||||
public class TitleBarVisualizer extends Group implements Disposable {
|
public class TitleBarVisualizer extends Group implements Disposable {
|
||||||
private Visualizer hvisual;
|
private Visualizer hvisual;
|
||||||
private TitleBarMesh background;
|
private TitleBarMesh background;
|
||||||
private Image titleImage;
|
|
||||||
|
|
||||||
public TitleBarVisualizer(AssetManager assets, OrthographicCamera camera) {
|
public TitleBarVisualizer(AssetManager assets, OrthographicCamera camera) {
|
||||||
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
if (assets == null) throw new NullPointerException("TitleBarVisualizer requires assets manager... ITS NULL YOU FOOL");
|
||||||
|
setSize((float) Math.sqrt(Gdx.graphics.getWidth()*Gdx.graphics.getWidth() + Gdx.graphics.getHeight()*Gdx.graphics.getHeight()), Gdx.graphics.getHeight()*0.3f);
|
||||||
hvisual = new Visualizer();
|
hvisual = new Visualizer();
|
||||||
addActor(hvisual);
|
addActor(hvisual);
|
||||||
|
debug();
|
||||||
titleImage = new Image(assets.get("title.png", Texture.class));
|
|
||||||
addActor(titleImage);
|
|
||||||
|
|
||||||
background = new TitleBarMesh();
|
background = new TitleBarMesh();
|
||||||
background.setHeight((int) (Gdx.graphics.getHeight()*0.2));
|
background.setHeight((int) MathUtils.round(Gdx.graphics.getHeight()*0.3f));
|
||||||
|
setRotation((float) (MathUtils.radiansToDegrees*Math.atan2(Gdx.graphics.getHeight()-background.getHeight(), Gdx.graphics.getWidth())));
|
||||||
background.setCam(camera);
|
background.setCam(camera);
|
||||||
|
|
||||||
hvisual.setY(getHeight());
|
hvisual.setWidth(getWidth());
|
||||||
|
hvisual.setHeight(Gdx.graphics.getHeight()*0.3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ public class Visualizer extends Widget {
|
|||||||
private BasicVisualizer vis;
|
private BasicVisualizer vis;
|
||||||
private Vector2 coords;
|
private Vector2 coords;
|
||||||
private Vector2 size;
|
private Vector2 size;
|
||||||
|
private boolean updatePositioning = true;
|
||||||
public Visualizer() {
|
public Visualizer() {
|
||||||
vis = new BasicVisualizer();
|
vis = new BasicVisualizer();
|
||||||
coords = new Vector2();
|
coords = new Vector2();
|
||||||
@ -32,7 +32,9 @@ public class Visualizer extends Widget {
|
|||||||
vis.setxPos(getX());
|
vis.setxPos(getX());
|
||||||
vis.setyPos(getY());
|
vis.setyPos(getY());
|
||||||
vis.setRotation(getRotation());
|
vis.setRotation(getRotation());
|
||||||
|
if (updatePositioning) {
|
||||||
vis.updatePositionInfo();
|
vis.updatePositionInfo();
|
||||||
|
}
|
||||||
vis.calculate();
|
vis.calculate();
|
||||||
super.act(delta);
|
super.act(delta);
|
||||||
}
|
}
|
||||||
@ -53,4 +55,12 @@ public class Visualizer extends Widget {
|
|||||||
vis.setColor(r, g, b, a);
|
vis.setColor(r, g, b, a);
|
||||||
super.setColor(r, g, b, a);
|
super.setColor(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUpdatePositioning(boolean updatePositioning) {
|
||||||
|
this.updatePositioning = updatePositioning;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUpdatePositioning() {
|
||||||
|
return updatePositioning;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,8 @@ public class MainPage extends Page implements OnDifferentSongListener {
|
|||||||
titleBar = new TitleBarVisualizer(core.getAssetManager(), camera);
|
titleBar = new TitleBarVisualizer(core.getAssetManager(), camera);
|
||||||
addActor(titleBar);
|
addActor(titleBar);
|
||||||
|
|
||||||
|
titleBar.getHvisual().setMDP(sc.getCurrentSong());
|
||||||
|
|
||||||
sc.addOnDifferentSongListener(this);
|
sc.addOnDifferentSongListener(this);
|
||||||
|
|
||||||
versionLabel = new Label("Version: " + RhythmBullet.VERSION, core.getDefaultSkin(), "sub-font",
|
versionLabel = new Label("Version: " + RhythmBullet.VERSION, core.getDefaultSkin(), "sub-font",
|
||||||
@ -44,4 +46,9 @@ public class MainPage extends Page implements OnDifferentSongListener {
|
|||||||
public void onDifferentSong(MusicManager mdp) {
|
public void onDifferentSong(MusicManager mdp) {
|
||||||
titleBar.getHvisual().setMDP(mdp);
|
titleBar.getHvisual().setMDP(mdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user