Problem : add cars during the game [SOLVED]

Hello,

I’m new in the community :slight_smile:

First of all, excuse me if I don’t speak very well sometimes. I learn English with delicacy ^^



(i don’t know if my topic is in the good troubleshooting)



well !

I have to develop a 3D game with JMonkeyEngine scene includes into a Swing window. No problem here even if the refresh render is sometimes bad : i must click on the scene to refresh it. --'

My problem is here :

When i want to put a car in my scene, i have sometimes a fatal error ! ^^ I know, i’m very strong for that 8)

This is my code :

[java]public void addCar( final int posX, final int posY ) throws InterruptedException, ExecutionException

{

// Class anonyme

Future fut = this.enqueue(new Callable()

{

public Object call() throws Exception

{

//this is where you modify your object, you can return a result value

return add( (float)posX, (float)posY);

}

});



//to retrieve return value (waits for call to finish, fire&forget otherwise):

fut.get();

nbCar++;

}



private int add( final float posX, final float posY )

{

Thread th = new Thread()

{

public void run()

{

int t;

if (listOfNode.isEmpty())

t = 0;

else

t = listOfNode.size();

String s = "Car"+t;

Node n = new Node(s);

listOfNode.add(n);

nodeCar.attachChild(n);

System.out.println(System.getProperty("user.dir")

+File.separator

+"F1.mesh.xml");

Spatial for1 = assetManager.loadModel("/Images/F1.mesh.xml");

// I change the position and size of my car

for1.setLocalTranslation(new Vector3f(0, 0, 0));

for1.scale(0.013f, 0.013f, 0.013f);

for1.move( ((float)(posY)/100), 0.025f, ((float)(tailleX-posX)/100) );

listOfCar.add(for1);

n.attachChild(for1);

}

};

th.run();

;

return 1;

}

[/java]



and now the error report :



#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000000b677829, pid=3492, tid=3848
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [ig4icd64.dll+0x1b7829]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

T H R E A D

Current thread (0x000000000a034000): JavaThread "LWJGL Renderer Thread" [_thread_in_native, id=3848, stack(0x000000000b3c0000,0x000000000b4c0000)]

siginfo: ExceptionCode=0xc0000005, reading address 0x000000000dfc0008

Registers:
RAX=0x0000000000000180, RBX=0x000000000c7bdac8, RCX=0x000000000dfc0000, RDX=0x0000000000000000
RSP=0x000000000b4be790, RBP=0x0000000000000004, RSI=0x0000000000000020, RDI=0x0000000010a39880
R8 =0x0000000000000002, R9 =0x0000000000000000, R10=0x0000000000000001, R11=0x000000000dfbfe80
R12=0x0000000000000030, R13=0x000000000200d810, R14=0x000000000000000c, R15=0x0000000010a39880
RIP=0x000000000b677829, EFLAGS=0x0000000000010246

Top of Stack: (sp=0x000000000b4be790)
0x000000000b4be790: 0000000010a7d8f0 000000000c1617c0
0x000000000b4be7a0: 0000000010a7d770 000000000dc98b40
0x000000000b4be7b0: 0000000000000001 0000000000000002
0x000000000b4be7c0: 0000000000000000 000000000000000c
0x000000000b4be7d0: 00000000bd070f2d 0000000000000000
0x000000000b4be7e0: 00000000bd070f2d 0000000000000000
0x000000000b4be7f0: 00000000000004b0 0000000010a391d0
0x000000000b4be800: 0000000000000030 0000000000000000
0x000000000b4be810: 0000000010a39880 0000000000000000
0x000000000b4be820: 000000000c7b0e40 000000000b679d2f
0x000000000b4be830: 000000000c7b0e40 00000000000004b0
0x000000000b4be840: 0000000000000030 0000000010a398b0
0x000000000b4be850: 0000000010a39880 0000000000000001
0x000000000b4be860: 0000000000000000 00000000000004b0
0x000000000b4be870: 0000000000001403 0000000000080038
0x000000000b4be880: 00000000000004b0 0000000000000f66

Instructions: (pc=0x000000000b677829)
0x000000000b677809: 83 ea 01 74 2b 83 ea 01 74 1e 83 ea 01 74 11 83
0x000000000b677819: fa 01 0f 85 59 02 00 00 8b 41 0c 41 89 44 ed 0c
0x000000000b677829: 8b 41 08 41 89 44 ed 08 8b 41 04 41 89 44 ed 04
0x000000000b677839: 8b 01 4c 8b 54 24 20 48 8b 9c 24 a0 00 00 00 4c


Register to memory mapping:

RAX=0x0000000000000180 is an unknown value
RBX=0x000000000c7bdac8 is an unknown value
RCX=0x000000000dfc0000 is an unknown value
RDX=0x0000000000000000 is an unknown value
RSP=0x000000000b4be790 is pointing into the stack for thread: 0x000000000a034000
RBP=0x0000000000000004 is an unknown value
RSI=0x0000000000000020 is an unknown value
RDI=0x0000000010a39880 is an unknown value
R8 =0x0000000000000002 is an unknown value
R9 =0x0000000000000000 is an unknown value
R10=0x0000000000000001 is an unknown value
R11=0x000000000dfbfe80 is an unknown value
R12=0x0000000000000030 is an unknown value
R13=0x000000000200d810 is an unknown value
R14=0x000000000000000c is an unknown value
R15=0x0000000010a39880 is an unknown value


Stack: [0x000000000b3c0000,0x000000000b4c0000], sp=0x000000000b4be790, free space=1017k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [ig4icd64.dll+0x1b7829]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.opengl.GL12.nglDrawRangeElementsBO(IIIIIJJ)V+0
j org.lwjgl.opengl.GL12.glDrawRangeElements(IIIIIJ)V+32
j com.jme3.renderer.lwjgl.LwjglRenderer.drawTriangleList(Lcom/jme3/scene/VertexBuffer;Lcom/jme3/scene/Mesh;I)V+361
j com.jme3.renderer.lwjgl.LwjglRenderer.renderMeshDefault(Lcom/jme3/scene/Mesh;II)V+165
j com.jme3.renderer.lwjgl.LwjglRenderer.renderMesh(Lcom/jme3/scene/Mesh;II)V+160
j com.jme3.material.Material.renderMultipassLighting(Lcom/jme3/shader/Shader;Lcom/jme3/scene/Geometry;Lcom/jme3/renderer/RenderManager;)V+595
j com.jme3.material.Material.render(Lcom/jme3/scene/Geometry;Lcom/jme3/renderer/RenderManager;)V+285
j com.jme3.renderer.RenderManager.renderGeometry(Lcom/jme3/scene/Geometry;)V+161
j com.jme3.renderer.queue.RenderQueue.renderGeometryList(Lcom/jme3/renderer/queue/GeometryList;Lcom/jme3/renderer/RenderManager;Lcom/jme3/renderer/Camera;Z)V+66
j com.jme3.renderer.queue.RenderQueue.renderQueue(Lcom/jme3/renderer/queue/RenderQueue$Bucket;Lcom/jme3/renderer/RenderManager;Lcom/jme3/renderer/Camera;Z)V+68
j com.jme3.renderer.RenderManager.renderViewPortQueues(Lcom/jme3/renderer/ViewPort;Z)V+22
j com.jme3.renderer.RenderManager.flushQueue(Lcom/jme3/renderer/ViewPort;)V+3
j com.jme3.renderer.RenderManager.renderViewPort(Lcom/jme3/renderer/ViewPort;F)V+267
j com.jme3.renderer.RenderManager.render(FZ)V+123
j com.jme3.app.SimpleApplication.update()V+192
j com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop()V+22
j com.jme3.system.lwjgl.LwjglCanvas.runLoop()V+222
j com.jme3.system.lwjgl.LwjglAbstractDisplay.run()V+117
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

P R O C E S S

Java Threads: ( => current thread )
0x00000000075e2000 JavaThread "jME3 Audio Thread" daemon [_thread_blocked, id=3988, stack(0x000000000e140000,0x000000000e240000)]
=>0x000000000a034000 JavaThread "LWJGL Renderer Thread" [_thread_in_native, id=3848, stack(0x000000000b3c0000,0x000000000b4c0000)]
0x00000000074f3000 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=1248, stack(0x0000000007be0000,0x0000000007ce0000)]
0x0000000007541000 JavaThread "AWT-Shutdown" [_thread_blocked, id=208, stack(0x0000000007a40000,0x0000000007b40000)]
0x000000000202b800 JavaThread "DestroyJavaVM" [_thread_blocked, id=2000, stack(0x00000000022c0000,0x00000000023c0000)]
0x0000000007698800 JavaThread "Thread-3" [_thread_in_native, id=3904, stack(0x00000000099f0000,0x0000000009af0000)]
0x0000000007649800 JavaThread "TimerQueue" daemon [_thread_blocked, id=3896, stack(0x0000000008910000,0x0000000008a10000)]
0x00000000074f3800 JavaThread "AWT-Windows" daemon [_thread_in_native, id=4016, stack(0x0000000006bd0000,0x0000000006cd0000)]
0x000000000624f000 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=3556, stack(0x00000000078c0000,0x00000000079c0000)]
0x000000000614e000 JavaThread "Service Thread" daemon [_thread_blocked, id=2520, stack(0x0000000007200000,0x0000000007300000)]
0x0000000006149800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=2556, stack(0x00000000070b0000,0x00000000071b0000)]
0x0000000006145800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=788, stack(0x0000000006eb0000,0x0000000006fb0000)]
0x000000000613e000 JavaThread "Attach Listener" daemon [_thread_blocked, id=2760, stack(0x0000000006d50000,0x0000000006e50000)]
0x0000000006139000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2844, stack(0x0000000006990000,0x0000000006a90000)]
0x0000000002282000 JavaThread "Finalizer" daemon [_thread_blocked, id=4000, stack(0x0000000006a90000,0x0000000006b90000)]
0x000000000227a000 JavaThread "Reference Handler" daemon [_thread_blocked, id=3776, stack(0x0000000006870000,0x0000000006970000)]

Other Threads:
0x0000000002274800 VMThread [stack: 0x0000000006690000,0x0000000006790000] [id=3032]
0x000000000615f000 WatcherThread [stack: 0x00000000073b0000,0x00000000074b0000] [id=2316]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
PSYoungGen total 18176K, used 11408K [0x00000000ebc00000, 0x00000000ed040000, 0x0000000100000000)
eden space 15616K, 56% used [0x00000000ebc00000,0x00000000ec4a9570,0x00000000ecb40000)
from space 2560K, 99% used [0x00000000ecdc0000,0x00000000ed03ae80,0x00000000ed040000)
to space 2560K, 0% used [0x00000000ecb40000,0x00000000ecb40000,0x00000000ecdc0000)
PSOldGen total 41472K, used 4300K [0x00000000c3400000, 0x00000000c5c80000, 0x00000000ebc00000)
object space 41472K, 10% used [0x00000000c3400000,0x00000000c3833360,0x00000000c5c80000)
PSPermGen total 21248K, used 17295K [0x00000000be200000, 0x00000000bf6c0000, 0x00000000c3400000)
object space 21248K, 81% used [0x00000000be200000,0x00000000bf2e3da8,0x00000000bf6c0000)

Code Cache [0x00000000023c0000, 0x0000000002630000, 0x00000000053c0000)
total_blobs=838 nmethods=249 adapters=540 free_code_cache=47851Kb largest_free_block=48972096

Dynamic libraries:
0x000000013fdd0000 - 0x000000013fe03000 C:Program FilesJavajre7binjavaw.exe
0x00000000778e0000 - 0x0000000077a89000 C:WindowsSYSTEM32ntdll.dll
0x00000000776c0000 - 0x00000000777df000 C:Windowssystem32kernel32.dll
0x000007fefdb90000 - 0x000007fefdbfc000 C:Windowssystem32KERNELBASE.dll
0x000007fefe010000 - 0x000007fefe0eb000 C:Windowssystem32ADVAPI32.dll
0x000007fefe440000 - 0x000007fefe4df000 C:Windowssystem32msvcrt.dll
0x000007fefdff0000 - 0x000007fefe00f000 C:WindowsSYSTEM32sechost.dll
0x000007feff810000 - 0x000007feff93d000 C:Windowssystem32RPCRT4.dll
0x00000000777e0000 - 0x00000000778da000 C:Windowssystem32USER32.dll
0x000007feffb80000 - 0x000007feffbe7000 C:Windowssystem32GDI32.dll
0x000007fefdfe0000 - 0x000007fefdfee000 C:Windowssystem32LPK.dll
0x000007fefdd80000 - 0x000007fefde49000 C:Windowssystem32USP10.dll
0x000007fefc300000 - 0x000007fefc4f4000 C:WindowsWinSxSamd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_fa396087175ac9acCOMCTL32.dll
0x000007fefe700000 - 0x000007fefe771000 C:Windowssystem32SHLWAPI.dll
0x000007fefe200000 - 0x000007fefe22e000 C:Windowssystem32IMM32.DLL
0x000007fefe0f0000 - 0x000007fefe1f9000 C:Windowssystem32MSCTF.dll
0x0000000074670000 - 0x0000000074741000 C:Program FilesJavajre7binmsvcr100.dll
0x0000000073fa0000 - 0x000000007466d000 C:Program FilesJavajre7binserverjvm.dll
0x000007fef85f0000 - 0x000007fef85f9000 C:Windowssystem32WSOCK32.dll
0x000007feff940000 - 0x000007feff98d000 C:Windowssystem32WS2_32.dll
0x000007feff990000 - 0x000007feff998000 C:Windowssystem32NSI.dll
0x000007fefb450000 - 0x000007fefb48b000 C:Windowssystem32WINMM.dll
0x0000000077aa0000 - 0x0000000077aa7000 C:Windowssystem32PSAPI.DLL
0x0000000074820000 - 0x000000007482f000 C:Program FilesJavajre7binverify.dll
0x00000000747f0000 - 0x0000000074818000 C:Program FilesJavajre7binjava.dll
0x00000000747d0000 - 0x00000000747e5000 C:Program FilesJavajre7binzip.dll
0x00000000728e0000 - 0x0000000072a73000 C:Program FilesJavajre7binawt.dll
0x000007fefe560000 - 0x000007fefe637000 C:Windowssystem32OLEAUT32.dll
0x000007fefe230000 - 0x000007fefe433000 C:Windowssystem32ole32.dll
0x000007fefbff0000 - 0x000007fefc046000 C:Windowssystem32uxtheme.dll
0x000007fefbbe0000 - 0x000007fefbbf8000 C:Windowssystem32dwmapi.dll
0x000007fefd760000 - 0x000007fefd76f000 C:Windowssystem32CRYPTBASE.dll
0x000007fefea80000 - 0x000007feff808000 C:Windowssystem32SHELL32.dll
0x0000000073f40000 - 0x0000000073f74000 C:Program FilesJavajre7binfontmanager.dll
0x00000000747b0000 - 0x00000000747c9000 C:Program FilesJavajre7binnet.dll
0x000007fefd0a0000 - 0x000007fefd0f5000 C:Windowssystem32mswsock.dll
0x000007fefd090000 - 0x000007fefd097000 C:WindowsSystem32wship6.dll
0x0000000074790000 - 0x00000000747a1000 C:Program FilesJavajre7binnio.dll
0x0000000073e90000 - 0x0000000073ed1000 C:Program FilesJavajre7bint2k.dll
0x000007fefe780000 - 0x000007fefe819000 C:Windowssystem32CLBCatQ.DLL
0x000007fefba70000 - 0x000007fefbb9a000 C:Windowssystem32WindowsCodecs.dll
0x000007fefd700000 - 0x000007fefd757000 C:Windowssystem32apphelp.dll
0x000007fef78d0000 - 0x000007fef7905000 C:Windowssystem32EhStorShell.dll
0x000007feff9a0000 - 0x000007feffb77000 C:Windowssystem32SETUPAPI.dll
0x000007fefd8e0000 - 0x000007fefd916000 C:Windowssystem32CFGMGR32.dll
0x000007fefdad0000 - 0x000007fefdaea000 C:Windowssystem32DEVOBJ.dll
0x000007fefc070000 - 0x000007fefc19c000 C:Windowssystem32PROPSYS.dll
0x000007fef7850000 - 0x000007fef78ce000 C:WindowsSystem32cscui.dll
0x000007fef7840000 - 0x000007fef784c000 C:WindowsSystem32CSCDLL.dll
0x000007fef7b60000 - 0x000007fef7b6f000 C:Windowssystem32CSCAPI.dll
0x000007fef77c0000 - 0x000007fef7840000 C:Windowssystem32ntshrui.dll
0x000007fefd480000 - 0x000007fefd4a3000 C:Windowssystem32srvcli.dll
0x000007fefb200000 - 0x000007fefb20b000 C:Windowssystem32slc.dll
0x0000000180000000 - 0x000000018004e000 D:CoursProgJAVAProjFormuleD�testFD_WPtest_svn2lwjgl64.dll
0x000007fef2c40000 - 0x000007fef2d5d000 C:Windowssystem32OPENGL32.dll
0x000007fefaf70000 - 0x000007fefaf9d000 C:Windowssystem32GLU32.dll
0x000007fef88d0000 - 0x000007fef89c1000 C:Windowssystem32DDRAW.dll
0x000007fefc1a0000 - 0x000007fefc1a8000 C:Windowssystem32DCIMAN32.dll
0x000007fefc990000 - 0x000007fefc99c000 C:Windowssystem32VERSION.dll
0x000000000b4c0000 - 0x000000000c6ad000 C:Windowssystem32ig4icd64.dll
0x0000000005ce0000 - 0x0000000005d1a000 D:CoursProgJAVAProjFormuleD�testFD_WPtest_svn2OpenAL64.dll
0x0000000072b70000 - 0x0000000072c0d000 C:WindowsWinSxSamd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4940_none_08e4299fa83d7e3cMSVCR90.dll
0x000007fef1fb0000 - 0x000007fef2038000 C:Windowssystem32dsound.dll
0x000007fefc220000 - 0x000007fefc24c000 C:Windowssystem32POWRPROF.dll
0x000007fefc1d0000 - 0x000007fefc21b000 C:WindowsSystem32MMDevApi.dll
0x000007fefb100000 - 0x000007fefb14f000 C:Windowssystem32AUDIOSES.DLL
0x000007fefbf60000 - 0x000007fefbf69000 C:Windowssystem32avrt.dll
0x0000000073df0000 - 0x0000000073e20000 C:Program FilesJavajre7binjpeg.dll
0x0000000073f30000 - 0x0000000073f37000 C:Program FilesJavajre7binjawt.dll

VM Arguments:
jvm_args: -Dfile.encoding=UTF-8
java_command: client3D.Main
Launcher Type: SUN_STANDARD

Environment Variables:
PATH=C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0
USERNAME=Mecrof
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 37 Stepping 2, GenuineIntel



S Y S T E M

OS: Windows 7 , 64 bit Build 7601 Service Pack 1

CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, ht

Memory: 4k page, physical 3978884k(2339536k free), swap 7955920k(5876344k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (21.1-b02) for windows-amd64 JRE (1.7.0_01-b08), built on Oct 3 2011 01:39:25 by "java_re" with unknown MS VC++:1600

time: Thu Jan 05 17:46:17 2012
elapsed time: 11 seconds




I think the problem is from OpenGL but where ? In my program ? In my computer ? In OpenGL ? In jMonkey ?
I need your help... I don't know what to do. :(

[edit :] i use Eclipse Indigo on Windows 7 pro 64

http://www.youtube.com/watch?v=_33cKDqRvzs

!! Well, you think the problem is from multi-threads ? Why not, however, i remember i tried without and that’s why i use them now. … -.-

But, i will try without thread soon.

Thanks !

I’ll keep you informed… :slight_smile:

Your way to do the threading is so bad that I don’t really feel like explaining what is bad about it ^^

It works but if in same time i move my camera, i get an exception :

Now :

[java]

public void addCar( final int posX, final int posY )

{

add( (float)posX, (float)posY);

nbCar++;

}



private void add( float posX, float posY )

{

int t;

if (listOfNode.isEmpty())

t = 0;

else

t = listOfNode.size();

String s = “Car”+t;

Node n = new Node(s);

listOfNode.add(n);

nodeCar.attachChild(n);

Spatial for1 = assetManager.loadModel("/Images/F1.mesh.xml");

for1.setLocalTranslation(new Vector3f(0, 0, 0));

for1.scale(0.013f, 0.013f, 0.013f);

for1.move( ((float)(posY)/100), 0.025f, ((float)(sizeX-posX)/100) );

listOfCar.add(for1);

n.attachChild(for1);

}

[/java]

So now, the adding of car is into my SimpleApplication’s renderer thread.

And the exception :

[java]

Infos: Child (Car0) attached to this node (rootNode)

janv. 09, 2012 10:37:44 PM com.jme3.material.MaterialDef <init>

Infos: Loaded material definition: Phong Lighting

janv. 09, 2012 10:37:45 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-1) attached to this node (F1-ogremesh)

janv. 09, 2012 10:37:45 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-2) attached to this node (F1-ogremesh)

janv. 09, 2012 10:37:45 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-3) attached to this node (F1-ogremesh)

janv. 09, 2012 10:37:46 PM com.jme3.scene.Node attachChild

Infos: Child (F1-ogremesh) attached to this node (Car0)

janv. 09, 2012 10:37:46 PM com.jme3.scene.Node attachChild

// My first car is correctly attached

Infos: Child (Car1) attached to this node (rootNode)

janv. 09, 2012 10:37:46 PM com.jme3.app.Application handleError

Grave: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalStateException: Scene graph is not properly updated for rendering.

State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

Problem spatial name: Car1

at com.jme3.scene.Spatial.checkCulling(Spatial.java:254)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:776)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:794)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1117)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1168)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:266)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Unknown Source)



janv. 09, 2012 10:37:46 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup

Infos: Deleting objects and invalidating state

janv. 09, 2012 10:37:46 PM com.jme3.scene.Node attachChild

Infos: Child (F1-ogremesh) attached to this node (Car1)

janv. 09, 2012 10:37:46 PM com.jme3.input.lwjgl.LwjglMouseInput destroy

Infos: Mouse destroyed.

janv. 09, 2012 10:37:46 PM com.jme3.input.lwjgl.LwjglKeyInput destroy

Infos: Keyboard destroyed.

janv. 09, 2012 10:37:46 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

Infos: Display destroyed.

[/java]



[edit :] normen : i think so, but i don’t know how to add an object in my scene during the game without it.

please do read the output, it has meaning and its not some magical words that you need to post here to decipher them:

Grave: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!

I had read but i have no other thread who modifies the scene… I have the scene’s thread and the main’s thread. The latter implements the scene and calls addCar. Like this : myScene.addCar(posX, posY);

I know it’s a problem about thread but i don’t understand why.

I think my problem is solved. I’m not exactly sure but i saw a reply (Normen’s) into an other topic :


[...] Don’t forget to call updateLogicalState() and updateGeometricState() on the rootNodes on each update. [...]

I tried it and that correctly works now. (without thread!!) It's strange because i thought these functions were called on each update by default.
Thank you very much, Normen. Could you explain me (if you want) why i must call updateGeometricState() on each update ?
Thanks again ! :) :)

If you have to do that for the already existing rootNode you are still doing it wrong.

Yes, you’re right… i again tried and again this problem… :cry: well, i don’t know where this thread so i’ll start over.

I’ll keep you informed.

I really don’t understand… same thing on a very simple application. :?

Here’s what I coded :

[java]

import java.io.File;



import com.jme3.app.SimpleApplication;

import com.jme3.asset.plugins.FileLocator;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Node;

import com.jme3.scene.Spatial;

import com.jme3.util.SkyFactory;



public class SceneOfTests extends SimpleApplication {



int cpt;



public SceneOfTests() {

// TODO Auto-generated constructor stub

super();

cpt = 0;

}



@Override

public void simpleInitApp() {

// TODO Auto-generated method stub



rootNode.attachChild(SkyFactory.createSky(assetManager, “Textures/Sky/Bright/BrightSky.dds”, false));

flyCam.setDragToRotate(true);



assetManager.registerLocator

(

System.getProperty(“user.dir”)+File.separator,

FileLocator.class.getName()

);



guiNode.detachAllChildren();



DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));

sun.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 1.0f));

rootNode.addLight(sun);



}



private void addCar( final float posX, final float posY )

{

System.out.println(“Begin adding Car”);



cpt++;

String s = “Car”+cpt;

Node n = new Node(s);

rootNode.attachChild(n);

Spatial for1 = assetManager.loadModel("/Images/F1.mesh.xml");

for1.setLocalTranslation(new Vector3f(0, 0, 0));

for1.scale(0.013f, 0.013f, 0.013f);

for1.move( ((float)(posY)/100), 0.025f, ((float)(1024-posX)/100) );

n.attachChild(for1);



System.out.println(“End adding Car”);

}



public static void main(String[] args) {



System.out.println(“Begin Main”);



SceneOfTests sc = new SceneOfTests();

sc.start();



try {

Thread.sleep(4000);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

System.out.println("Error thread : " +e.getStackTrace());

}



sc.addCar(200, 0);



System.out.println(“End Main”);



}



}

[/java]



and again the exception :

[java]

Begin adding Car

janv. 10, 2012 6:22:16 PM com.jme3.scene.Node attachChild

Infos: Child (Car1) attached to this node (Root Node)

janv. 10, 2012 6:22:16 PM com.jme3.material.MaterialDef <init>

Infos: Loaded material definition: Phong Lighting

janv. 10, 2012 6:22:17 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-1) attached to this node (F1-ogremesh)

janv. 10, 2012 6:22:17 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-2) attached to this node (F1-ogremesh)

janv. 10, 2012 6:22:17 PM com.jme3.scene.Node attachChild

Infos: Child (F1-geom-3) attached to this node (F1-ogremesh)

janv. 10, 2012 6:22:17 PM com.jme3.scene.Node attachChild

Infos: Child (F1-ogremesh) attached to this node (Car1)

End adding Car

End Main

janv. 10, 2012 6:23:06 PM com.jme3.app.Application handleError

Grave: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalStateException: Scene graph is not properly updated for rendering.

State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

Problem spatial name: Root Node

at com.jme3.scene.Spatial.checkCulling(Spatial.java:254)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:776)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1117)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1168)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:266)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Unknown Source)



janv. 10, 2012 6:23:06 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup

Infos: Deleting objects and invalidating state

janv. 10, 2012 6:23:06 PM com.jme3.input.lwjgl.LwjglMouseInput destroy

Infos: Mouse destroyed.

janv. 10, 2012 6:23:06 PM com.jme3.input.lwjgl.LwjglKeyInput destroy

Infos: Keyboard destroyed.

janv. 10, 2012 6:23:06 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

Infos: Display destroyed.

[/java]

“Make sure you do not modify the scene from another thread!” Where ?!! :?



[edit : ] I think the other thread is the main. Because i tried to put car’s coordinates in SceneOfTest. And on the simpleUpdate, i delete the car and after i recreate it with no problem ! I know it’s very bad but it was just to try. So, if it’s this problem, how can i synchronize the main with my SimpleApplication ?

The main method runs in another thread than the app

yep !

That’s why it doesn’t work sometimes. I learned lot of things about thread : general meanings, wait(), etc… i never use them for the moment WITH jMonkey before. The thread of jmonkey is running during the main’s thread do other things. But i don’t know to synchronise them. I have already done that with two threads. But they were my own thread. Here, i have to use the thread of jmonkey with the thread of the main. Do you think i have to use wait() and notify() methods ?

JME3 doesnt seem to work well (or at all, as the error implies), when u try to update the scene from another thread.



i have found a way around this by doing functions that stop themselves at some point and when they return, they do so from where they left… so it creates an ilusion of threading without actually having multiple threads modifing the scene…



i would suggest though, that you try simpler stuff, as normen kindly suggested with his video xD… if you cant work out by urself what your doing wrong, it’s sometimes better to make things simple and work slowly up from there…



main method should only start JME3, after that, to update it, use the “simpleUpdate”, here’s the tutorial:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_main_event_loop



be sure to do ALL the tutorials:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3



they will save time to you and to others trying to figure out how to explain the basics to you :slight_smile:



cheers mate, and good luck…

:facepalm:

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:multithreading

[snippet id=“10”]

oh, there was a multithreading tutorial, yeah… i saw that, didnt read it though xD… but my functions work quite well like they are now :wink:

will read it soon enough though xD!! thx :slight_smile:

i might take my own advice and keep reading all the tutorials :wink: lol… cheers…



edit: btw, how did you do the face palm? xD lol

http://hub.jmonkeyengine.org/wp-includes/images/smilies/chimpanzee-facepalm.gif

xD So thats where the : facepalm: (hint, hint) smiley is stored ^^

I don’t memorize the smileys tag, I go directly to the smileys page xD.

lol :facepalm: nice :smiley: thx…



on an added note, multithreading would actually not work quite as the functions i already made…

i’ve made a multithreaded server for the mutant that was the JOGL client version of my game, and had to carefully sincronize all the threads in it… since then, i’ve hated threads for their randomness… unless finely tuned, they are managed by the OS, which gives quite random results on how CPU time is shared amongs them… this can be a good thing or a bad thing, depending on how you want things to flow…



cheers :slight_smile: