/** * Convenience method for setting texture without managing TextureState. * * @param texture * the new texture to set on unit 0. */ public void setTexture(final Texture2D texture) { TextureState ts = (TextureState) getLocalRenderState(RenderState.StateType.Texture); if (ts == null) { ts = new TextureState(); ts.setEnabled(true); setRenderState(ts); } ts.setTexture(texture, 0); }
final TextureState newTState = new TextureState(); boolean foundEnabled = false; final Object states[] = stack.toArray(); for (int iIndex = states.length - 1; iIndex >= 0; iIndex--) { final TextureState pkTState = (TextureState) states[iIndex]; if (!pkTState.isEnabled()) { if (mode == TextureCombineMode.CombineClosestEnabled) { break; for (int i = 0, max = pkTState.getMaxTextureIndexUsed(); i <= max; i++) { final Texture pkText = pkTState.getTexture(i); if (newTState.getTexture(i) == null) { newTState.setTexture(pkText, i); for (int iIndex = 0, max = states.length; iIndex < max; iIndex++) { final TextureState pkTState = (TextureState) states[iIndex]; if (!pkTState.isEnabled()) { continue; final Texture pkText = pkTState.getTexture(i); if (newTState.getTexture(i) == null) { newTState.setTexture(pkText, i); break; newTState.setEnabled(foundEnabled); return newTState;
public static Image loadImage(final String type, final InputStream stream, final boolean flipped) { Image imageData = null; try { ImageLoader loader = loaders.get(type.toLowerCase()); if (loader == null) { loader = defaultLoader; } if (loader != null) { imageData = loader.load(stream, flipped); } else { logger.log(Level.WARNING, "Unable to read image of type: {0}", type); } if (imageData == null) { logger.warning("loadImage(String, InputStream, boolean): no imageData found. defaultTexture used."); imageData = TextureState.getDefaultTextureImage(); } } catch (final IOException e) { logger.log(Level.WARNING, "Could not load Image.", e); imageData = TextureState.getDefaultTextureImage(); } return imageData; }
public TextureState getTextureState() { if (map_Kd != null) { final TextureState tState = new TextureState(); tState.setTexture(map_Kd, 0); return tState; } return null; }
/** * Add a given texture to the cache * * @param texture * our texture */ public static void addToCache(final Texture texture) { if (TextureState.getDefaultTexture() == null || (texture != TextureState.getDefaultTexture() && texture.getImage() != TextureState.getDefaultTextureImage())) { _tCache.put(texture.getTextureKey(), texture); } }
@Override public void draw(final Renderer renderer, final UIComponent comp) { if (_texState.getNumberOfSetTextures() == 0 || _texState.getTexture().getTextureKey() == null || !_texState.getTexture().getTextureKey().equals(_image.getTexture().getTextureKey())) { _texState.setTexture(_image.getTexture()); ImageArcBackdrop._standin.setRenderState(_texState); ImageArcBackdrop._standin.updateWorldRenderStates(false); } drawBackdrop(ImageArcBackdrop._standin, renderer, comp, _image); }
public void actionPerformed(final ActionEvent e) { ((TextureState) getEdittedParticles().getLocalRenderState(StateType.Texture)).setTexture(null); _imageLabel.setIcon(null); } });
private void loadApplyTexture() throws MalformedURLException { final TextureState ts = (TextureState) getEdittedParticles().getLocalRenderState(StateType.Texture); // XXX: Needed? // TextureManager.clearCache(); ts.setTexture(TextureManager.load(new URLResourceSource(_newTexture.toURI().toURL()), Texture.MinificationFilter.BilinearNearestMipMap, TextureStoreFormat.GuessCompressedFormat, true)); ts.getTexture().setWrap(WrapMode.BorderClamp); ts.setEnabled(true); getEdittedParticles().setRenderState(ts); _newTexture = null; }
public OutlinePass(final boolean antialiased) { _wireframeState = new WireframeState(); _wireframeState.setFace(WireframeState.Face.FrontAndBack); _wireframeState.setLineWidth(DEFAULT_LINE_WIDTH); _wireframeState.setEnabled(true); _frontCull = new CullState(); _frontCull.setCullFace(Face.Front); _backCull = new CullState(); _backCull.setCullFace(Face.Back); _wireframeState.setAntialiased(antialiased); _noLights = new LightState(); _noLights.setGlobalAmbient(DEFAULT_OUTLINE_COLOR); _noLights.setEnabled(true); _noTexture = new TextureState(); _noTexture.setEnabled(true); _blendState = new BlendState(); _blendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); _blendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); _blendState.setBlendEnabled(true); _blendState.setEnabled(true); }
tState = new TextureState(); mesh.setRenderState(tState); tState.setTexture(texture, tState.getNumberOfSetTextures()); loadedTextures.put(textureReference, texture); if (info != null) {
context.setCurrentState(StateType.Texture, state); if (state.isEnabled()) { TextureRecord texRecord; final int glHint = LwjglTextureUtil.getPerspHint(state.getCorrectionType()); if (!record.isValid() || record.hint != glHint) { texture = state.getTexture(i);
if (mesh.getLocalRenderState(StateType.Texture) != null) { final TextureState textureState = (TextureState) mesh.getLocalRenderState(StateType.Texture); if (textureState.isEnabled() && textureState.getTexture() != null) { final TextureKey tKey = textureState.getTexture().getTextureKey(); final String tmpTextureName = tKey.getSource().getName(); final int lastIndexOfUnixPathSeparator = tmpTextureName.lastIndexOf('/');
public Texture getTexture(final Face face) { if (face == null) { throw new IllegalArgumentException("Face can not be null."); } return ((TextureState) _skyboxQuads[face.ordinal()].getLocalRenderState(RenderState.StateType.Texture)) .getTexture(); }
public void createAtlases(final AtlasTextureParameter atlasTextureParameter) { for (final ByteBuffer data : dataBuffers) { data.rewind(); final ImageDataFormat fmt = useAlpha ? ImageDataFormat.RGBA : ImageDataFormat.RGB; final Image image = new Image(fmt, PixelDataType.UnsignedByte, atlasWidth, atlasHeight, data, null); final TextureStoreFormat format = atlasTextureParameter.compress ? TextureStoreFormat.GuessCompressedFormat : TextureStoreFormat.GuessNoCompressedFormat; final Texture texture = TextureManager.loadFromImage(image, atlasTextureParameter.minificationFilter, format); texture.setMagnificationFilter(atlasTextureParameter.magnificationFilter); texture.setWrap(atlasTextureParameter.wrapMode); textures.add(texture); } for (final List<TextureParameter> paramList : cachedAtlases.values()) { for (final TextureParameter param : paramList) { final Texture texture = textures.get(param.getAtlasIndex()); final TextureState ts = (TextureState) param.getMesh().getLocalRenderState(StateType.Texture); ts.setTexture(texture, param.getTargetTextureIndex()); ts.setNeedsRefresh(true); } } TexturePacker.logger.info(nrTextures + " textures packed into " + packers.size() + " atlases."); }
public static RenderState createState(final StateType type) { switch (type) { case Blend: return new BlendState(); case ColorMask: return new ColorMaskState(); case Cull: return new CullState(); case Light: return new LightState(); case Offset: return new OffsetState(); case Stencil: return new StencilState(); case Texture: return new TextureState(); case Wireframe: return new WireframeState(); case ZBuffer: return new ZBufferState(); } throw new IllegalArgumentException("Unknown state type: " + type); } }
private static String calcMeshMaterial(final Mesh mesh) { final StringBuilder material = new StringBuilder(); // First, check if we are lit or not final LightState ls = mesh.getWorldRenderState(StateType.Light); final boolean lit = (ls != null && ls.isEnabled() && ls.count() > 0); material.append(lit ? "lit/" : "unlit/"); // Now check if we are textured final TextureState ts = mesh.getWorldRenderState(StateType.Texture); final boolean textured = (ts != null && ts.isEnabled() && ts.getNumberOfSetTextures() > 0); material.append(textured ? "textured/" : "untextured/"); // Check if we are using vertex colors final boolean vertColor = mesh.getMeshData().containsKey(MeshData.KEY_ColorCoords); material.append(vertColor ? "vertex_color" : "basic"); material.append(lit ? "_phong" : ""); // Finally, check if we are using fog final boolean foggy = mesh.hasProperty(FogParams.DefaultPropertyKey); material.append(foggy ? "_fog" : ""); material.append(".yaml"); System.out.println(material + " - " + mesh.getName()); return material.toString(); } }
for (int i = 0; i < TextureState.MAX_TEXTURES; i++) { exists = i < textureCoords.size() && textureCoords.get(i) != null && i <= ts.getMaxTextureIndexUsed();
for (int x = 0, maxIndex = Math.min(ts1.getMaxTextureIndexUsed(), ts2.getMaxTextureIndexUsed()); x <= maxIndex; x++) { final TextureKey key1 = ts1.getTextureKey(x); final TextureKey key2 = ts2.getTextureKey(x); if (ts1.getMaxTextureIndexUsed() != ts2.getMaxTextureIndexUsed()) { return ts2.getMaxTextureIndexUsed() - ts1.getMaxTextureIndexUsed();
private void resetFakeTexture() { // create a texture to cache the contents to _fakeTexture = new Texture2D(); _fakeTexture.setMagnificationFilter(MagnificationFilter.Bilinear); _fakeTexture.setMinificationFilter(_minificationFilter); _fakeTexture.setTextureStoreFormat(TextureStoreFormat.RGBA8); _fakeTexture.setWrap(WrapMode.EdgeClamp); UIContainer._textureRenderer.setupTexture(_fakeTexture); // Set a texturestate on the standin, using the fake texture final TextureState ts = new TextureState(); ts.setTexture(_fakeTexture); _standin.setRenderState(ts); }
if (_texState.getNumberOfSetTextures() == 0 || _texState.getTexture().getTextureKey() == null || !_texState.getTexture().getTextureKey().equals(_image.getTexture().getTextureKey())) { _texState.setTexture(_image.getTexture()); ImageDiskBackdrop._standin.setRenderState(_texState); ImageDiskBackdrop._standin.updateWorldRenderStates(false);