Java Code Examples for com.jme3.export.InputCapsule#readInt()
The following examples show how to use
com.jme3.export.InputCapsule#readInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Image.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
public void read(JmeImporter e) throws IOException { InputCapsule capsule = e.getCapsule(this); format = capsule.readEnum("format", Format.class, Format.RGBA8); width = capsule.readInt("width", 0); height = capsule.readInt("height", 0); depth = capsule.readInt("depth", 0); mipMapSizes = capsule.readIntArray("mipMapSizes", null); multiSamples = capsule.readInt("multiSamples", 1); data = (ArrayList<ByteBuffer>) capsule.readByteBufferArrayList("data", null); colorSpace = capsule.readEnum("colorSpace", ColorSpace.class, null); if (mipMapSizes != null) { needGeneratedMips = false; mipsWereGenerated = true; } }
Example 2
Source File: TerrainPatch.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); size = ic.readInt("size", 16); totalSize = ic.readInt("totalSize", 16); quadrant = ic.readShort("quadrant", (short)0); stepScale = (Vector3f) ic.readSavable("stepScale", Vector3f.UNIT_XYZ); offset = (Vector2f) ic.readSavable("offset", Vector3f.UNIT_XYZ); offsetAmount = ic.readFloat("offsetAmount", 0); //lodCalculator = (LodCalculator) ic.readSavable("lodCalculator", new DistanceLodCalculator()); //lodCalculator.setTerrainPatch(this); //lodCalculatorFactory = (LodCalculatorFactory) ic.readSavable("lodCalculatorFactory", null); lodEntropy = ic.readFloatArray("lodEntropy", null); geomap = (LODGeomap) ic.readSavable("geomap", null); Mesh regen = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false); setMesh(regen); //TangentBinormalGenerator.generate(this); // note that this will be removed ensurePositiveVolumeBBox(); }
Example 3
Source File: TerrainPatch.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); size = ic.readInt("size", 16); totalSize = ic.readInt("totalSize", 16); quadrant = ic.readShort("quadrant", (short)0); stepScale = (Vector3f) ic.readSavable("stepScale", Vector3f.UNIT_XYZ); offset = (Vector2f) ic.readSavable("offset", Vector3f.UNIT_XYZ); offsetAmount = ic.readFloat("offsetAmount", 0); //lodCalculator = (LodCalculator) ic.readSavable("lodCalculator", new DistanceLodCalculator()); //lodCalculator.setTerrainPatch(this); //lodCalculatorFactory = (LodCalculatorFactory) ic.readSavable("lodCalculatorFactory", null); lodEntropy = ic.readFloatArray("lodEntropy", null); geomap = (LODGeomap) ic.readSavable("geomap", null); Mesh regen = geomap.createMesh(stepScale, new Vector2f(1,1), offset, offsetAmount, totalSize, false); setMesh(regen); //TangentBinormalGenerator.generate(this); // note that this will be removed ensurePositiveVolumeBBox(); }
Example 4
Source File: BlenderKey.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void read(JmeImporter e) throws IOException { super.read(e); InputCapsule ic = e.getCapsule(this); fps = ic.readInt("fps", DEFAULT_FPS); featuresToLoad = ic.readInt("features-to-load", FeaturesToLoad.ALL); loadUnlinkedAssets = ic.readBoolean("load-unlinked-assets", false); assetRootPath = ic.readString("asset-root-path", null); fixUpAxis = ic.readBoolean("fix-up-axis", true); generatedTexturePPU = ic.readInt("generated-texture-ppu", 128); usedWorld = ic.readString("used-world", null); defaultMaterial = (Material) ic.readSavable("default-material", null); faceCullMode = ic.readEnum("face-cull-mode", FaceCullMode.class, FaceCullMode.Off); layersToLoad = ic.readInt("layers-to=load", -1); mipmapGenerationMethod = ic.readEnum("mipmap-generation-method", MipmapGenerationMethod.class, MipmapGenerationMethod.GENERATE_WHEN_NEEDED); }
Example 5
Source File: MatParam.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
public void read(JmeImporter im) throws IOException { InputCapsule ic = im.getCapsule(this); type = ic.readEnum("varType", VarType.class, null); name = ic.readString("name", null); ffBinding = ic.readEnum("ff_binding", FixedFuncBinding.class, null); switch (getVarType()) { case Boolean: value = ic.readBoolean("value_bool", false); break; case Float: value = ic.readFloat("value_float", 0f); break; case Int: value = ic.readInt("value_int", 0); break; default: value = ic.readSavable("value_savable", null); break; } }
Example 6
Source File: MeshCollisionShape.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * De-serialize this shape, for example when loading from a J3O file. * * @param im importer (not null) * @throws IOException from importer */ @Override public void read(final JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); this.numVertices = capsule.readInt(MeshCollisionShape.NUM_VERTICES, 0); this.numTriangles = capsule.readInt(MeshCollisionShape.NUM_TRIANGLES, 0); this.vertexStride = capsule.readInt(MeshCollisionShape.VERTEX_STRIDE, 0); this.triangleIndexStride = capsule.readInt(MeshCollisionShape.TRIANGLE_INDEX_STRIDE, 0); this.triangleIndexBase = BufferUtils.createByteBuffer(capsule.readByteArray(MeshCollisionShape.TRIANGLE_INDEX_BASE, null)); this.vertexBase = BufferUtils.createByteBuffer(capsule.readByteArray(MeshCollisionShape.VERTEX_BASE, null)); byte[] nativeBvh = capsule.readByteArray(MeshCollisionShape.NATIVE_BVH, null); memoryOptimized=nativeBvh != null; createShape(nativeBvh); }
Example 7
Source File: TerrainGrid.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule c = im.getCapsule(this); name = c.readString("name", null); size = c.readInt("size", 0); patchSize = c.readInt("patchSize", 0); stepScale = (Vector3f) c.readSavable("stepScale", null); offset = (Vector2f) c.readSavable("offset", null); offsetAmount = c.readFloat("offsetAmount", 0); gridTileLoader = (TerrainGridTileLoader) c.readSavable("terrainQuadGrid", null); material = (Material) c.readSavable("material", null); initData(); if (gridTileLoader != null) { gridTileLoader.setPatchSize(this.patchSize); gridTileLoader.setQuadSize(this.quadSize); } }
Example 8
Source File: TextureKey.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); flipY = ic.readBoolean("flip_y", false); generateMips = ic.readBoolean("generate_mips", false); asCube = ic.readBoolean("as_cubemap", false); anisotropy = ic.readInt("anisotropy", 0); }
Example 9
Source File: ConeCollisionShape.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); radius = capsule.readFloat("radius", 0.5f); height = capsule.readFloat("height", 0.5f); axis = capsule.readInt("axis", PhysicsSpace.AXIS_Y); createShape(); }
Example 10
Source File: Texture.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
public void read(JmeImporter e) throws IOException { InputCapsule capsule = e.getCapsule(this); name = capsule.readString("name", null); key = (TextureKey) capsule.readSavable("key", null); // load texture from key, if available if (key != null) { // key is available, so try the texture from there. Texture loadedTex = e.getAssetManager().loadTexture(key); if (loadedTex == null) { Logger.getLogger(Texture.class.getName()).log(Level.SEVERE, "Could not load texture: {0}", key.toString()); } else { image = loadedTex.getImage(); } }else{ // no key is set on the texture. Attempt to load an embedded image image = (Image) capsule.readSavable("image", null); if (image == null){ // TODO: what to print out here? the texture has no key or data, there's no useful information .. // assume texture.name is set even though the key is null Logger.getLogger(Texture.class.getName()).log(Level.SEVERE, "Could not load embedded image: {0}", toString() ); } } anisotropicFilter = capsule.readInt("anisotropicFilter", 1); minificationFilter = capsule.readEnum("minificationFilter", MinFilter.class, MinFilter.BilinearNoMipMaps); magnificationFilter = capsule.readEnum("magnificationFilter", MagFilter.class, MagFilter.Bilinear); }
Example 11
Source File: PhysicsCollisionObject.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void read(JmeImporter e) throws IOException { InputCapsule capsule = e.getCapsule(this); collisionGroup = capsule.readInt("collisionGroup", 0x00000001); collisionGroupsMask = capsule.readInt("collisionGroupsMask", 0x00000001); debugShape = (Spatial) capsule.readSavable("debugShape", null); CollisionShape shape = (CollisionShape) capsule.readSavable("collisionShape", null); collisionShape = shape; }
Example 12
Source File: SpotLightShadowRenderer.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); zFarOverride = ic.readInt("zFarOverride", 0); light = (SpotLight) ic.readSavable("light", null); fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null); fadeLength = ic.readFloat("fadeLength", 0f); init((int) shadowMapSize); }
Example 13
Source File: GImpactCollisionShape.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); worldScale = (Vector3f) capsule.readSavable("worldScale", new Vector3f(1, 1, 1)); numVertices = capsule.readInt("numVertices", 0); numTriangles = capsule.readInt("numTriangles", 0); vertexStride = capsule.readInt("vertexStride", 0); triangleIndexStride = capsule.readInt("triangleIndexStride", 0); triangleIndexBase = ByteBuffer.wrap(capsule.readByteArray("triangleIndexBase", new byte[0])); vertexBase = ByteBuffer.wrap(capsule.readByteArray("vertexBase", new byte[0])); createShape(); }
Example 14
Source File: Dome.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter e) throws IOException { super.read(e); InputCapsule capsule = e.getCapsule(this); planes = capsule.readInt("planes", 0); radialSamples = capsule.readInt("radialSamples", 0); radius = capsule.readFloat("radius", 0); center = (Vector3f) capsule.readSavable("center", Vector3f.ZERO.clone()); }
Example 15
Source File: CapsuleCollisionShape.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * De-serialize this shape, for example when loading from a J3O file. * * @param im importer (not null) * @throws IOException from importer */ @Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); radius = capsule.readFloat("radius", 0.5f); height = capsule.readFloat("height", 0.5f); axis = capsule.readInt("axis", 1); createShape(); }
Example 16
Source File: HeightfieldCollisionShape.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule capsule = im.getCapsule(this); heightStickWidth = capsule.readInt("heightStickWidth", 0); heightStickLength = capsule.readInt("heightStickLength", 0); heightScale = capsule.readFloat("heightScale", 0); minHeight = capsule.readFloat("minHeight", 0); maxHeight = capsule.readFloat("maxHeight", 0); upAxis = capsule.readInt("upAxis", 1); heightfieldData = capsule.readFloatArray("heightfieldData", new float[0]); flipQuadEdges = capsule.readBoolean("flipQuadEdges", false); createShape(); }
Example 17
Source File: LodControl.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException{ super.read(im); InputCapsule ic = im.getCapsule(this); trisPerPixel = ic.readFloat("trisPerPixel", 1f); distTolerance = ic.readFloat("distTolerance", 1f); numLevels = ic.readInt("numLevels", 0); numTris = ic.readIntArray("numTris", null); }
Example 18
Source File: Cylinder.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void read(JmeImporter e) throws IOException { super.read(e); InputCapsule capsule = e.getCapsule(this); axisSamples = capsule.readInt("axisSamples", 0); radialSamples = capsule.readInt("radialSamples", 0); radius = capsule.readFloat("radius", 0); radius2 = capsule.readFloat("radius2", 0); height = capsule.readFloat("height", 0); closed = capsule.readBoolean("closed", false); inverted = capsule.readBoolean("inverted", false); }
Example 19
Source File: PMDNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void read(JmeImporter e) throws IOException { super.read(e); InputCapsule c = e.getCapsule(this); pmdModel = (PMDModel)SavableUtil.read(c, "pmdModel", null); skeleton = (Skeleton)c.readSavable("skeleton", null); skinMap = (Map<String, Skin>)c.readStringSavableMap("skinMap", new HashMap<String, Savable>()); // skinBoneWeightArray = c.readFloatArray("skinBoneWeightArray", new float[0]); // skinBoneArray = c.readIntArray("skinBoneArray", new int[0]); edgeSize = c.readFloat("edgeSize", 1.0f); int pmdGeometryArrayLength = c.readInt("pmdGeometryArrayLength", 0); pmdGeometryArray = new PMDGeometry[pmdGeometryArrayLength]; targets = new PMDMesh[pmdGeometryArrayLength]; int skinTargetsLength = c.readInt("skinTargetsLength", 0); skinTargets = new PMDSkinMesh[skinTargetsLength]; VertexBuffer skinvb = (VertexBuffer)c.readSavable("skinvb", null); VertexBuffer skinnb = (VertexBuffer)c.readSavable("skinnb", null); VertexBuffer skintb = (VertexBuffer)c.readSavable("skintb", null); VertexBuffer skinvb2 = skinvb.clone(); VertexBuffer skinnb2 = skinnb.clone(); int meshCount = 0; int skinMeshCount = 0; for(Spatial sp : getChildren()) { Spatial newSp = sp;//.clone(); // newPMDNode.attachChild(newSp); if (sp instanceof PMDGeometry) { Mesh mesh = ((Geometry)newSp).getMesh(); if (mesh instanceof PMDMesh) { PMDMesh pmdMesh = (PMDMesh)mesh; pmdMesh.setVbBackup(pmdMesh.getBuffer(Type.Position)); pmdMesh.setNbBackup(pmdMesh.getBuffer(Type.Normal)); pmdGeometryArray[meshCount] = (PMDGeometry)sp; targets[meshCount++] = (PMDMesh)mesh; } else if (mesh instanceof PMDSkinMesh) { // mesh.setMode(Mesh.Mode.Triangles); PMDSkinMesh skinMesh = (PMDSkinMesh)mesh; if (skinMeshCount != 0) { skinMesh.setBuffer(skinvb); skinMesh.setSkinvb2(skinvb2); skinMesh.setBuffer(skinnb); // skinMesh.setSkinnb2(skinnb2); skinMesh.setBuffer(skintb); } else { skinMesh.setBuffer(skinvb); skinMesh.setSkinvb2(skinvb2); skinMesh.setBuffer(skinnb); // skinMesh.setSkinnb2(skinnb2); skinMesh.setBuffer(skintb); } skinTargets[skinMeshCount++] = (PMDSkinMesh)mesh; } } } calcOffsetMatrices(); Savable[] sa = c.readSavableArray("skinArray", new Skin[0]); skinArray = new Skin[sa.length]; for(int i=0;i<sa.length;i++) { Skin skin = (Skin)sa[i]; skinArray[i] = skin; skin.pmdNode = this; l2: for(int i2=0;i2<pmdModel.getSkinCount();i2++){ if (pmdModel.getSkinData()[i2].getSkinName().equals(skin.getSkinName())) { // skin.skinData = pmdModel.getSkinData()[i2]; break l2; } } skin.setWeight(0f); skin.setUpdateNeeded(true); skinMap.put(skin.skinName, skin); } // skinPosArray = (javax.vecmath.Vector3f[])SavableUtil.read(c, "skinPosArray", null); // skinPosArrayOrig = new javax.vecmath.Vector3f[skinPosArray.length]; // for(int i=0;i<skinPosArray.length;i++) { // skinPosArrayOrig[i] = new javax.vecmath.Vector3f(skinPosArray[i]); // } // skinNormalArray = (javax.vecmath.Vector3f[])SavableUtil.read(c, "skinNormalArray", null); // skinNormalArrayOrig = new javax.vecmath.Vector3f[skinNormalArray.length]; // for(int i=0;i<skinNormalArray.length;i++) { // skinNormalArrayOrig[i] = new javax.vecmath.Vector3f(skinNormalArray[i]); // } // skinBoneArray = c.readIntArray("skinBoneArray", skinBoneArray); // skinBoneWeightArray = c.readFloatArray("skinBoneWeightArray", skinBoneWeightArray); }
Example 20
Source File: WaterFilter.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); speed = ic.readFloat("speed", 1f); lightDirection = (Vector3f) ic.readSavable("lightDirection", new Vector3f(0, -1, 0)); lightColor = (ColorRGBA) ic.readSavable("lightColor", ColorRGBA.White); waterHeight = ic.readFloat("waterHeight", 0.0f); waterColor = (ColorRGBA) ic.readSavable("waterColor", new ColorRGBA(0.0078f, 0.3176f, 0.5f, 1.0f)); deepWaterColor = (ColorRGBA) ic.readSavable("deepWaterColor", new ColorRGBA(0.0039f, 0.00196f, 0.145f, 1.0f)); colorExtinction = (Vector3f) ic.readSavable("colorExtinction", new Vector3f(5.0f, 20.0f, 30.0f)); waterTransparency = ic.readFloat("waterTransparency", 0.1f); maxAmplitude = ic.readFloat("maxAmplitude", 1.5f); shoreHardness = ic.readFloat("shoreHardness", 0.1f); useFoam = ic.readBoolean("useFoam", true); foamIntensity = ic.readFloat("foamIntensity", 0.5f); foamHardness = ic.readFloat("foamHardness", 1.0f); foamExistence = (Vector3f) ic.readSavable("foamExistence", new Vector3f(0.45f, 4.35f, 1.5f)); waveScale = ic.readFloat("waveScale", 0.005f); sunScale = ic.readFloat("sunScale", 3.0f); shininess = ic.readFloat("shininess", 0.7f); windDirection = (Vector2f) ic.readSavable("windDirection", new Vector2f(0.0f, -1.0f)); reflectionMapSize = ic.readInt("reflectionMapSize", 512); useRipples = ic.readBoolean("useRipples", true); normalScale = ic.readFloat("normalScale", 3.0f); useHQShoreline = ic.readBoolean("useHQShoreline", true); useSpecular = ic.readBoolean("useSpecular", true); useRefraction = ic.readBoolean("useRefraction", true); refractionStrength = ic.readFloat("refractionStrength", 0.0f); refractionConstant = ic.readFloat("refractionConstant", 0.5f); reflectionDisplace = ic.readFloat("reflectionDisplace", 30f); underWaterFogDistance = ic.readFloat("underWaterFogDistance", 120f); causticsIntensity = ic.readFloat("causticsIntensity", 0.5f); useCaustics = ic.readBoolean("useCaustics", true); final TextureKey causticsTextureKey = (TextureKey) ic.readSavable("causticsTexture", null); final TextureKey heightTextureKey = (TextureKey) ic.readSavable("heightTexture", null); final TextureKey normalTextureKey = (TextureKey) ic.readSavable("normalTexture", null); final TextureKey foamTextureKey = (TextureKey) ic.readSavable("foamTexture", null); needSaveReflectionScene = ic.readBoolean("needSaveReflectionScene", false); reflectionScene = (Spatial) ic.readSavable("reflectionScene", null); final AssetManager assetManager = im.getAssetManager(); if (causticsTextureKey != null) { setCausticsTexture((Texture2D) assetManager.loadTexture(causticsTextureKey)); } if (heightTextureKey != null) { setHeightTexture((Texture2D) assetManager.loadTexture(heightTextureKey)); } if (normalTextureKey != null) { setNormalTexture((Texture2D) assetManager.loadTexture(normalTextureKey)); } if (foamTextureKey != null) { setFoamTexture((Texture2D) assetManager.loadTexture(foamTextureKey)); } //positional attributes center = (Vector3f) ic.readSavable("center", null); radius = ic.readFloat("radius", 0f); int shapeType = ic.readInt("shapeType", AreaShape.Circular.ordinal()); this.shapeType = AreaShape.values()[shapeType]; }