r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Sunanda
13-Jan-2005
[120]
Thanks for the strict-greater? idea.  I was hoping there was a built-in 
ability somewhere.

One tiny tweak to the function -- you need to restrict the two values 
to series or you can get strange results:
     >> strict-greater? make object! [1] make object! [0]
     == false
     >> greater? make object! [1] make object! [0]
     ** Script Error: Cannot use greater? on object! value
So:

 strict-greater?: func [value1 [series!] value2 [series!]] [(to-binary 
 value1) > (to-
binary value2)]
Ladislav
13-Jan-2005
[121x2]
Infix words are "hard-wired" from the Rebol programmer POV currently
postfix operators aren't reasonable to have, the prefix versus infix 
issues are complicated enough
Geomol
13-Jan-2005
[123]
The infix operators in REBOL can be seen with:
>> ? op!

It's a special corner of REBOL, as I see it. And I don't feel a big 
need to be able to make my own infix operators. There is a funny 
thing with the and, or and xor operators. They have twin and~, or~ 
and xor~ actions. The actions is used like: <action> <value1> <value2>, 
but operators can be used the same way, so the action counterparts 
seem to be irrelevant. Examples:
>> 3 and 9
>> and 3 9
>> and~ 3 9

Why do we have and~, or~ and xor~ made?
Anton
13-Jan-2005
[124]
I suspect that originally, the infix operators weren't also able 
to be used prefix.
Vincent
13-Jan-2005
[125]
One can overload 'and~ 'xor~ 'or~ but should not overload 'and 'xor 
'or.

With form~ we know they are only used in <action> <value1> <value2>, 
and are safe to change.
Ladislav
13-Jan-2005
[126]
I think, that it is an *unsafe* and confusing practice to use infix 
operators as prefix
shadwolf
13-Jan-2005
[127x5]
I have one little thing to ask for my personal knowledge and I hope 
for people to thinks together on a good way to exploit it in REBOL 
to enhance it's capability to interface with DLL or exploit files 
containing memory struct dump:
the thing is how to load or convert a C structure like this and use 
it in REBOL in a approachant way of C (I hope we could find even 
a better way to do it with rebol than in C)
//-------------------------------------------------------------
//- SMD2Header
//- Header for all Md2 files, 
struct SMD2Header
{
   int m_iMagicNum; //Always IDP2 (844121161)
   int m_iVersion;  //8
   int m_iSkinWidthPx;  
   int m_iSkinHeightPx; 
   int m_iFrameSize; 
   int m_iNumSkins; 
   int m_iNumVertices; 
   int m_iNumTexCoords; 
   int m_iNumTriangles; 
   int m_iNumGLCommands; 
   int m_iNumFrames; 
   int m_iOffsetSkins; 
   int m_iOffsetTexCoords; 
   int m_iOffsetTriangles; 
   int m_iOffsetFrames; 
   int m_iOffsetGlCommands; 
   int m_iFileSize; 
};

//-------------------------------------------------------------
//- SMD2Vert
//- Vertex structure for MD2
struct SMD2Vert
{
float m_fVert[3];
unsigned char m_ucReserved;
};


//-------------------------------------------------------------
//- SMD2Frame
//- Frame information for the model file 
struct SMD2Frame
{
float m_fScale[3];
float m_fTrans[3];
char m_caName[16];
SMD2Vert * m_pVerts;

//Cleans up after itself
SMD2Frame()
{
m_pVerts = 0;
}

~SMD2Frame()
{
if(m_pVerts)
delete [] m_pVerts;
}
};

//-------------------------------------------------------------
//- SMD2Tri
//- Triangle information for the MD2
struct SMD2Tri
{
unsigned short m_sVertIndices[3];
unsigned short m_sTexIndices[3];
};

//-------------------------------------------------------------
//- SMD2TexCoord
//- Texture coord information for the MD2
struct SMD2TexCoord
{
float m_fTex[2];
};

//-------------------------------------------------------------
//- SMD2Skin
//- Name of a single skin in the md2 file
struct SMD2Skin
{
char m_caSkin[64];//filename
CImage m_Image;//Image file ready for texturing
};

//-------------------------------------------------------------
//                        CTIMER                              -
// author: Evan Pipho ([evan-:-codershq-:-com])                     -
// date  : Jul 10, 2002                                       -
//-------------------------------------------------------------
class CMd2 : public CModel
{
public:

//Set skin to one of the files specified in the md2 files itself
void SetSkin(unsigned int uiSkin);
//Set skin to a different image
void SetSkin(CImage& skin);

//Load the file
bool Load(const char * szFilename);

//Render file at the initial position
void Render();
//Render the file at a certain frame
void Render(unsigned int uiFrame);


//Animate the md2 model (start and end frames of 0 and 0 will loop 
through the WHOLE model

void Animate(float fSpeed = 30.0f, unsigned int uiStartFrame = 0, 
unsigned int uiEndFrame = 0, bool bLoop = true);

//constructors/destructo
CMd2();
CMd2(const char * szFile);
~CMd2();

private:

CTimer m_Timer;
//file header information
SMD2Header m_Head; 
//Frame information
SMD2Frame * m_pFrames;
//Triangles
SMD2Tri * m_pTriangles;
//Texure coords
SMD2TexCoord * m_pTexCoords;
//Skin files
SMD2Skin * m_pSkins;
//Interpolated vertices
SMD2Vert * m_pVerts;
//Current skin
unsigned int m_uiSkin;
//Using a custom skin?
bool m_bIsCustomSkin;
//The custom skin
CImage * m_pCustSkin;

};
What I would like to achieve is in REBOL:

1) Declaring in REBOL the struct schemes identically as a in the 
C way
2) read the file containing the datas to fill the declared struct
3) attribute to struct the rode data from the file
4)can interact freely with REBOL common fonctions
the main problem I think with this kind of hierarchical and dynamical 
size struct is to be anought performant and close to the original 
to save code writing  time and tu enhance the loading performances 
in such tasks. Actually you need to parse and readapt each data from 
the binary dump file to rebol based   things. And that's an heavy 
task


This can be usefull for all langages that allow binary dump file 
read/wirte like C, VB and many others.
eFishAnt
13-Jan-2005
[132x3]
if that is the struct of the data stored in a file, it should not 
be too hard to parse the file to get the information...looks like 
a 3-D rendering file or ?
my REBOL coding is nearly as good as my C coding...but my C codding 
had a 22 year head start...;-)
coding = codding ... a slip of the fish
Geomol
14-Jan-2005
[135]
shadwolf, it seems, you need some kind of binary format, so external 
data can be loaded directly in to a REBOL structure. Maybe REBin? 
http://www.rebol.net/blogs/0044.html
shadwolf
14-Jan-2005
[136x2]
this structure is the one for MD2 File format it contents vertex 
point position, texture, texture coordinates, frames of animation. 
In MD2 format each animation move is the difference beetwin 2 frame 
content .
the goal is to provide to REBOL the capability to do such a load 
in the simpliest and fastest way I think the posibility of using 
a vectorial data like float myvar[3];
eFishAnt
14-Jan-2005
[138]
is there a site with files I could look at? (just seems there would 
be a very simple way to do this without much problem) sorry I am 
not familiar with md2 (guess the enterprise work distracts me too 
much...;-(
shadwolf
14-Jan-2005
[139]
you can find an example files in MD2 format here-> http://shadwolf.free.fr/hellpig.md2
eFishAnt
14-Jan-2005
[140]
what could I use to view it so I see what it looks like?
shadwolf
14-Jan-2005
[141]
In fact the actual need to support MD2 file format is not requiered 
but We can use such a complicated hierarchical structure to simplify 
in REBOL/Core the C library branchement witch will in reallity very 
important if we want to have the true capabilité to exploite C library 
 that use vectorial dat or vectorial structure based API
eFishAnt
14-Jan-2005
[142x2]
understood.
parsing binary is a bit different than parsing ASCII...and I have 
done a bit for mp4...but I think your point of making it simple is 
a good thing.
shadwolf
14-Jan-2005
[144x4]
To see it you can use the MD2 model viewer http://www.swissquake.ch/chumbalum-soft/md2v/
you need to download too the texture skin image http://shadwolf.free.fr/hellpig.bmp
you open in the modelviewer the hellpig.md2 file and tada you can 
playback the animation
an other way could be to use the MD2 importer script into blender 
but it's not anymore online for the moment (I have a copy of it on 
my local harddrive if you want to test it....)
eFishAnt
14-Jan-2005
[148x2]
ok...I see what it does...cool.
when Josh appears, we will scratch each others heads and see if we 
can determine a way to parse this...he has done some work like this 
for his NASA project...and he is working on some crazy computer science 
parsing algorithms...I think he has been chatting with Ladislav too 
long ... ;-)
Ladislav
14-Jan-2005
[150]
SMD2Header: make struct! [
   m_iMagicNum [int] ; Always IDP2 (844121161)
   m_iVersion  [int] ; 8
   m_iSkinWidthPx [int]  
   m_iSkinHeightPx [int] 
   m_iFrameSize [int]
   m_iNumSkins [int]
   m_iNumVertices  [int]
   m_iNumTexCoords [int]
   m_iNumTriangles [int]
   m_iNumGLCommands [int]
   m_iNumFrames [int]
   m_iOffsetSkins [int]
   m_iOffsetTexCoords [int]
   m_iOffsetTriangles [int]
   m_iOffsetFrames [int]
   m_iOffsetGlCommands [int]
   m_iFileSize [int]
] none
shadwolf
14-Jan-2005
[151x2]
oki if I can apport my own head to help finding the better solution 
to handle this just communicate it to me thrue skype or altme. Than 
we can give our reflexions solution to Carl in order for him to include 
it to core
thank you ladislave for single int variable that's easy (like header) 
but for file content it's ver hard and harder I think to attribute 
to a REBOL struct based pointer the content of the file
Ladislav
14-Jan-2005
[153]
SMD2Vert: make struct! [
    m_fVert1 [float]
    m_fVert2 [float]
    m_fVert3 [float]
    m_ucReserved [char]
] none
shadwolf
14-Jan-2005
[154x2]
struct SMD2Frame
{
float m_fScale[3];
float m_fTrans[3];
char m_caName[16];
SMD2Vert * m_pVerts;

//Cleans up after itself
SMD2Frame()
{
m_pVerts = 0;
}

 this hierarchical structure typical in C is very very very hard to 
 adapt easyly to REBOL or maby I'm to idiot to do it ...
>> a: make object! SMD2Header
** Script Error: Invalid argument: make struct! [
    m_iMagicNum [int]
    m_iVersion [int]
    m_iSkinWidthPx [int]
    m_iSkinHeightPx [int]
    m_iFrameSize [int]
    m_iNumSkins [int]
    m_iNumVertices [int]
    m_iNumTexCoords [int]
    m_iNumTriangles [int]
    m_iNumGLCommands [int]
    m_iNumFrames [int]
    m_iOffsetSkins [int]
    m_iOffsetTexCoords [int]
    m_iOffsetTriangles [int]
    m_iOffsetFrames [int]
    m_iOffsetGlCommands [int]
    m_iFileSize [int]
] [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
Ladislav
14-Jan-2005
[156]
why do you want to make object? - it is a struct
shadwolf
14-Jan-2005
[157x5]
that's not that way it has to be done sorry I made a mistake. It's 
only a: SMD2Header

but in this case you can't have a declaration like SMD2Header *myheader; 
that is the common way to do it in C SMD2Header struct will became 
a type in C, In rebol you only make a pointer to the struct so with 
vectorials struct based array mofifying one data will modify all 
data in the array
example SMD2Vert struct is use to make an aray of vertex position 
for each frame int SMD2Frame struct SMD2Frame Struct is use as type 
to make an array of frames
so MD2 format encapsulate many  Frame as array and all those frames 
encapsulate many Vert that discribe for this frame each location 
of every point of my 3d Model
the we have the posibility to take a bunch of frame for example from 
0 to 10  to say that's  animation set correspond to run
animation
eFishAnt
14-Jan-2005
[162x3]
aha, you give me so many ideas for my editor...
it is sometimes too mind expanding to write code while chatting. 
 Sometimes I think I need a few more heads, and a couple more arms 
to type and click...maybe I should draw a new model of myself.
but I think I would use REBOL blocks rather than some silly C structs. 
 blocks are such flexible containers.
shadwolf
14-Jan-2005
[165]
in my 3D engine I will make a switch to change the animation that 
are into my model that supose for me to have all my 3D model to get 
the identical set of animation or to make animation switch that could 
be adapted to every 3D Model Type (that's why 3D engeneers not even 
more use this format and prefert bone animation based file format 
like MDL or MD3/MD5)
eFishAnt
14-Jan-2005
[166]
aha...a datatype-sensitive editor...see, I should close down the 
right side of my brain so the left side can type code easier.
shadwolf
14-Jan-2005
[167x3]
for example if I say walk is frame 0 10 for human but for aliens 
in my game I nead to have only frames 0 to 5 for the walk I need 
to make 2 animation list and 2 animation switches to handle human 
(main caracter of my game for example) and alien
If i have alien type 1 alien type 2 alien type 3 etc... and all of 
them with different set of animation it could be very heavy task 
to handle all of them using MD2 but that's not our purpose in fact 
 :)
data-type sensitive editor  but normally rebol is datatype unsensive 
 :)