lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 10, 2011 14:48:34 GMT -5
The colors don't load properly onto this cube. Each side should be a different color, however that isn't what's happening. I suspect lines 214-226 are the cause of the problem. Even though I've looked for a very long time for the problem; there's been no fixing progress. Please help. Press "c" when the image displays to view colors. note: this is a primitive .obj loader, so solutions dealing with specifically creating my own cube in the code with colors can't happen. The cube or object must be loaded from a .obj file. I've attached the zip file to this post, if there's any problems with the program not mentioned above please message me. Attachments:
|
|
|
Post by matthew on May 10, 2011 18:23:30 GMT -5
On line 215 put -1 after the count variable so it looks like this...
if count-1 = val(usemtl(m,0)) and colorstat = 1 then Do the colours look like they should now?
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 11, 2011 16:36:13 GMT -5
Yes! That's it thank you so much once again! I looked at this for almost 2 hrs trying to find out what went wrong with it.
|
|
|
Post by Darkjester on May 11, 2011 21:41:02 GMT -5
this is by far the nicest .obj loader i have seen writtin in basic4gl, one suggestion though you could read the file one time before the allocate the proper memory, and then read it the second time to load it into your arrays, just a suggestion but either way it works the same -darkjester
|
|
|
Post by shadow008 on May 11, 2011 22:15:14 GMT -5
Very nice reading output. Never cared for that on mine. But it actually gives you a heads up on whats going on. You might wanna concider compiling your object into a display list though. I tried loading a file with ~ 10k poly's and the fps counter dropped to about 4.
Also, do what Darkjester suggested. Allocating the proper memory is kinda important.
BTW, you got some random commentation in here. Like at line 301: 's6r4ys6d5f4ga6d5fra4+sdr54a+er84+4864+94767ER%Y^#$@gykifhjesr^Q$%@%&*¿¡«¢„‘¦±¼z I was like WTFIZTHISSHIT? LOL! Now for serious side:
This works for a single .obj file, but what if you have multiple files to load? Try putting your variables into a structure so that multiple objects can be loaded.
Otherwise, Very Nice!
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 12, 2011 15:57:39 GMT -5
You might wanna concider compiling your object into a display list though. I tried loading a file with ~ 10k poly's and the fps counter dropped to about 4. This .obj loader is in the middle stages of development, it only has about half of what should be there. display lists are one of those things that are going to be implemented/object loaded. Allocating the proper memory is kinda important. I feel noobish for asking this, but what does allocate mean? BTW, you got some random commentation in here. Like at line 301: I just quickly added that there before i shutdown the computer, because the q key doesn't do any shutdown routine. Try putting your variables into a structure so that multiple objects can be loaded. This part is hardly difficult, it just involves reading through more files before adding them to the memory. Thanks for the suggestions. My goals for this are: (from most important to least important @ the moment) 1. Define normals and add lighting. 2. Link up multiple textures to materials.(so far only 1 texture works @ a time) 3. Create display lists. 4. Implement shadows. 5. Create a menu where the user can define the file(s) being loaded. 6. Allow the user to place lights into the scene where they want, specify the color of the light, and to specify the direction of the light (if that particular light is directional.) 7. Create a keyboard and mouse format loader/writer that allows the user to specify what keys do what. (all keys interchangeably) Saves key/mouse config for load-up next time 8. Clean up the program. (i.e. clear up messy rem statements, and fix small problems with code.) Although #7 probably isn't even necessary to implement unless you A.) have a laptop (no mouse). or B.) are missing a serious # of keys on your keyboard.
|
|
|
Post by shadow008 on May 13, 2011 10:29:54 GMT -5
Allocate = Dynamic Memory en.wikipedia.org/wiki/Malloc#Dynamic_memory_allocation_in_CRead up. However, be aware that at this time, there is no way to de-allocate memory in Basic4GL, but it uses garbage cleanup, so its freed when you close the program. Basic4GL equivalent of malloc is simply alloc. Heres an example: dim &YourCustomArray() as single dim NumberOfElements as integer = 100
alloc YourCustomArray, NumberOfElements
'EQUIVILANT TO:
dim AnotherCustomArray(100) as single
NOTE: pointer declaration is denoted with the & symbol However, this way does NOT need to have an explicit constant to make the array. It can also be used with as many arrays as you need such as: dim &Pointer()()()()() as single 'a 5 dimensional array alloc Pointer, 3, 3, 3, 10, 60 And thats works the same as: dim Pointer(3)(3)(3)(10)(60) However, i dont see a use for a 5D array... You can free up the variables in the pointer by setting it to NULL like this: 'Allocate your pointer here... &Pointer = NULL 'then re-allocate it the same way as before, but with different variables ALSO NOTE: To free up a pointer at an address, you must denote it with the & sign as like when declaring. Otherwise you get something like a: Left sign cannot be assigned to error, because a variable cannot be set to NULL. Without the & sign, the pointer is treated as a variable. I think that sum's it up nicely... Any questions?
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 13, 2011 19:24:38 GMT -5
So allocate just is another more complex way to say dim? So what Darkjester is saying here: you could read the file one time before the allocate the proper memory, and then read it the second time to load it into your arrays Means he's suggesting that i do something that's already done? (i.e. read through the file to determine the # of elements, and then use that # of elements to determine an array that is to be used for storing all the necessary data in the file) I mean to say doesn't the loadprep subroutine cover the determining of the array sizes by reading the file ahead of time? Aren't those arrays used to store the important data? If that's a yes to both of the above, then why bother with the allocate function if I've just done the same? Is there any benefit to using the Allocate function over dim?
|
|
|
Post by Wayne Rayner on May 13, 2011 21:03:02 GMT -5
ok I'm not sure about this answer because I'm not really a programmer especially in a 3d sense.
Well if you use dim there is no memory allocated to the variables, array and so forth which could cause if loading a complex scene on a older system it could cause a crash because you have run out of virtual memory, other than that there is no reason to use allocate over dim
|
|
|
Post by Supermonkey on May 14, 2011 10:44:08 GMT -5
Basically alloc allows for dynamic memory allocation. Memory allocated with dim is static and can't be resized at runtime.
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 14, 2011 14:40:24 GMT -5
Okay, i did what i should have done first before asking questions. I actually looked at the Basic4gl Language Guide. Their example of Allocate was incorrect by one char
dim &ptrarray () ' Array size is not specified here! alloc ptrarray, 100 ' Specified here instead!
dim &ptrMatrix#()() alloc ptrMatrix, 3, 3
i.e. the # sign.
And looking @ the code i was able to see one way that it could benefit a program. That way would be allowing people to see all the variables (including the arrays that would normally be dimmed later in the code). This in turn would allow for easier understandability for anyone who looked at the program later.
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 14, 2011 22:44:41 GMT -5
Everything was working fine until I loaded a different file that i made called "Sample.obj" Now the colors are messing up again (the still work on 6dc though). I think it has something to do with the amount of materials in the file, but I'm not sure. Basically The same thing is happening as before. Some of the triangles drawn will end up being the wrong color. If there's a way to fix it then the line(s) to be fixed would be somewhere between 352 and 358. here's the link to download: docs.google.com/leaf?id=0B2rqIy25tcEeMjk1ZmEwMmQtMjgwNS00M2E2LWE0MDAtZDUzNGU1ZDdkMDhk&hl=en&authkey=CM_P-pcC (I really wish they'd allow us to post our attachments when using a standard post)
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
Post by lal7777 on May 15, 2011 17:07:35 GMT -5
Okay i finally was able to pinpoint the new/old problem and fix it. the line that says
if count-1 = val(usemtl(m,0)) and colorstat = 1 then
should be
if count-1 >= val(usemtl(m,0)) and colorstat = 1 then
In other-words all i forgot was a > sign
|
|