|
COLLADA
Nov 15, 2011 15:16:22 GMT -5
Post by shadow008 on Nov 15, 2011 15:16:22 GMT -5
Forums are quiet -_- So I guess I could inform you that I've recently started writing a COLLADA (.dae) file reader. Going strictly on what I've seen from it, its like an "all in one" file type. It exports absolutely everything I need: 3D Models, UV Mapping, Shader Specifications, Bone Weights, Skeletal Animation Data... But mostly animation that can be done on the GPU (Because we know how well B4GL does on the CPU )... Basically everything I need to start writing a full sized 3D engine. The biggest problem is that this file is HUGE AND DENSE! If anyone wants to discuss a possibly better option before I completely commit to this, please speak quickly. If you wanna help out on this, drop me a message. I'm pretty sure this and the tons of shaders I wanna write are the only things left to do... I'll keep things posted. I project this taking at least a month or two to get right/perfect. Happy Coding! GL HF!
|
|
|
COLLADA
Nov 16, 2011 23:33:04 GMT -5
Post by matthew on Nov 16, 2011 23:33:04 GMT -5
I know from experience in the past Basic4GL does take some time to load large files. How big can these COLLADA files be?
|
|
|
COLLADA
Nov 17, 2011 15:21:49 GMT -5
Post by shadow008 on Nov 17, 2011 15:21:49 GMT -5
2000 polygon file (Read JUST line for line) with 4 different textures/shaders, 14 armatures with vertex weights, and 10 frames of animation took 11 seconds to read on my computer...
Thats not too terribly bad : \
To answer your question: I'm actually not sure how big they can be though. I should probably test that to find out how bad loading times could be (I'm going to be the pessimist here, so I don't get disappointed)
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
COLLADA
Nov 18, 2011 4:51:15 GMT -5
Post by lal7777 on Nov 18, 2011 4:51:15 GMT -5
Question: why isn't there a version of B4gl that uses GPU instead of CPU?
|
|
|
COLLADA
Nov 18, 2011 14:51:38 GMT -5
Post by shadow008 on Nov 18, 2011 14:51:38 GMT -5
Answer: There is. DJLinux made the GLSL/CG/ARB Shader plugins just for that purpose. You should look into those. And I don't think you realize what the GPU is. The GPU's SOLE PURPOSE is for graphic related computations. Its the processor inside the graphics card (or integrated chip). It doesn't "talk" to the CPU other than taking data from it, which doesn't go both ways. There are 3 parts the programmer has to worry about when using the GPU: The vertex shader, the fragment (or pixel) shader, and the most recent installment; the geometry shader. For now, B4GL only has the vertex and fragment shader via one of the three plugins mentioned above (most recommended is GLSL). Honestly, programming shaders to test on 3d models are surprisingly fun ^_^ You can do all sorts of various effects with them. I am going to be integrating them with my COLLADA loader for the very obvious graphical effects, and also to do bone animation. Just by passing the weights and transformed bone matricies, I can (hopefully) do fully GPU sided animation that doesn't suffer from B4GL's problem of being an interpreted language; therefore, not being as efficient on the CPU. Fun times That was probably overkill for your question but oh well... Back to coding.
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
COLLADA
Nov 24, 2011 14:12:49 GMT -5
Post by lal7777 on Nov 24, 2011 14:12:49 GMT -5
"I don't think you realize what the GPU is."~Shadow008 I do know what GPU is, however I thought that display lists use it. You claim that B4gl uses only CPU, which led to my question of why it wasn't made to use GPU which is a LOT faster.
|
|
|
COLLADA
Nov 24, 2011 15:13:40 GMT -5
Post by DJLinux on Nov 24, 2011 15:13:40 GMT -5
|
|
lal7777
Posts
if all.knowledge = orange then: seed = mankind.knowledge: grow(seed,time): endif
Posts: 88
|
COLLADA
Nov 29, 2011 11:06:27 GMT -5
Post by lal7777 on Nov 29, 2011 11:06:27 GMT -5
When I tired your links it led me to a page that said "Could not initialise WebGL, sorry :-("
|
|
|
COLLADA
Nov 29, 2011 11:39:18 GMT -5
Post by angros47 on Nov 29, 2011 11:39:18 GMT -5
Some browsers don't support WebGL (i.e. Microsoft Explorer doesn't)
Most recent Firefox and Chrome support WebGL, so, if you are using explorer, you should install either chrome or firefox; if you already have one of them, just upgrade it to the last version.
|
|
|
COLLADA
Jan 27, 2012 23:49:58 GMT -5
Post by shadow008 on Jan 27, 2012 23:49:58 GMT -5
HiHi I iz back with a "completed" FILE loader (theres probably bugs). Yes sir, it only parses the file and retrieves what I deem as worthy. There is one slight problem... A larger file will EXPONENTIALLY increase the load time I have narrowed the problem down to the function I use to parse individual strings, namely "GetFloat()" It takes in the HUGE string I read in, and does some heavy stuff on it to see where the next number is. If you would like to take a look at it: dl.dropbox.com/u/5319168/COLLADA%20Loader.zipNow the commented out line in the main file page is the smaller file, while the other is the big file. The smaller file takes about 200 milliseconds to read in. The larger one took ~193 SECONDS to read. And MOST of the time spend reading in the file is in the Geometry library. Which led me to check that out, which led me to the conclusion that my line parsing algorithm is REALLY DAMN INEFFICIENT So now the other option I have is read character by character... But I'm reallllly not sure how to handle tags that way. Ehh... So if anyone has suggestions, solutions, hax, software duct-tape, it would be really appreciated. I cant really start on part 2 of this until part 1 takes < 20 seconds start to finish, otherwise that's TOO long of a time to wait
|
|
|
COLLADA
Jan 28, 2012 6:19:09 GMT -5
Post by matthew on Jan 28, 2012 6:19:09 GMT -5
The only help I could really give is searching on Google. A quick search for Collada Loader does bring up a few useful links to some Open Source Loaders that people have already made. Such as ColladaLoader or Assimp. You could try looking at the Source for them & seeing if it helps.
|
|
|
COLLADA
Jan 28, 2012 10:00:54 GMT -5
Post by DJLinux on Jan 28, 2012 10:00:54 GMT -5
Your code is really slow my XML reader in Basic4GL is much faster tested with file: "TestModel2.dae". (150 seconds vs. 25 seconds)
Joshy
|
|
|
COLLADA
Jan 28, 2012 18:43:02 GMT -5
Post by shadow008 on Jan 28, 2012 18:43:02 GMT -5
Where can I obtain this XML reader? Or is it even open source?
|
|
|
COLLADA
Jan 31, 2012 15:23:53 GMT -5
Post by shadow008 on Jan 31, 2012 15:23:53 GMT -5
Alright, I got the read time down from 196000ms (average) to around 800ms on the larger file. MUCH better. And the reason was because B4GL is rather slow trying to parse large strings... Simple as that. Not only does my newer method work INSURMOUNTABLY faster, but it doesn't cause the crashes mentioned in my other thread.
^_^
|
|
|
Post by DJLinux on Feb 3, 2012 8:29:42 GMT -5
xml.inc
' ##################### ' # simple XML parser # ' ##################### const DEBUG% = 1
type XML_ATTRIBUTE_T Name as string Value as string end type const XML_ATTRIBUTES = 16 const XML_VALUES = 65000 type XML_LINE_T Prefix as string nAttributes as integer Attributes(XML_ATTRIBUTES-1) as XML_ATTRIBUTE_T nValues as integer Values(XML_VALUES) as string Terminator as string end type dim XMLLine as XML_LINE_T
sub ConsoleStatus(msg$,condition%) printr msg$ if (condition%=FALSE) then end end if end sub
' parse a XML line function NextXMLLine(hFile as integer) as integer XMLLine.Prefix ="" XMLLine.nAttributes=0 XMLLine.Terminator ="" XMLLine.nValues=0 dim Line as string dim Part as string dim EOF as integer dim l as integer while (L=0) LAND (EOF=0) EOF=EndOfFile(hFile) if (EOF<>0) then return FALSE:end if Line = ReadLine(hFile) l=len(Line) wend dim c as string dim i as integer = 1 ' move to prefix while (c<>"<") LAND (i<l) c=mid$(Line,i,1):i=i+1 wend if (i=l) then ConsoleStatus("error: no XML prefix !",FALSE) return FALSE end if c=mid$(Line,i,1):i=i+1 ' get prefix while (c<>" ") LAND (c<>">") LAND (i<=l) Part=Part+c:c=mid$(Line,i,1):i=i+1 wend XMLLine.Prefix=lcase$(Part)
' simple prefix without pairs of attributes if c=">" then XMLLine.Terminator=">" return TRUE end if
' get all atributes c=mid$(Line,i,1):i=i+1 while (c<>"?") LAND (c<>"/") LAND (c<>">") LAND (i<l) ' ignore spaces while (c=" "):c=mid$(Line,i,1):i=i+1:wend ' get name of attribute Part="" while (c<>"=") Part=Part+c c=mid$(Line,i,1):i=i+1 wend XMLLine.Attributes(XMLLine.nAttributes).Name=ucase$(Part) ' get value of attribute while (c<>chr$(34)):c=mid$(Line,i,1):i=i+1:wend c=mid$(Line,i,1):i=i+1 Part="" while (c<>chr$(34)) Part=Part+c c=mid$(Line,i,1):i=i+1 wend XMLLine.Attributes(XMLLine.nAttributes).Value=Part XMLLine.nAttributes=XMLLine.nAttributes+1 ' get next char c=mid$(Line,i,1):i=i+1 wend if c="/" then XMLLine.Terminator="/>":i=i+1 elseif c="?" then XMLLine.Terminator="?>":i=i+1 elseif c=">" then XMLLine.Terminator=">" else ConsoleStatus("error: wrong XML line terminator !", FALSE) return FALSE end if ' get optional values from XML line if (i<l) then while (i<l) ' ignore spaces c=mid$(Line,i,1):i=i+1 while (c=" "):c=mid$(Line,i,1):i=i+1:wend Part="" while (i<l) LAND (c<>" ") LAND (c<>"<") Part=Part+c c=mid$(Line,i,1):i=i+1 wend XMLLine.Values(XMLLine.nValues)=Part XMLLine.nValues=XMLLine.nValues+1 if (c="<") then return TRUE:end if wend end if return TRUE end function
simple test
include XML.inc
const FILNAME$ = "Models/TestModel2.dae" dim hFile = OpenFileRead(FILNAME$) if hFile<1 then printr "error: open " + FILNAME$ + " !" beep():input$():end end if dim i printr "start reading " + FILNAME$ dim Time# = PerformanceCounter() while NextXMLLine(hFile)=TRUE
wend Time# = (PerformanceCounter() - Time#)/1000 CloseFile(hFile)
Print "File read in " + Time# + " seconds" more complex test:
include XML.inc
const FILNAME$ = "Models/TestModel2.dae" dim hFile = OpenFileRead(FILNAME$) if hFile<1 then printr "error: open " + FILNAME$ + " !" beep():input$():end end if dim i
while NextXMLLine(hFile)=TRUE if XMLLine.nAttributes>0 then for i=0 to XMLLine.nAttributes-1 printr XMLLine.Attributes(i).Name + "=" + XMLLine.Attributes(i).Value next end if if XMLLine.nValues>0 then for i=0 to XMLLine.nValues-1 printr XMLLine.Values(i) next end if wend
|
|