one.empty3.feature20220726.MultiLinkList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of empty3-library-3d Show documentation
Show all versions of empty3-library-3d Show documentation
3D rendering engine. Plus modelling. Expected glsl textures 3d and 2d rendering3D primitives, and a lot of scenes' samples to test.+ Game Jogl reworked, Calculator (numbers and vectors). Java code parser implementation starts (<=1.2)
The newest version!
/*
*
* * Copyright (c) 2024. Manuel Daniel Dahmen
* *
* *
* * Copyright 2024 Manuel Daniel Dahmen
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/
package one.empty3.feature20220726;
import one.empty3.library.Point2D;
import java.util.Objects;
class P2P2 {
private Point2D p0;
private Point2D p1;
public P2P2(Point2D p0, Point2D p1) {
this.p0 = p0;
this.p1 = p1;
}
public Point2D getP0() {
return p0;
}
public void setP0(Point2D p0) {
this.p0 = p0;
}
public Point2D getP1() {
return p1;
}
public void setP1(Point2D p1) {
this.p1 = p1;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof P2P2)) return false;
P2P2 p2P2 = (P2P2) o;
return Objects.equals(getP0(), p2P2.getP0()) &&
Objects.equals(getP1(), p2P2.getP1());
}
@Override
public int hashCode() {
return Objects.hash(getP0(), getP1());
}
}
public class MultiLinkList {
static double[] xy = new double[300000000];
static int maxIndex = 0;
private int index;
public void reset() {
xy = new double[30000000];
maxIndex = -4;
}
public P2P2 get(int i) {
i = i * 4;
return new P2P2(new Point2D(xy[i], xy[i + 1]), new Point2D(xy[i + 2], xy[3]));
}
public int add(P2P2 p2P2) {
int i = maxIndex;
xy[i] = p2P2.getP0().getX();
xy[i + 1] = p2P2.getP0().getY();
xy[i + 2] = p2P2.getP1().getX();
xy[i + 3] = p2P2.getP1().getY();
maxIndex += 4;
return maxIndex / 4;
}
public int size() {
return maxIndex / 4;
}
/*
public void add(int i, MultiLinkList list, int listItemAt) {
add(new P2P2(get(i).getP0(), list.get(listItemAt).getP0()));
for(int j=listItemAt; j0; j--)
add(new P2P2(list.get(j).getP1(), list.get(j-1).getP0()));
add(new P2P2(list.get(0).getP1(), list.get(0).getP0()));
}
*/
}