This site requires JavaScript, please enable it in your browser!
Greenfoot back

Comments for 3D Model File Loader

Return to 3D Model File Loader

JetLennitJetLennit

2013/4/28

What kinds of 3D files does it use
DutaDuta

2013/4/28

.obj files
JetLennitJetLennit

2013/4/28

Then how is the Overlay a png?
DutaDuta

2013/4/28

Overlay is just an image for the start text. The actual 3D file is called "head.obj", if you look in the project folder you'll find it.
You should rework your file loading to use URL paths and BufferedReaders so that it can work on the gallery as well. The method I use in castle storm II uses this method and it works quite nicely!
A new version of this scenario was uploaded on Sun Apr 28 09:39:01 UTC 2013 Now works on the gallery too! (I hope)
DutaDuta

2013/4/28

Yeah, not sure why I forgot to do that - that's my go-to method of loading files normally. Anyway, I've done it and it works.
MatheMagicianMatheMagician

2013/4/28

@Duta, is it alright I used two lines of your code for my filereader? Mine did not let me play the scenario on the site, but the FileStream seems to work fine.
DutaDuta

2013/4/28

Of course! The entire idea for mine is from yours. I've found a little bug, which I'm about to get round to fixing - it might affect yours too, I haven't checked. I've also added a lot of stuff, which will all come in the next update (just need to track down this pesky bug first).
A new version of this scenario was uploaded on Sun Apr 28 16:13:59 UTC 2013 +Colors, +Menu, +Code redesign, +List of models, +More comments. The house model is kinda bugged at the moment, in that the colours on the underside of the roof seem to keep switching. I really need to go revise, and so don't have time to work it out. If anyone looks through the code and finds the reason, I'll be really grateful.
DutaDuta

2013/4/28

To add to what I said in the update text, if anyone works out why the colours in the house are slightly bugged, I'll say in the description that you're freakin' awesome. But yeah, I have to go revise.
MatheMagicianMatheMagician

2013/4/28

In your sorting method, when the edges get to the side, the top roof seems to be closer, which means its color is drawn over the edge color, causing the problem.
MatheMagicianMatheMagician

2013/4/28

Basically, the problem is with your sorting method. Sorting stuff like this is hard :(
MatheMagicianMatheMagician

2013/4/28

Is this using the mtl files, or are you just choosing the colors in the code?
A new version of this scenario was uploaded on Sun Apr 28 17:59:23 UTC 2013 +Keyboard/mouse control! +Removal of house model, because it was bugged and not even particularly interesting.
DutaDuta

2013/4/28

Yeah, I realized that was the case, which meant I removed it from the scenario. The problem was mainly caused by there being really large polygons, which are hard to sort (especially using the naive z-sorting algorithm I'm doing at the moment). At the moment the colours are completely random. I'm going to get around to adding support for the .mtl files / textures and stuff soon. I'm quite happy with the keyboard/mouse control :)
MatheMagicianMatheMagician

2013/4/28

That's what I was talking about. "Concave" objects (where two sides bend inward) are bug-prone with 3-D programming.
MatheMagicianMatheMagician

2013/4/28

The keyboard and mouse control is good. I created some controls for my other 3d scenarios, but haven't implemented them yet.
A new version of this scenario was uploaded on Sun Apr 28 19:49:19 UTC 2013 +Added two more models.
A new version of this scenario was uploaded on Sun Apr 28 21:06:51 UTC 2013 +Support for materials. I extended the file parser to have some basic support for materials. Only diffuse colour is used at the moment, and there's a lot more I should add. Hence, a model's specular/ambient colours are ignored. Because my models have large sections that are the same colour, I've added in some very basic shading so that you can see the individual faces differentiated slightly. This helps to keep the 3D feel.
JetLennitJetLennit

2013/4/28

I made the face crash while turning it
A new version of this scenario was uploaded on Sun Apr 28 21:17:03 UTC 2013 Better cube model.
A new version of this scenario was uploaded on Sun Apr 28 21:18:46 UTC 2013 Crash fix.
DutaDuta

2013/4/28

Fixed that crash JetLennit
DutaDuta

2013/4/28

(Thanks for reporting it!)
JetLennitJetLennit

2013/4/28

No problem =)
A new version of this scenario was uploaded on Sun Apr 28 21:25:00 UTC 2013 +Different head material, +Changed the shading intensity. Done for tonight, I think.
A new version of this scenario was uploaded on Sun Apr 28 21:28:12 UTC 2013 +Different head material, +Changed the shading intensity. Done for tonight, I think.
SPowerSPower

2013/9/15

Although this example doesn't have it, would it also be possible to load objects with textures instead of colors?
Alan_cAlan_c

2016/5/24

I'm getting parsing errors such as..... Error while parsing "f 19/46/5 25/45/5 26/47/5 21/48/5" in the file "models/Grave.obj". The file may not have parsed correctly. Error while parsing "f 21/48/5 26/47/5 5/8/5 2/7/5" in the file "models/Grave.obj". The file may not have parsed correctly. Error while parsing "f 17/49/5 16/50/5 23/51/5 27/52/5" in the file "models/Grave.obj". The file may not have parsed correctly. Error while parsing "f 27/52/5 23/51/5 3/10/5 8/9/5" in the file "models/Grave.obj". The file may not have parsed correctly............... I'm trying to use a model i've created but keep getting these error could you possibly help me out understand what i'm doing wrong looking at the code it says it has something to do with the faces if it starts with "f". Thanks very much in advance
RidicolasRidicolas

2016/11/25

how did you import the 3d models?