/** * IModelState wrapper for a Clip, sampled at specified time. */ public static Pair<IModelState, Iterable<Event>> apply(final IClip clip, final float lastPollTime, final float time) { return Pair.<IModelState, Iterable<Event>>of(new IModelState() { public Optional<TRSRTransformation> apply(Optional<? extends IModelPart> part) { if(!part.isPresent() || !(part.get() instanceof IJoint)) { return Optional.absent(); } IJoint joint = (IJoint)part.get(); // TODO: Cache clip application? TRSRTransformation jointTransform = clip.apply(joint).apply(time).compose(joint.getInvBindPose()); Optional<? extends IJoint> parent = joint.getParent(); while(parent.isPresent()) { TRSRTransformation parentTransform = clip.apply(parent.get()).apply(time); jointTransform = parentTransform.compose(jointTransform); parent = parent.get().getParent(); } return Optional.of(jointTransform); } }, clip.pastEvents(lastPollTime, time)); }
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer) { if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) { return; } if(blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos pos = te.getPos(); IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos); IBlockState state = world.getBlockState(pos); if(state.getPropertyNames().contains(Properties.StaticProperty)) { state = state.withProperty(Properties.StaticProperty, false); } if(state instanceof IExtendedBlockState) { IExtendedBlockState exState = (IExtendedBlockState)state; if(exState.getUnlistedNames().contains(Properties.AnimationProperty)) { float time = Animation.getWorldTime(getWorld(), partialTick); Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time); handleEvents(te, time, pair.getRight()); // TODO: caching? IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean()); exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft()); renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ()); blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false); } } }
public Iterable<Event> pastEvents(float lastPollTime, float time) { float clipLastPollTime = input.apply(lastPollTime); float clipTime = input.apply(time); return Iterables.mergeSorted(ImmutableSet.of( from.pastEvents(clipLastPollTime, clipTime), to.pastEvents(clipLastPollTime, clipTime) ), Ordering.<Event>natural()); }
public Iterable<Event> pastEvents(float lastPollTime, float time) { if(parameter.apply(lastPollTime) < 0 && parameter.apply(time) >= 0) { return Iterables.mergeSorted(ImmutableSet.of( clip.pastEvents(lastPollTime, time), ImmutableSet.of(new Event(event, 0)) ), Ordering.<Event>natural()); } return clip.pastEvents(lastPollTime, time); }
@Override public void renderTileEntityFast(TileEntityPaintMixer te, double x, double y, double z, float partialTick, int breakStage, float alpha, BufferBuilder renderer) { if (te.hasPaint()) { if (!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) { return; } if (blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); final BlockPos pos = te.getPos(); final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos); IBlockState state = world.getBlockState(pos); if (state.getPropertyKeys().contains(Properties.StaticProperty)) { state = state.withProperty(Properties.StaticProperty, false); } if (state instanceof IExtendedBlockState) { state = state.getBlock().getExtendedState(state, world, pos); // difference between this and AnimationTESR IExtendedBlockState exState = (IExtendedBlockState)state; if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) { float time = Animation.getWorldTime(getWorld(), partialTick); Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time); IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean()); exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft()); renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ()); blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false); } } } }
public Iterable<Event> pastEvents(float lastPollTime, float time) { return ImmutableSet.<Event>of(); }
public Iterable<Event> pastEvents(float lastPollTime, float time) { return childClip.pastEvents(lastPollTime, time); }
public Iterable<Event> pastEvents(float lastPollTime, float time) { return childClip.pastEvents(this.time.apply(lastPollTime), this.time.apply(time)); }
public Iterable<Event> pastEvents(float lastPollTime, float time) { resolve(); return clip.pastEvents(lastPollTime, time); }
private void renderProjector(TileEntityProjector projector, float partialTickTime, double x, double y, double z) { if (bakedSpinnerModel == null) return; if (!projector.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) return; if (blockModelRenderer == null) { blockModelRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer(); } final BlockPos pos = projector.getPos(); final IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(projector.getWorld(), pos); final IBlockState state = world.getBlockState(pos); if (state instanceof IExtendedBlockState) { IExtendedBlockState exState = (IExtendedBlockState)state; if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend(); GlStateManager.disableCull(); if (Minecraft.isAmbientOcclusionEnabled()) { GlStateManager.shadeModel(GL11.GL_SMOOTH); } else { GlStateManager.shadeModel(GL11.GL_FLAT); } vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); float time = Animation.getWorldTime(getWorld(), partialTickTime); final Pair<IModelState, Iterable<Event>> pair = projector.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time); exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft()); vb.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ()); blockModelRenderer.renderModel(world, bakedSpinnerModel, exState, pos, vb, false); vb.setTranslation(0, 0, 0); tessellator.draw(); RenderHelper.enableStandardItemLighting(); } } }
@Override public Iterable<Event> pastEvents(float lastPollTime, float time) { throw new AssertionError("unsupported operation"); }
/** * Sample the state and events at the current time. * Event iterable will contain all events that happened from the last invocation of this method, from most to least recent. * Event offset is relative to the previous event, and for the first event it's relative to the current time. */ Pair<IModelState, Iterable<Event>> apply(float time);
public void handleEvents(T instance, float time, Iterable<Event> pastEvents) {}
public void handleEvents(T te, float time, Iterable<Event> pastEvents) {}
Iterable<Event> pastEvents(float lastPollTime, float time);