Strange Error

So I just got started on jme3, very nice program… Well I recently tried to write my own program, and i wrote a code with no errors, should have worked, and so i ran it. It would go to the preference screen, and I would click okay, then i would get this error:

ERROR: 0:125: '=' : cannot convert from 'const float' to '4-component vector of float'
at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderSourceData(LwjglRenderer.java:878)
at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderData(LwjglRenderer.java:913)
at com.jme3.renderer.lwjgl.LwjglRenderer.setShader(LwjglRenderer.java:993)
at com.jme3.material.Material.renderMultipassLighting(Material.java:670)
at com.jme3.material.Material.render(Material.java:853)
at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:434)
at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:132)
at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:183)
at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:575)
at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:555)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:721)
at com.jme3.renderer.RenderManager.render(RenderManager.java:742)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:249)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:158)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
at java.lang.Thread.run(Thread.java:662)

Heres my code. If i take out the part that renders the terrain, it runs fine, but otherwise it crashes.
[java]package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;

/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication {

public static void main(String[] args) {
Main app = new Main();
app.start();
}

@Override
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry("Box", b);
geom.updateModelBound();

Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
mat.setColor("m_Color", ColorRGBA.Red);
geom.setMaterial(mat);

Spatial scene = assetManager.loadModel("Scenes/main.j3o");
rootNode.attachChild(scene);


rootNode.attachChild(geom);
}

@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}

@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]

So if i change it to:
[java]package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;

/**
* test
* @author normenhansen
*/
public class Main extends SimpleApplication {

public static void main(String[] args) {
Main app = new Main();
app.start();
}

@Override
public void simpleInitApp() {
Box b = new Box(Vector3f.ZERO, 1, 1, 1);
Geometry geom = new Geometry("Box", b);
geom.updateModelBound();

Material mat = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
mat.setColor("m_Color", ColorRGBA.Red);
geom.setMaterial(mat);


rootNode.attachChild(geom);
}

@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}

@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]
it works... Also i recently added an ambient light onto the terrain, and before then it ran but you couldnt see the terrain (no light.) I'm thinking the program is having trouble rendering that...

Thanks for any help!

1- SolidColor.j3md is obsolete according to the j3md - in fact, it should throw an AssetLoadException saying “SolidColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.” Are you sure you’re using jME 3 and not 2?

Edit - a little odd, your stack trace does mention jme3, so that’s “interesting/confusing”. Just tested again to be sure, and I do get an exception when I try to use SolidColor…





2- It looks to me like that’s a shader error, it’s expecting a 4 float vector but it’s only getting 1 float (something to do with data in the model you’re loading, but I haven’t messed with j3o models enough yet to really help here).

You are running against old code… probably base alpha 4 I’m guessing?



Update to a nightly build and you might get a better error message at best… maybe even it fixes your issue.



After upgrading, you will have to switch SolidColor to Unshaded and m_Color to Color but I think that’s it.

How do i upgrade to a nightly build? Just download here?

If you use JMP just look in the help: F1

Thanks :slight_smile:

Edit: What does this mean?

1- SolidColor.j3md is obsolete according to the j3md – in fact, it should throw an AssetLoadException saying “SolidColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.


Whats SolidColor.j3md? How do i switch?

edit2: I got the following error:
com.jme3.asset.AssetLoadException: SolidColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.


I hate to say but this is actually good it seems, as you now know what i mean. How would i go about switching?



Edit3: I tried taking out the part that makes a box, and got this error:

com.jme3.asset.AssetNotFoundException: com/jme3/gde/terraineditor/dirt.jpg (Flipped) (Mipmaped)

heres the code so someone can maybe test it :slight_smile:



[java]package mygame;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.renderer.RenderManager;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.scene.shape.Box;



/**

  • test
  • @author normenhansen

    */

    public class Main extends SimpleApplication {



    public static void main(String[] args) {

    Main app = new Main();

    app.start();

    }



    @Override

    public void simpleInitApp() {



    Spatial teapot = assetManager.loadModel("Scenes/main.j3o");

    rootNode.attachChild(teapot);



    }





    }

    [/java]

You see the line in your code that says:

Material mat = new Material(assetManager, “Common/MatDefs/Misc/SolidColor.j3md”);



You see how it says “SolidColor.j3md”? Change that to “Unshaded.j3md”… ie:

Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);



I have no idea about the other error. Seems like maybe there is a bad texture in the terrain.

I see… Thanks

Erm whats up with the terrain editor? Its not working at all? Just shows a green arrow pointing down, can change my angle or anything :open_mouth:

you didnt read jme3 tutorials, instead you read jme2 tutorials. so they dont work.



replace “Common/MatDefs/Misc/SolidColor.j3md” with “Common/MatDefs/Misc/Unshaded.j3md”

This is fixed… Starting a new topic about my other problems.