Show Posts
|
|
Pages: [1] 2
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: Textures dont show up on models
|
on: 2006-03-27 05:05:06
|
Also another problem, I can run my program as a Application just fine, but when I try to open it as an applet in html, it has an error initializing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| import java.applet.Applet; import java.awt.BorderLayout; import java.awt.event.*; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.behaviors.vp.*; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.loaders.*; import com.glyphein.j3d.loaders.milkshape.MS3DLoader; public class LandTest extends Applet { SimpleUniverse u; BoundingSphere bounds; ViewingPlatform ourView; OrbitBehavior B; public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); u = new SimpleUniverse(c); BranchGroup scene = createSceneGraph(); u.addBranchGraph(scene); ourView = u.getViewingPlatform(); ourView.setNominalViewingTransform(); B = new OrbitBehavior(c); B.setSchedulingBounds(bounds); ourView.setViewPlatformBehavior(B); add("Center",c); }
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); bounds = new BoundingSphere(); String filePath="file://localhost/"+System.getProperty("user.dir")+"/"; String texturePath=filePath + "stone.jpg"; Land s = new Land(6, 6, texturePath); try { java.net.URL modelPath = new java.net.URL(filePath+"gun2.ms3d"); Loader msLoader = new MS3DLoader(); Scene ourScene; ourScene = msLoader.load(modelPath); BranchGroup modelBranch = ourScene.getSceneGroup(); Shape3D model= (Shape3D)modelBranch.getChild(0); modelBranch.removeChild(0); objRoot.addChild(model); } catch(Exception e){ } Color3f alColour = new Color3f(0.4f, 0.4f, 0.4f); AmbientLight aLgt = new AmbientLight(alColour); aLgt.setInfluencingBounds(bounds); Color3f DirColour = new Color3f(0.35f, 0.35f, 0.3f); Vector3f DirVec = new Vector3f(-0.5f, -0.2f, 0.6f); DirectionalLight DirLig = new DirectionalLight(DirColour, DirVec); DirLig.setInfluencingBounds(bounds); objRoot.addChild(DirLig); objRoot.addChild(aLgt); objRoot.addChild(s); objRoot.compile(); return objRoot; } public static void main(String[] args) { new MainFrame(new LandTest(), 256, 256); } } |
error message: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Java Plug-in 1.5.0_06 Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\peter
---------------------------------------------------- c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n> ----------------------------------------------------
java.lang.NoClassDefFoundError: javax/media/j3d/Bounds at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-4" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletStatus(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NoClassDefFoundError: javax/media/j3d/Bounds at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.newInstance0(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at sun.applet.AppletPanel.createApplet(Unknown Source) at sun.plugin.AppletViewer.createApplet(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception in thread "Thread-8" java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletException(Unknown Source) at sun.applet.AppletPanel.runLoader(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) java.lang.NullPointerException at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source) at sun.plugin.AppletViewer.showAppletStatus(Unknown Source) at sun.applet.AppletPanel.run(Unknown Source) at java.lang.Thread.run(Unknown Source) |
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: Textures dont show up on models
|
on: 2006-03-27 04:23:31
|
|
ok I realized that in milkshape, you have to, when your done, regroup the entire model into one group,
I had it where i grouped it differently, to do textures (i.e. different colors for stuff), are I did this, the model imported with success.
ONLY problem is, and its a big problem, when I regrouped, all the texturing stuff got deleted, so do you know how to keep the textures?
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: 3d lighting
|
on: 2006-03-26 06:34:56
|
|
ugh, i is really beginner
for (1) I just tried random normal values because i dont really know much about normals (0,10,30,60,120,270) and it didnt work SO can you tell me what radian means??? i guess that would help alot, and HOW DO YOU CALCULATE THE APPROPRIATE RADIAN
for(2) im pretty sure its not that, sinc it works with the other object
|
|
|
|
|
10
|
Game Development / Newbie & Debugging Questions / 3d lighting
|
on: 2006-03-26 05:08:56
|
well i read this source code that had the lighting done pretty good but it was kind of hard to understand ( not the lighting part, but everything else ) so I wrote my own program but using the lighting part of the source code, and........my lighting doesnt work. this is my class code for the geometry + lighting part 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| GeometryInfo gf = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); gf.setTextureCoordinateParams(1,2); gf.setTextureCoordinates(0,txt); gf.setStripCounts(strips); gf.setCoordinates(pts); gf.setContourCounts(contours); NormalGenerator ng = new NormalGenerator(); ng.setCreaseAngle ((float) Math.toRadians(30)); ng.generateNormals(gf); Appearance app = new Appearance(); Material mat = new Material(); mat.setShininess(0.01f); mat.setEmissiveColor(0.0f, 0.0f, 0.0f); mat.setAmbientColor(0.1f, 0.1f, 0.1f); app.setMaterial(mat); try{
TextureLoader txtLoader = new TextureLoader(new java.net.URL(texture),null); Texture2D textImg = (Texture2D) txtLoader.getTexture(); TextureAttributes texatt=new TextureAttributes(TextureAttributes.BLEND, new Transform3D(), new Color4f(1.0f, 1.0f, 1.0f, 1.0f), TextureAttributes.NICEST); app.setTextureAttributes(texatt); app.setTexture(textImg); }catch(java.net.MalformedURLException e){ System.out.println("he"); } setGeometry(gf.getGeometryArray()); setAppearance(app); |
and this is the tester class that I use for both the other source code and my code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| import java.applet.Applet; import java.awt.BorderLayout; import java.awt.event.*; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.behaviors.vp.*; import javax.media.j3d.*; import javax.vecmath.*;
public class LandTest extends Applet { SimpleUniverse u; BoundingSphere bounds; ViewingPlatform ourView; OrbitBehavior B; public void init() { setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); u = new SimpleUniverse(c); BranchGroup scene = createSceneGraph(); u.addBranchGraph(scene); ourView = u.getViewingPlatform(); ourView.setNominalViewingTransform(); B = new OrbitBehavior(c); B.setSchedulingBounds(bounds); ourView.setViewPlatformBehavior(B); add("Center",c); }
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); bounds = new BoundingSphere(); String texturePath="file://localhost/"+System.getProperty("user.dir")+"/stone.jpg"; Land s = new Land(6, 6, texturePath); Color3f alColour = new Color3f(0.4f, 0.4f, 0.4f); AmbientLight aLgt = new AmbientLight(alColour); aLgt.setInfluencingBounds(bounds); Color3f DirColour = new Color3f(0.35f, 0.35f, 0.3f); Vector3f DirVec = new Vector3f(0.5f, -0.2f, 0.6f); DirectionalLight DirLig = new DirectionalLight(DirColour, DirVec); DirLig.setInfluencingBounds(bounds); objRoot.addChild(DirLig); objRoot.addChild(aLgt); objRoot.addChild(s); objRoot.compile(); return objRoot; }
public static void main(String[] args) { new MainFrame(new LandTest(), 256, 256); } } |
|
|
|
|
|
16
|
Game Development / Newbie & Debugging Questions / Re: Need help bad!
|
on: 2006-02-12 22:44:21
|
|
What this code is suppose to do is, when I kill an enemy, he drops a item, and that item goes in the ArrayList,
the thing is, this works only for the first item that gets dropped, if i try to get any other one BESIDES the one being dropped then i get error
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: Need help bad!
|
on: 2006-02-12 22:41:04
|
it says NullPointer Exception at line 355 which is this line 1
| if(!( currentI.getBounds().intersects( quix.getBounds() ))) |
and if i make it a comment (/* */) then the error goes to 1
| quix.itemTask( currentI.task() ); |
and if i comment that it goes to 1
| level.setGarbage( currentI.getIdRow(),currentI.getIdCol() ); |
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Ah! Im so stupid
|
on: 2006-02-12 22:22:57
|
My game is due tomorrow and im far from done so plz help ArrayLists are making me so angry!! I keep getting a nullpointer exception while using a iterator to go through an arrayList, but When i looked through my code, there was nothing I found that removes the element during iteration (besides the code that removes the current element after using it) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| for(int row=0;row<4;row++) { if(row!=2) { currentIndex = row*level.getLevelWidth()+quix.getCol(); eIterator = iList[ currentIndex ].iterator(); while(eIterator.hasNext()) { currentI = (Element)eIterator.next(); if(!( currentI.getBounds().intersects( quix.getBounds() ))) { continue; } quix.itemTask( currentI.task() ); level.setGarbage( currentI.getIdRow(),currentI.getIdCol() ); eIterator.remove(); } } } |
when i execute it tells me that currentI is null, but i never made it null 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| { public void generateItem(int enemyIndex) { randnum = random.nextInt(60); if(randnum>40) { int index = (Integer)blankIndex.get(0); System.out.println(index); int row = index/4; int col = index%getLevelWidth(); elementsArray[row][col] = new Element("potion",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app); itemList[enemyIndex].add(elementsArray[col][row]); blankIndex.remove(0); } else if(randnum>35) { int index = (Integer)blankIndex.get(0); int row = index/4; int col = index%getLevelWidth(); elementsArray[row][col] = new Element("hbook",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app); itemList[enemyIndex].add(elementsArray[col][row]); blankIndex.remove(0); } else { int index = (Integer)blankIndex.get(0); int row = index/4; int col = index%getLevelWidth(); elementsArray[row][col] = new Element("money",enemyIndex/getLevelWidth(),enemyIndex%getLevelWidth(),row,col,applet,app); itemList[enemyIndex].add(elementsArray[col][row]); blankIndex.remove(0); } } } |
1 2 3 4 5 6
| public void setGarbage(int row, int col) { blankIndex.add(row*getLevelWidth()+col); } |
|
|
|
|
|
19
|
Game Development / Newbie & Debugging Questions / help! weird problem
|
on: 2006-02-11 20:41:43
|
In my game, when the character's position is 0 or less, he cant move left (left edge of the game) My code works when he is walking on ground level (he cant move left when reach edge), but when character is jumping, in the air, then he can MOVE left. i dont know why this happens my code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| if(key == Event.LEFT) { if(quix.getXposLeft()<=0) { quix.isWalkingLeft(false); quix.isFaceLeft(true); } } ........................ else if (key == Event.UP) { if(!quix.getJumpLock()) quix.isJumping(true); } |
|
|
|
|
|
20
|
Game Development / Newbie & Debugging Questions / Re: Efficiency Question?
|
on: 2006-02-10 06:34:56
|
|
but isn't time consuming to recreate objects?
I read somewhere that instead of deleting an element in the list ( that you would need later, but not at the moment), its best to not delete it, but put it in a arrayList and pull it out of the arrayList when you need it.
im pretty sure that is faster than the first two,..................right?
|
|
|
|
|
21
|
Game Development / Newbie & Debugging Questions / Efficiency Question?
|
on: 2006-02-09 01:42:58
|
|
If I have a grid and each position on grid is an ArrayList
is it better to
1. Construct all the ArrayLists at initialization, and just leave them active, even if their is nothing in there.
2. don't make any ArrayList at initialization, but when an object moves to that spot, that instantiate an ArrayList and add it to the list, but if that object moves to a different grid, then delete that ArrayList, and make a new ArrayList, at that Enemies position
I've already done the first, and it works fine, but just wondering if is faster to do option 2.
|
|
|
|
|
24
|
Game Development / Newbie & Debugging Questions / Re: quick ArrayList question
|
on: 2006-02-07 02:41:16
|
lol thats funny cause my Comp Sci teacher is telling me that get() returns only a copy. but i dont understand something in my previous 2 examples, the original list gets changed but when i did another test, this time with Strings, the original list did NOT get changed, why is that? 1 2 3 4 5
| ArrayList b = new ArrayList(); b.add("hey"); String tester = (String)b.get(0); tester = tester.substring(0,1); System.out.println((String)b.get(0)); |
|
|
|
|
|
25
|
Game Development / Newbie & Debugging Questions / quick ArrayList question
|
on: 2006-02-07 02:23:54
|
is it me or does the get() method return the address of an object instead of a copy of an object like for example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class z { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add(new Bob()); System.out.println("Before Change"); System.out.println( ( (Bob)list.get(0) ).getX() ); Bob testObject = (Bob)list.get(0); testObject.a(); System.out.println("After Change"); System.out.println( ( (Bob)list.get(0) ).getX() ); } } class Bob { private int x =0; public Bob() { } public void a() { x++; } public int getX() { return x; } } |
Considering this code, if testObject is only a copy of whats in get(0), then if i do anything to testObject, wouldn't the element in get(0) stay the same??? but when i execute the code, the element at get(0) becomes changed when I didn't use any set methods at all. Another example with iterator. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public class test { ArrayList a = new ArrayList(); public test() {
a.add(new bob()); } public ArrayList getList() { return a; } } class Bobtester { public static void main(String[] args) { test t = new test(); ArrayList b = t.getList(); Iterator bi = b.iterator(); while(bi.hasNext()) { bob c = (bob)bi.next(); } System.out.println(b); System.out.println(t.getList()); } } class bob { int x=0; public void at() { x++; } public String toString() { return Integer.toString(x); } } |
Basically ArrayList b is suppose to be a copy of ArrayList a, but when I remove each element from ArrayList b, each element is also removed from ArrayList a..........................why is that???
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException
|
on: 2006-02-07 01:44:50
|
|
Ah ok! I understand now why I get this error (after making a few test appliacations),
My code was suppose to put the enemy in a different ArrayList each time he moves, but sometimes he would be in the same arrayList, and therefore adding to the current ArrayList while iterating through it at the same time will cause the error!!
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / Re: ConcurrentModificationException
|
on: 2006-02-06 21:13:30
|
Read the JavaDocs for that method
if you read my first post , i said i already read the java docs but i didnt understand the circumstances for the error to happen. But so i am guessing the error happens BECAUSE im trying to change the arrayList while im iterating through it? am i correct? if that is the case, than whats some options that i could use??? wouldnt a CopyOnWriteArrayList be too slow
|
|
|
|
|
29
|
Game Development / Newbie & Debugging Questions / ConcurrentModificationException
|
on: 2006-02-06 05:19:09
|
I keep getting this error with this code 1 2 3 4 5 6 7 8 9 10 11 12 13
| public boolean attackElement(int arrayIndex, int listIndex, int damage) { ((Enemy)enemyList[ arrayIndex ].get(listIndex) ).attack(damage); if( ( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getHp()<=0) { elementsArray[( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getIdRow()][( (Enemy)enemyList[ arrayIndex].get(listIndex) ).getIdCol()] = null; enemyList[arrayIndex].remove(listIndex); return true; } else return false; } |
what does that mean? I read the definition but i didn't understand it
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|