i get a code to long error when i try to create a custom mesh (when compiling)
is there a way to fix this?
Yes, create the mesh correctly.
the mesh was generated by a script i found. it is started by blender and writes a java class to create the mesh. i can’t remember exactly where i found it (somewhere on the internet), but i have tried it with a single cube and it worked. but somehow, when i try to export a sphere and a cylinder, i got the ‘code to long’ error.
The strange bit is that a can find next to nothing about this error, while java is used frequently. The only thing about this error is that it’s very rare, and mostly happens with code generated with a script.
The cylinder and the sphere both use the same material as the cube, and exporting only the cube works, two cubes also work, but a cylinder and a sphere not.
the java code itself looks like it’s exported correctly, and the error occurs while compiling the java class
I think there is a 65535 character limit in one method, the code you generate must exceed this limit.
so then i can only use this script for really simple meshes?
Or make it split the code into several methods when a method length is more than 64k characters…
But honestly, it does not look as a very efficient way of importing models.
Why aren’t you using ogre?
I can’t get ogre to export the texture coordinates right, so i was searching the internet for an other solution, and i found this. this script exports the texture coordinates right, but now, after seeing these posts, it looks like something that can only be used for very simple meshes.
Edit: and about the ‘make it split the code in different methods’ method to make it work: The script is written in python, and I’ve newer used python. Isn’t this very hard to do? And if this isn’t very hard, do you know a good python tutorial (for blender export scripts)?
Honestly I never used python, and I don’t know any tutos about it…but I’m pretty sure google does
I’m surprised about your UV issue with Ogre exporter, I never had such an issue.
Could you expose the problem? or maybe link to a previous post you made about it?
I really think you should look more into this issue and stick with ogre
Perhaps you need to flip your textures?
the models just don’t have any texture coordinates when i export it. the textures of my exported models are then very strange, and sometimes don’t even show up at all. creating tangents with the scene composer doesn’t work either and then something appears in the console saying: “can’t create tangents for meshes without texture coordinates”.
also: models with UV textures are just black.
i have found a good tutorial for export scripts in blender, and it’s not very difficoult. I started to write my own script with python, and this is the result:
(only the model in the middle of the screen)
look at the model: aren’t the texture coords very good

still have to make the script more user friendly: You can now only export meshes when you convert the quads to triangles and you have to let blender calculate the texco’s. I’ll try to let the script do that ass well.
Could a core membr of JME also please tell me how the binnary .j3o files are coded? then i might be able to create a .j3o exporter for blender.
as i like open source, here’s the source code:[patch]#BPY
coding: utf-8
author=“Ben G.”
date ="$25-feb-2011 19:32:14$"
“”"
Name: ‘JME scene (.java)…’
Blender: 244
Group: ‘Export’
Tooltip: ‘exports to a java file containing the code to create a JME geometry’
“”"
import Blender
import bpy
def write(fileName):
if not fileName.lower().endswith(".java"):
fileName += “.java”
out = open(fileName,“w”)
sce = bpy.data.scenes.active
meshCount = 0
out.write(“import com.jme3.scene.Mesh;n”)
out.write(“import com.jme3.scene.Node;n”)
out.write(“import com.jme3.math.Vector2f;n”)
out.write(“import com.jme3.math.Vector3f;n”)
out.write(“import com.jme3.material.Material;n”)
out.write(“import com.jme3.math.ColorRGBA;n”)
out.write(“import com.jme3.util.BufferUtils;n”)
out.write(“import com.jme3.scene.VertexBuffer.Type;nn”)
filelenght = len(fileName)-5
out.write(“public class " + fileName[:filelenght] + “{nn”)
out.write(“Node n = new Node(“Scene”);nn”)
out.write(” public Node exportedNode(){n")
for ob in sce.objects:
if ob.type == ‘Mesh’:
vertIndex = 0
mesh = ob.getData(mesh=1)
mesh.quadToTriangle()
out.write(" Mesh m" + str(meshCount) + " = new Mesh();nn")
out.write(" Vector3f[] vertices" + str(meshCount) + " = new Vector3f[" + str(mesh.verts.len()) + “];n”)
for vert in mesh.verts:
out.write(" vertices" + str(meshCount) + “[” + str(vertIndex) + “] = new Vector3f(” + str(vert.co.x) + “f,” + str(vert.co.z) + “f,” + str(vert.co.y) + “f);n”)
vertIndex += 1
out.write(“n”)
out.write(" Vector2f[] texCoord" + str(meshCount) + " = new Vector2f[" + str(mesh.faces.len()) + “];n”)
vertIndex = 0
for vert in mesh.verts:
out.write(" texCoord" + str(meshCount) +"[" + str(vertIndex) + “] = new Vector2f(” + str(vert.uvco.x) + “f,” + str(vert.uvco.y) + “f);n”)
vertIndex += 1
out.write(“n”)
out.write(" int indexes" + str(meshCount) + " = {")
vertIndex = 0
for face in mesh.faces:
for vert in face.v:
out.write(str(vert.index))
vertIndex += 1
if not vertIndex == mesh.faces.len()*3:
out.write(",")
out.write("};nn")
out.write(" m" + str(meshCount) + “.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices” + str(meshCount) + “));n”)
out.write(" m" + str(meshCount) + “.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord” + str(meshCount) + “));n”)
out.write(" m" + str(meshCount) + “.setBuffer(Type.Index, 1, BufferUtils.createIntBuffer(indexes” + str(meshCount) + “));nn”)
out.write(" Geometry geom" + str(meshCount) + " = new Geometry(“OurMesh” + str(meshCount) + “”, m" + str(meshCount) + “);n”)
out.write(" n.attachChild(geom" + str(meshCount) + “);n”)
meshCount += 1
out.write(" }n")
out.write("}")
out.close
Blender.Window.FileSelector(write,“Export .java”)[/patch]