use of javax.vecmath.Point3f in project BuildCraft by BuildCraft.
the class PipeWireRenderer method getQuads.
private static MutableQuad[] getQuads(EnumWirePart part) {
MutableQuad[] quads = new MutableQuad[6];
Tuple3f center = new //
Point3f(//
0.5f + (part.x.getOffset() * 4.51f / 16f), //
0.5f + (part.y.getOffset() * 4.51f / 16f), //
0.5f + (part.z.getOffset() * 4.51f / 16f));
Tuple3f radius = new Point3f(1 / 32f, 1 / 32f, 1 / 32f);
UvFaceData uvs = new UvFaceData();
int off = func(part.x) * 4 + func(part.y) * 2 + func(part.z);
uvs.minU = off / 16f;
uvs.maxU = (off + 1) / 16f;
uvs.minV = 0;
uvs.maxV = 1 / 16f;
for (EnumFacing face : EnumFacing.VALUES) {
quads[face.ordinal()] = ModelUtil.createFace(face, center, radius, uvs);
}
return quads;
}
use of javax.vecmath.Point3f in project ffx by mjschnie.
the class GraphicsCanvas method postSwap.
/**
* {@inheritDoc}
*
* Image capture from the 3D Canvas is done in postSwap.
*/
@Override
public void postSwap() {
if (!imageCapture || mainPanel.getHierarchy().getActive() == null) {
return;
}
GraphicsContext3D ctx = getGraphicsContext3D();
Rectangle rect = getBounds();
BufferedImage img = new BufferedImage(rect.width, rect.height, BufferedImage.TYPE_INT_RGB);
ImageComponent2D comp = new ImageComponent2D(ImageComponent.FORMAT_RGB, img);
Raster ras = new Raster(new Point3f(-1.0f, -1.0f, -1.0f), Raster.RASTER_COLOR, 0, 0, rect.width, rect.height, comp, null);
ctx.readRaster(ras);
img = ras.getImage().getImage();
try {
if (!ImageIO.write(img, imageFormat.toString(), imageName)) {
logger.warning(String.format(" No image writer was found for %s.\n Please try a different image format.\n", imageFormat.toString()));
imageName.delete();
} else {
logger.info(String.format(" %s was captured.", imageName));
}
} catch (IOException e) {
logger.warning(e.getMessage());
}
imageCapture = false;
}
use of javax.vecmath.Point3f in project mmtf-spark by sbl-sdsc.
the class StructureToBioassembly method call.
@Override
public Iterator<Tuple2<String, StructureDataInterface>> call(Tuple2<String, StructureDataInterface> t) throws Exception {
StructureDataInterface structure = t._2;
// Map<Integer, Integer> atomMap = new HashMap<>();
List<Tuple2<String, StructureDataInterface>> resList = new ArrayList<>();
// for each of them, create one structure.
for (int i = 0; i < structure.getNumBioassemblies(); i++) {
// initiate the bioassembly structure.
AdapterToStructureData bioAssembly = new AdapterToStructureData();
// set the structureID.
String structureId = structure.getStructureId() + "-BioAssembly" + structure.getBioassemblyName(i);
int totAtoms = 0, totBonds = 0, totGroups = 0, totChains = 0, totModels = 0;
int numTrans = structure.getNumTransInBioassembly(i);
totModels = structure.getNumModels();
int[][] bioChainList = new int[numTrans][];
double[][] transMatrix = new double[numTrans][];
// calculate the total data we will use to initialize the structure.
for (int ii = 0; ii < numTrans; ii++) {
bioChainList[ii] = structure.getChainIndexListForTransform(i, ii);
transMatrix[ii] = structure.getMatrixForTransform(i, ii);
for (int j = 0; j < totModels; j++) {
totChains += bioChainList[ii].length;
// System.out.println(bioChainList[ii].length);
for (int k = 0, groupCounter = 0; k < structure.getChainsPerModel()[j]; k++) {
boolean adding = false;
for (int currChain : bioChainList[ii]) {
if (currChain == k)
adding = true;
}
if (adding) {
// System.out.println("adding groups");
totGroups += structure.getGroupsPerChain()[k];
}
for (int h = 0; h < structure.getGroupsPerChain()[k]; h++, groupCounter++) {
if (adding) {
int groupIndex = structure.getGroupTypeIndices()[groupCounter];
totAtoms += structure.getNumAtomsInGroup(groupIndex);
totBonds += structure.getGroupBondOrders(groupIndex).length;
}
}
}
}
}
// init
// System.out.println("Initializing the structure with\n"
// + " totModel = " + totModels + ", totChains = " + totChains + ", totGroups = " + totGroups + ", totAtoms = "
// + totAtoms + ", totBonds = " + totBonds + ", name : " + structureId);
bioAssembly.initStructure(totBonds, totAtoms, totGroups, totChains, totModels, structureId);
DecoderUtils.addXtalographicInfo(structure, bioAssembly);
DecoderUtils.addHeaderInfo(structure, bioAssembly);
/*
* Now we have bioChainList and transMatrix.
* bioChainList[i] is the ith trans' list of chains it has.
* transMatrix[i] is the matrix that is going to be applied on those chains.
*/
// initialize the indices.
int modelIndex = 0;
int chainIndex = 0;
int groupIndex = 0;
int atomIndex = 0;
int chainCounter = 0;
// loop through models
for (int ii = 0; ii < structure.getNumModels(); ii++) {
// precalculate indices
int numChainsPerModel = structure.getChainsPerModel()[modelIndex] * numTrans;
bioAssembly.setModelInfo(modelIndex, numChainsPerModel);
int[] chainToEntityIndex = getChainToEntityIndex(structure);
// loop through chains
for (int j = 0; j < structure.getChainsPerModel()[modelIndex]; j++) {
// loop through each trans
int currGroupIndex = groupIndex;
int currAtomIndex = atomIndex;
for (int k = 0; k < numTrans; k++) {
// get the currChainList that needs to be added
int[] currChainList = bioChainList[k];
double[] currMatrix = transMatrix[k];
boolean addThisChain = false;
for (int currChain : currChainList) {
if (currChain == j)
addThisChain = true;
}
groupIndex = currGroupIndex;
atomIndex = currAtomIndex;
float[] xCoords = structure.getxCoords();
float[] yCoords = structure.getyCoords();
float[] zCoords = structure.getzCoords();
float[] floatMatrix = Floats.toArray(Doubles.asList(currMatrix));
Matrix4f m = new Matrix4f(floatMatrix);
if (addThisChain) {
int entityToChainIndex = chainToEntityIndex[chainIndex];
// System.out.println("adding chain : " + chainIndex);
// TODO
// not sure
bioAssembly.setEntityInfo(new int[] { chainCounter }, structure.getEntitySequence(entityToChainIndex), structure.getEntityDescription(entityToChainIndex), structure.getEntityType(entityToChainIndex));
bioAssembly.setChainInfo(structure.getChainIds()[chainIndex], structure.getChainNames()[chainIndex], structure.getGroupsPerChain()[chainIndex]);
chainCounter++;
}
// loop through the groups in the chain
for (int jj = 0; jj < structure.getGroupsPerChain()[chainIndex]; jj++) {
int currgroup = structure.getGroupTypeIndices()[groupIndex];
if (addThisChain) {
bioAssembly.setGroupInfo(structure.getGroupName(currgroup), structure.getGroupIds()[groupIndex], structure.getInsCodes()[groupIndex], structure.getGroupChemCompType(currgroup), structure.getNumAtomsInGroup(currgroup), structure.getGroupBondOrders(currgroup).length, structure.getGroupSingleLetterCode(currgroup), structure.getGroupSequenceIndices()[groupIndex], structure.getSecStructList()[groupIndex]);
}
for (int kk = 0; kk < structure.getNumAtomsInGroup(currgroup); kk++) {
// System.out.println("currgroup : " + currgroup + " curratom : " + kk);
if (addThisChain) {
Point3f p1 = new Point3f(xCoords[atomIndex], yCoords[atomIndex], zCoords[atomIndex]);
m.transform(p1);
// System.out.println(kk + " " + currgroup);
bioAssembly.setAtomInfo(structure.getGroupAtomNames(currgroup)[kk], structure.getAtomIds()[atomIndex], structure.getAltLocIds()[atomIndex], p1.x, p1.y, p1.z, structure.getOccupancies()[atomIndex], structure.getbFactors()[atomIndex], structure.getGroupElementNames(currgroup)[kk], structure.getGroupAtomCharges(currgroup)[kk]);
}
// inc the atomIndex
atomIndex++;
}
if (addThisChain) {
for (int l = 0; l < structure.getGroupBondOrders(currgroup).length; l++) {
// System.out.println(structure.getGroupBondOrders(currgroup).length + " " + l);
int bondIndOne = structure.getGroupBondIndices(currgroup)[l * 2];
int bondIndTwo = structure.getGroupBondIndices(currgroup)[l * 2 + 1];
int bondOrder = structure.getGroupBondOrders(currgroup)[l];
bioAssembly.setGroupBond(bondIndOne, bondIndTwo, bondOrder);
}
}
// inc the groupIndex
groupIndex++;
}
if (addThisChain) {
// Add inter-group bond info
// for(int l = 0; l < structure.getInterGroupBondOrders().length; l++){
// int bondIndOne = structure.getInterGroupBondIndices()[l*2];
// int bondIndTwo = structure.getInterGroupBondIndices()[l*2+1];
// int bondOrder = structure.getInterGroupBondOrders()[l];
// Integer indexOne = atomMap.get(bondIndOne);
// if (indexOne != null) {
// Integer indexTwo = atomMap.get(bondIndTwo);
// if (indexTwo != null) {
// bioAssembly.setInterGroupBond(indexOne, indexTwo, bondOrder);
// }
// }
}
}
// inc the chainIndex
chainIndex++;
}
// inc the modelIndex
modelIndex++;
}
bioAssembly.finalizeStructure();
resList.add(new Tuple2<String, StructureDataInterface>(structureId, bioAssembly));
}
return resList.iterator();
}
use of javax.vecmath.Point3f in project mmtf-spark by sbl-sdsc.
the class ColumnarStructureX method getcAlphaCoordinatesF.
public Point3f[] getcAlphaCoordinatesF() {
List<Integer> indices = getCalphaAtomIndices();
float[] x = getxCoords();
float[] y = getyCoords();
float[] z = getzCoords();
Point3f[] calpha = new Point3f[indices.size()];
for (int i = 0; i < calpha.length; i++) {
int index = indices.get(i);
calpha[i] = new Point3f(x[index], y[index], z[index]);
}
return calpha;
}
use of javax.vecmath.Point3f in project Solar by Martacus.
the class PageRitualComponent method draw.
@Override
public void draw(int mouseX, int mouseY, FontRenderer fontRenderer) {
int yTranslate = (160 - this.width) / 2;
GlStateManager.translate(yTranslate, 30, 0);
Matrix4f mat = getMatrix(GL11.GL_MODELVIEW_MATRIX);
Point3f point = new Point3f();
mat.transform(point);
this.hovered = mouseX >= point.x && mouseY >= point.y && mouseX < point.x + this.width && mouseY < point.y + this.height;
Minecraft mc = Minecraft.getMinecraft();
GlStateManager.enableBlend();
GlStateManager.enableAlpha();
GlStateManager.disableLighting();
mc.fontRenderer.drawString(this.text, 0, 0, Color.BLACK.getRGB());
if (this.hovered) {
this.drawHorizontalLine(0, this.width, 9, Color.BLACK.getRGB());
}
GlStateManager.enableLighting();
GlStateManager.disableAlpha();
GlStateManager.disableBlend();
}
Aggregations