Example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D getX

List of usage examples for org.apache.commons.math3.geometry.euclidean.threed Vector3D getX

Introduction

In this page you can find the example usage for org.apache.commons.math3.geometry.euclidean.threed Vector3D getX.

Prototype

public double getX() 

Source Link

Document

Get the abscissa of the vector.

Usage

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public boolean removeBlock(Vector3D position) {
    return world().setBlockToAir((int) position.getX(), (int) position.getY(), (int) position.getZ());
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public Entity addEntity(Vector3D position, Item item) {
    EntityItem entityItem = new EntityItem(world(), position.getX(), position.getY(), position.getZ(),
            Game.natives().toNative(item));
    world().spawnEntityInWorld(entityItem);
    return new BWEntity(entityItem);
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld.java

@Override
public void playSoundAtPosition(Vector3D position, Sound sound) {
    world().playSound(position.getX(), position.getY(), position.getZ(), sound.getID(), sound.pitch,
            sound.volume, false);/*  w ww.java2  s.  c o m*/
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.BWRigidBody.java

void updateTranslation(double deltaTime) {
    //Integrate velocity to displacement
    Vector3D displacement = velocity().scalarMultiply(deltaTime);
    mcEntity().moveEntity(displacement.getX(), displacement.getY(), displacement.getZ());

    //Integrate netForce to velocity
    setVelocity(velocity().add(netForce.scalarMultiply(1 / mass()).scalarMultiply(deltaTime)));

    //Clear net force
    netForce = Vector3D.ZERO;//from w ww  .j a  va  2 s. co m

    //Apply drag
    addForce(velocity().negate().scalarMultiply(drag()));
    if (!mcEntity().onGround) {
        //Apply gravity
        addForce(gravity().scalarMultiply(mass()));
    }
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.BWRigidBody.java

@Override
public void setVelocity(Vector3D velocity) {
    mcEntity().motionX = velocity.getX();
    mcEntity().motionY = velocity.getY();
    mcEntity().motionZ = velocity.getZ();
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.entity.forward.MCEntityTransform.java

@Override
public void setPosition(Vector3D position) {
    if (wrapper instanceof EntityPlayerMP) {
        ((EntityPlayerMP) wrapper).playerNetServerHandler.setPlayerLocation(position.getX(), position.getY(),
                position.getZ(), wrapper.rotationYaw, wrapper.rotationPitch);
    } else {/*w  ww.j a  va  2s . c  om*/
        wrapper.setPosition(position.getX(), position.getY(), position.getZ());
    }
}

From source file:nova.core.wrapper.mc.forge.v17.wrapper.render.BWModel.java

public void render(Optional<IBlockAccess> access, Optional<RenderManager> entityRenderManager) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setColorRGBA_F(1, 1, 1, 1);

    /**//from   w ww.  j av a2  s.c  o  m
     * Convert textures and UV into Minecraft equivalent.
     */
    flatten().forEach(model -> {
        if (model instanceof MeshModel) {
            MeshModel meshModel = (MeshModel) model;
            meshModel.faces.forEach(face -> {
                // Brightness is defined as: skyLight << 20 | blockLight << 4
                if (face.getBrightness() >= 0) {
                    tessellator.setBrightness((int) (face.getBrightness() * (15 << 20 | 11 << 4)));
                } else if (access.isPresent()) {
                    // Determine nearest adjacent block.
                    Vector3D nearestPos = Vector3DUtil
                            .floor(face.getCenter().add(face.normal.scalarMultiply(0.05)));
                    Block block = access.get().getBlock((int) nearestPos.getX(), (int) nearestPos.getY(),
                            (int) nearestPos.getZ());
                    int brightness = block.getMixedBrightnessForBlock(access.get(), (int) nearestPos.getX(),
                            (int) nearestPos.getY(), (int) nearestPos.getZ());

                    // TODO: Add Ambient Occlusion
                    /*
                    int aoBrightnessXYNN = block.getMixedBrightnessForBlock(blockAccess, translation.getX() - 1, translation.getY(), translation.zi());
                    int aoBrightnessYZNN = block.getMixedBrightnessForBlock(blockAccess, translation.getX(), translation.getY(), translation.zi() - 1);
                    int aoBrightnessYZNP = block.getMixedBrightnessForBlock(blockAccess, translation.getX(), translation.getY(), translation.zi() + 1);
                    int aoBrightnessXYPN = block.getMixedBrightnessForBlock(blockAccess, translation.getX() + 1, translation.getY(), translation.zi());
                            
                    int brightnessTopLeft = getAoBrightness(aoBrightnessXYZNNP, this.aoBrightnessXYNN, this.aoBrightnessYZNP, i1);
                    int brightnessTopRight = getAoBrightness(aoBrightnessYZNP, this.aoBrightnessXYZPNP, this.aoBrightnessXYPN, i1);
                    int brightnessBottomRight = getAoBrightness(this.aoBrightnessYZNN, this.aoBrightnessXYPN, this.aoBrightnessXYZPNN, i1);
                    int brightnessBottomLeft = getAoBrightness(this.aoBrightnessXYNN, this.aoBrightnessXYZNNN, this.aoBrightnessYZNN, i1);
                    */

                    tessellator.setBrightness(brightness);

                } else {
                    // Determine nearest adjacent block.
                    tessellator.setBrightness(15 << 20 | 11 << 4);
                }

                tessellator.setNormal((int) face.normal.getX(), (int) face.normal.getY(),
                        (int) face.normal.getZ());

                if (face.texture.isPresent()) {
                    if (entityRenderManager.isPresent() && face.texture.get() instanceof EntityTexture) {
                        //We're not working on an atlas, so just do... this.
                        Texture t = face.texture.get();
                        entityRenderManager.get().renderEngine.bindTexture(
                                new ResourceLocation(t.domain, "textures/entities/" + t.resource + ".png"));
                        face.vertices.forEach(v -> {
                            tessellator.setColorRGBA(v.color.red(), v.color.green(), v.color.blue(),
                                    v.color.alpha());
                            tessellator.addVertexWithUV(v.vec.getX(), v.vec.getY(), v.vec.getZ(), v.uv.getX(),
                                    v.uv.getY());
                        });
                    } else {
                        Texture texture = face.texture.get();
                        IIcon icon = RenderUtility.instance.getIcon(texture);
                        face.vertices.forEach(v -> {
                            tessellator.setColorRGBA(v.color.red(), v.color.green(), v.color.blue(),
                                    v.color.alpha());
                            if (icon != null) {
                                tessellator.addVertexWithUV(v.vec.getX(), v.vec.getY(), v.vec.getZ(),
                                        icon.getInterpolatedU(16 * v.uv.getX()),
                                        icon.getInterpolatedV(16 * v.uv.getY()));
                            } else {
                                tessellator.addVertexWithUV(v.vec.getX(), v.vec.getY(), v.vec.getZ(),
                                        v.uv.getX(), v.uv.getY());
                            }
                        });
                    }
                } else {
                    face.vertices.forEach(v -> {
                        tessellator.setColorRGBA(v.color.red(), v.color.green(), v.color.blue(),
                                v.color.alpha());
                        tessellator.addVertex(v.vec.getX(), v.vec.getY(), v.vec.getZ());
                    });
                }
            });
        } else if (model instanceof CustomModel) {
            CustomModel customModel = (CustomModel) model;
            customModel.render.accept(customModel);
        }
    });
}

From source file:nova.core.wrapper.mc.forge.v18.launcher.ClientProxy.java

@Override
public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
    //Backward entity particle unwrapper
    if (entity instanceof BWEntityFX) {
        EntityFX entityFX = ((BWEntityFX) entity).createEntityFX(world);
        Vector3D position = entity.position();
        entityFX.posX = position.getX();
        entityFX.posY = position.getY();
        entityFX.posZ = position.getZ();
        FMLClientHandler.instance().getClient().effectRenderer.addEffect(entityFX);
        return Game.natives().toNova(entityFX);
    } else {//from   w  w w  . ja  v  a 2s  .  com
        FWEntityFX bwEntityFX = new FWEntityFX(world, entity);
        FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
        return bwEntityFX.wrapped;
    }
}

From source file:nova.core.wrapper.mc.forge.v18.wrapper.block.forward.FWBlock.java

public Block getBlockInstance(IBlockAccess access, Vector3D position) {
    /**/*from www.  ja  v a 2s . co  m*/
     * If this block has a TileEntity, forward the method into the Stateful
     * block. Otherwise, create a new instance of the block and forward the
     * methods over.
     */
    if (hasTileEntity(null)) {
        FWTile tileWrapper = (FWTile) access.getTileEntity(
                new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()));
        if (tileWrapper != null && tileWrapper.getBlock() != null) {
            return tileWrapper.getBlock();
        }

        try {
            throw new RuntimeException("Error: Block in TileWrapper is null for " + dummy);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return getBlockInstance((nova.core.world.World) Game.natives().toNova(access), position);

}

From source file:nova.core.wrapper.mc.forge.v18.wrapper.block.world.BWWorld.java

@Override
public void markStaticRender(Vector3D position) {
    world().markBlockForUpdate(/*from w w w  .  ja  va2s  .c o  m*/
            new BlockPos((int) position.getX(), (int) position.getY(), (int) position.getZ()));
}