本文整理匯總了Java中javax.vecmath.Matrix4f.transform方法的典型用法代碼示例。如果您正苦於以下問題:Java Matrix4f.transform方法的具體用法?Java Matrix4f.transform怎麽用?Java Matrix4f.transform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.vecmath.Matrix4f
的用法示例。
在下文中一共展示了Matrix4f.transform方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: transform
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public static void transform(org.lwjgl.util.vector.Vector3f vec, Matrix4f m)
{
Vector4f tmp = new Vector4f(vec.x, vec.y, vec.z, 1f);
m.transform(tmp);
if(Math.abs(tmp.w - 1f) > 1e-5) tmp.scale(1f / tmp.w);
vec.set(tmp.x, tmp.y, tmp.z);
}
示例2: rotate
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public static EnumFacing rotate(Matrix4f matrix, EnumFacing facing)
{
Vec3i dir = facing.getDirectionVec();
Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 0);
matrix.transform(vec);
return EnumFacing.getFacingFromVector(vec.x, vec.y, vec.z);
}
示例3: transformPoints
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public static List<Point3f> transformPoints(List<Point3f> vPts, Matrix4f m4, Point3f center) {
List<Point3f> v = new ArrayList<Point3f>();
for (int i = 0; i < vPts.size(); i++) {
Point3f pt = new Point3f(vPts.get(i));
pt.sub(center);
m4.transform(pt, pt);
pt.add(center);
v.add(pt);
}
return v;
}
示例4: outputList
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
/**
* create the v or vn list
*
* @param pts
* @param nPts
* @param m
* @param prefix
* @param bsValid TODO
*/
private void outputList(Tuple3f[] pts, int nPts, Matrix4f m, String prefix, BitSet bsValid) {
for (int i = 0; i < nPts; i++) {
if (bsValid != null && !bsValid.get(i))
continue;
ptTemp.set(pts[i]);
if (m != null)
m.transform(ptTemp);
output(prefix + ptTemp.x + " " + ptTemp.y + " " + ptTemp.z + "\n");
}
}
示例5: renderSignPicture
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public void renderSignPicture(final float opacity, final float scale, @Nonnull final RenderOption opt) {
// Load Image
final Content content = this.entry.getContent();
final AttrReaders attr = this.entry.getMeta();
// Size
final SizeData size01 = content!=null ? content.image.getSize() : SizeData.DefaultSize;
final SizeData size = attr.sizes.getMovie().get().aspectSize(size01);
OpenGL.glPushMatrix();
final OffsetData offset = attr.offsets.getMovie().get();
final OffsetData centeroffset = attr.centeroffsets.getMovie().get();
final Quat4f rotate = attr.rotations.getMovie().get().getRotate();
final boolean see = CurrentMode.instance.isState(CurrentMode.State.SEE);
if (see) {
OpenGL.glColor4f(.5f, .5f, .5f, opacity*.5f);
OpenGL.glLineWidth(1f);
WRenderer.startShape();
final WVertex v1 = WRenderer.begin(GL_LINE_STRIP);
final Matrix4f m = new Matrix4f();
final Vector3f ov = new Vector3f(offset.x.offset, offset.y.offset, offset.z.offset);
final Vector3f cv = new Vector3f(centeroffset.x.offset, centeroffset.y.offset, centeroffset.z.offset);
final Point3f p = new Point3f();
v1.pos(p.x, p.y, p.z);
m.set(ov);
m.transform(p);
m.set(cv);
m.transform(p);
v1.pos(p.x, p.y, p.z);
p.set(0f, 0f, 0f);
cv.negate();
m.set(cv);
m.transform(p);
m.set(rotate);
m.transform(p);
cv.negate();
m.set(cv);
m.transform(p);
m.set(ov);
m.transform(p);
v1.pos(p.x, p.y, p.z);
v1.draw();
}
OpenGL.glTranslatef(offset.x.offset, offset.y.offset, offset.z.offset);
OpenGL.glTranslatef(centeroffset.x.offset, centeroffset.y.offset, centeroffset.z.offset);
RotationGL.glRotate(rotate);
OpenGL.glTranslatef(-centeroffset.x.offset, -centeroffset.y.offset, -centeroffset.z.offset);
OpenGL.glTranslatef(-size.getWidth()/2, size.getHeight()+(size.getHeight()>=0 ? 0 : -size.getHeight())-.5f, 0f);
OpenGL.glScalef(size.getWidth()<0 ? -1f : 1f, size.getHeight()<0 ? 1f : -1f, 1f);
OpenGL.glScalef(scale, scale, 1f);
drawScreen(0, 0, 0, opacity, size.getWidth()/scale, size.getHeight()/scale, opt);
OpenGL.glPopMatrix();
}
示例6: applyLight
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public void applyLight(final float x, final float y, final float z, final @Nonnull Quat4f signrotate) {
final AttrReaders attr = this.entry.getMeta();
int lightx = (int) attr.f.getMovie().get().data;
int lighty = (int) attr.g.getMovie().get().data;
if (lightx!=-1||lighty!=-1) {
if (lightx<0||lighty<0) {
int lsign = 0;
int lcenter = 0;
int lpicture = 0;
if (lightx!=-2&&lightx!=-3||lighty!=-2&&lighty!=-3)
lsign = Client.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_float(x), MathHelper.floor_float(y), MathHelper.floor_float(z), 0);
if (lightx==-2||lighty==-2||lightx==-3||lighty==-3) {
final OffsetData offset = attr.offsets.getMovie().get();
final OffsetData centeroffset = attr.centeroffsets.getMovie().get();
final Matrix4f m = new Matrix4f();
final Point3f p = new Point3f();
final Quat4f rotate = attr.rotations.getMovie().get().getRotate();
final Vector3f tv = new Vector3f(x, y, z);
final Vector3f ov = new Vector3f(offset.x.offset, offset.y.offset, offset.z.offset);
final Vector3f cv = new Vector3f(centeroffset.x.offset, centeroffset.y.offset, centeroffset.z.offset);
m.set(ov);
m.transform(p);
m.set(cv);
m.transform(p);
m.set(signrotate);
m.transform(p);
m.set(tv);
m.transform(p);
if (lightx==-2||lighty==-2)
lcenter = Client.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_float(p.x), MathHelper.floor_float(p.y), MathHelper.floor_float(p.z), 0);
if (lightx==-3||lighty==-3) {
final Point3f p2 = new Point3f();
m.set(cv);
m.transform(p2);
m.set(signrotate);
m.transform(p2);
m.set(rotate);
m.transform(p2);
p.sub(p2);
lpicture = Client.mc.theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_float(p.x), MathHelper.floor_float(p.y), MathHelper.floor_float(p.z), 0);
}
}
if (lightx<0)
if (lightx==-2)
lightx = lcenter%65536>>4;
else if (lightx==-3)
lightx = lpicture%65536>>4;
else
lightx = lsign%65536>>4;
if (lighty<0)
if (lighty==-2)
lighty = lcenter/65536>>4;
else if (lighty==-3)
lighty = lpicture/65536>>4;
else
lighty = lsign/65536>>4;
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightx<<4, lighty<<4);
}
}
示例7: applySymmetry
import javax.vecmath.Matrix4f; //導入方法依賴的package包/類
public void applySymmetry(List<Matrix4f> biomts, float[] notionalUnitCell, boolean applySymmetryToBonds, String filter) {
if (latticeCells != null && latticeCells[0] != 0) {
Logger.error("Cannot apply biomolecule when lattice cells are indicated");
return;
}
doNormalize = false;
symmetry = null;
getSymmetry();
setNotionalUnitCell(notionalUnitCell, null, unitCellOffset);
getSymmetry().setSpaceGroup(doNormalize);
addSpaceGroupOperation("x,y,z");
setAtomSetSpaceGroupName("biomolecule");
int len = biomts.size();
this.applySymmetryToBonds = applySymmetryToBonds;
bondCount0 = bondCount;
boolean addBonds = (bondCount0 > bondIndex0 && applySymmetryToBonds);
int[] atomMap = (addBonds ? new int[atomCount] : null);
int iAtomFirst = getLastAtomSetAtomIndex();
int atomMax = atomCount;
if (filter.indexOf("#<") >= 0) {
len = Math.min(len, Parser.parseInt(filter.substring(filter.indexOf("#<") + 2)) - 1);
filter = TextFormat.simpleReplace(filter, "#<", "_<");
}
for (int iAtom = iAtomFirst; iAtom < atomMax; iAtom++)
atoms[iAtom].bsSymmetry = BitSetUtil.setBit(0);
for (int i = 1; i < len; i++) {
if (filter.indexOf("!#") >= 0) {
if (filter.indexOf("!#" + (i + 1) + ";") >= 0)
continue;
} else if (filter.indexOf("#") >= 0
&& filter.indexOf("#" + (i + 1) + ";") < 0) {
continue;
}
Matrix4f mat = biomts.get(i);
//Vector3f trans = new Vector3f();
for (int iAtom = iAtomFirst; iAtom < atomMax; iAtom++) {
try {
int atomSite = atoms[iAtom].atomSite;
Atom atom1;
if (addBonds)
atomMap[atomSite] = atomCount;
atom1 = newCloneAtom(atoms[iAtom]);
atom1.atomSite = atomSite;
mat.transform(atom1);
atom1.bsSymmetry = BitSetUtil.setBit(i);
if (addBonds) {
// Clone bonds
for (int bondNum = bondIndex0; bondNum < bondCount0; bondNum++) {
Bond bond = bonds[bondNum];
int iAtom1 = atomMap[atoms[bond.atomIndex1].atomSite];
int iAtom2 = atomMap[atoms[bond.atomIndex2].atomSite];
if (iAtom1 >= atomMax || iAtom2 >= atomMax)
addNewBond(iAtom1, iAtom2, bond.order);
}
}
} catch (Exception e) {
errorMessage = "appendAtomCollection error: " + e;
}
}
mat.m03 /= notionalUnitCell[0];
mat.m13 /= notionalUnitCell[1];
mat.m23 /= notionalUnitCell[2];
if (symmetry != null && i > 0)
symmetry.addSpaceGroupOperation(mat);
//System.out.println("biomt " + i + " " + atomCount);
}
int noSymmetryCount = atomMax - iAtomFirst;
setAtomSetAuxiliaryInfo("presymmetryAtomIndex", Integer.valueOf(iAtomFirst));
setAtomSetAuxiliaryInfo("presymmetryAtomCount", Integer.valueOf(noSymmetryCount));
setAtomSetAuxiliaryInfo("biosymmetryCount", Integer.valueOf(len));
if (symmetry != null) {
symmetry.setFinalOperations(atoms, iAtomFirst, noSymmetryCount, doNormalize);
setSymmetryOps();
}
symmetry = null;
notionalUnitCell = new float[6];
coordinatesAreFractional = false;
setAtomSetAuxiliaryInfo("hasSymmetry", Boolean.TRUE);
setGlobalBoolean(GLOBAL_SYMMETRY);
//TODO: need to clone bonds
}