📄 howto.txt
字号:
identity matrix)
Note: If you need to use this function, you have to define the constant in
file rendbead.cpp (SLOT_USE_USER_DEFINED_MATRIX). It is undefined by default.
- glSetObjectSlotScaleVar (slotno, anim, scale);
where: anim is the instance animation structure
slotno is the object slot number (start from 0)
scale is the object scale
Use this function to define the object scale (default to 1)
- glSetObjectSlotAnimVar (slotno, anim, slotanim);
where: anim is the instance animation structure
slotno is the object slot number (start from 0)
slotanim is the instance animation structure for the object
Use this function to define the animation structure (default to none)
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
11. Dynamic Vertex:
This is a feature to animate vertex.
Functions available for runtime:
- GLObjectData *glGetDetailObject (objectID);
return the pointer to the most detail object or 0 if object is not loaded.
- GLint glResetDynamicVertex (object, instance, index);
Use this function to copy the original vertices to instances. If index is not
specified, all dynamic vertices will be copied.
return 0 if object is not loaded.
- GLvertex *glGetDynamicVertex (instance, index);
return the pointer to the coordinate of dynamic vertex
- void glSetDynamicVertex (instance, index, vertex);
Set the dynamic vertex. If vertex is specified, it will be copied to instance.
Note:
object is pointer to object returned by glGetDetailObject
instance is pointer to instance data
index is the dynamic vertex index in dynamic vertex table
vertex is pointer to vertex
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
III. ANimation Script
- Each ANS file must have Data block, Init block, and Code block in that order.
- ANS file has a similar syntax to 'C' language.
- // is comment. All characters that come after // in the current line will be
ignored.
- Characters are not case sensitive --> ANSCode is equal to anscode, etc
- Space character is ignored.
ANS limitations:
- Limited error checking. It is performed for syntax checking only.
- can only have 1 assignment per statement. i.e: a = b = 0; won't work!
- only int and float data type are supported
- exponent (E or e) is not supported
- limited instructions
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
1. ANS file format:
---------------
Data Block format:
-----------------
ANSVar { <-- data begin
... <-- data declaration
} <-- data end
Data can only be declared as a 'int' or a 'float'. Data can also be declared
as array type.
i.e.:
int var1, var2;
int var3[10]; // array of 10 int variables
float var4, var5;
...etc
Init Block format:
-----------------
ANSInit { <-- init begin
... <-- initialize data if necessary
} <-- init end
Code Block format:
-----------------
ANSCode { <-- code begin
... <-- code
} <-- code end
Special ANS keywords:
--------------------
rotl --> rotate bit to the left
Usage: rotl (value, count)
--> will return value rotate to the left count time
i.e.: rotl (1, 8) --> return 256
rotr --> rotate bit to the right
Usage: rotr (value, count)
--> will return value rotate to the right count time
i.e.: rotr (256, 8) --> return 1
time --> get the current time (1000 = 1 sec)
exit --> jump to the end of code
DisableScript --> disable the animation script
ResetVertex --> Initialized the instance dynamic vertex data
If no parameter is passed, this function will initialized all dynamic vertex
i.e.: ResetVertex (); --> Initialized all dynamic vertices
ResetVertex (0); --> Initialized the first element of dynamic vertex
GetX, GetY, GetZ --> will retrieve the current value of the dynamic vertex
Usage: GetX (index) --> return the X value of vertex[index]
SetX, SetY, SetZ --> will set the value of the dynamic vertex
Usage: SetX (index, X) -> set the X value of vertex[index] to X
GetCode --> Get the value of certain flag
GetCode parameter currently supported:
0 -- check colormode
i.e.: GetCode (0) will return 0 if colormode is not in 'Green Mode'. It will
return 1 if colormode is in 'Green Mode'.
SwitchArray --> Switch array, each element has a 32-bit mask where each bit
represents the child of the switch. If the bit value is 0, the child will be
skipped. If the value of the bit is 1, the child will be processed as usual.
Note:
- The bit is stored from right to left.
- SwitchArray index starts from 0
DOF arrays --> use as the input to generate DOF matrix
DOFRotate = pitch angle (16384 = 360 deg)
DOFTranslate = x (east = positive x) translation
Note:
- DOF arrays index starts from 0
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
2. ANS examples:
------------
example #1: Degree Of Freedom animation sample
----------
ANSVar {
int starttime; // variable to hold the animation started time
float currenttime; // must be defined in float to avoid overflow
}
ANSInit {
starttime = time; // set the start time
}
ANSCode {
currenttime = time - starttime; // get time difference
// Set the pitch angle of the first DOF element
DOFRotate[0] = currenttime * 16.384; // rotate 360 deg/sec
}
example #2: Switch animation sample
----------
ANSVar {
int mask, rotflag, starttime;
float currenttime;
}
ANSInit {
rotflag = 0; // default use rotate right
mask = 0x000c0000; // only turn on object #19 and #20
SwitchArray[0] = mask;
starttime = time;
}
ANSCode {
currenttime = time - starttime;
if (currenttime > 250) { // Do this every 0.25 seconds
if (rotflag == 0) { // rotate bit to the right
mask = rotr (mask, 2);
if (mask == 0xc0000000) {
rotflag = 1;
mask = 0x00000003;
}
}
else {
mask = rotl (mask, 2);
if (mask == 0x00300000) {
rotflag = 0;
mask = 0x000c0000;
}
}
// Set the current mask to the first SwitchArray element
SwitchArray[0] = mask;
starttime = time; // reset time
}
}
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
3. ANS language reference:
----------------------
ANS keywords:
ANSVar
ANSInit
ANSCode
else
exit
float
if
int
rotl
rotr
time
DisableScript
GetCode
SwitchArray
ResetVertex
GetX
GetY
GetZ
SetX
SetY
SetZ
DOFArray: one of the following
DOFRotate
DOFTranslate
ANS operators: * / % & | ^ + - << >> >>>
*= /= %= &= |= ^= += -= <<= >>= >>>=
++ -- ~ = < <= > >= == != !
ANS punctuators: ; { } ( ) [ ]
Note:
----
& = and --> 0xffff & 0xff = 0xff
| = or --> 0xff00 | 0xff = 0xffff
^ = xor --> 0xffff ^ 0xff = 0xff00
~ = complement --> ~0xffff = 0xffff0000
% = modulus --> 10 % 7 = 3
<< = shift left
>> = shift right
>>> = shift unsigned right
! = logical not
The following notation is used:
[digit](0) = 0 or more occurences of digits are allowed
[digit](1) = 1 or more occurences of digits are allowed
A | B | C = choose one of A, B, or C
ANSVar {
[declaration](0)
}
ANSInit {
[statement](0)
}
ANSCode {
[statement](0)
}
declaration
int declarationvar ;
or float declarationvar ;
declarationvar
declarationvar , declarationvar
or identifier
or identifier [ constant ]
statement
{ statement }
or expression ;
or expression
expression
term = expression
or term + term
or term - term
or term += term
or term -= term
term
term1 & term1
or term1 | term1
or term1 ^ term1
or term1 << term1
or term1 >> term1
or term1 >>> term1
or term1 &= term1
or term1 |= term1
or term1 ^= term1
or term1 <<= term1
or term1 >>= term1
or term1 >>>= term1
term1
factor * factor
or factor / factor
or factor % factor
or factor *= factor
or factor /= factor
or factor %= factor
factor
( expression )
or if ( condition ) statement
or if ( condition ) statement else statement
or - factor
or ~ factor
or ++ factor
or -- factor
or factor ++
or factor --
or identifier [ constant ]
or identifier [ identifier ]
or identifier
or constant
or DOFArray [ constant ]
or DOFArray [ identifier ]
or SwitchArray [ constant ]
or SwitchArray [ identifier ]
or time
or exit
or DisableScript
or rotl ( factor , factor )
or rotr ( factor , factor )
or GetCode ( factor )
or ResetVertex ()
or ResetVertex ( factor )
or GetX ( factor )
or GetY ( factor )
or GetZ ( factor )
or SetX ( factor , factor )
or SetY ( factor , factor )
or SetZ ( factor , factor )
condition
logicalexpression
or ! logicalexpression
or expression < expression
or expression > expression
or expression <= expression
or expression >= expression
or expression == expression
or expression != expression
identifier
nondigit [nondigit | digit](0)
nondigit
a | b | ... | z | A | B | ... | Z
digit
0 | 1 | ... | 9
hexdigit
0 | 1 | ... | 9 | A | B | C | D | E | F
constant
floatingpoint
or integer
or hexinteger
floatingpoint
digitsequence . digitsequence
or digitsequence .
digitsequence
[digit](1)
integer
digit [digit](0)
hexinteger
0x hexdigit [hexdigit](0)
0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -