浏览代码

Added Scene setup logic

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 年前
父节点
当前提交
18869ca359
共有 4 个文件被更改,包括 96 次插入25 次删除
  1. +4
    -0
      test/meshviewer.cpp
  2. +71
    -24
      test/meshviewer_index.html
  3. +19
    -0
      test/scenesetup.js
  4. +2
    -1
      test/type_dictionnary.js

+ 4
- 0
test/meshviewer.cpp 查看文件

@@ -466,6 +466,10 @@ public:
if (m_stream_update_time > .0f)
{
m_stream_update_time = -1.f;
MessageService::Send(MessageBucket::AppIn,
" addlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) \
addlight 0.0 position (8 2 6) color #ffff \
custom setmesh \"[sc#f8f ab 1]\"");
// MessageService::Send(MessageBucket::AppIn, "[sc#f8f ab 1]");
// MessageService::Send(MessageBucket::AppIn, "[sc#f8f ab 1 splt 4 twy 90]");
// MessageService::Send(MessageBucket::AppIn, "[sc#8ff afcb 1 1 1 0]");


+ 71
- 24
test/meshviewer_index.html 查看文件

@@ -88,8 +88,8 @@ progress::-webkit-progress-value

<script type="text/javascript">
//Base data Setup : GLOBAL STYLE
g_div_frame_embed_save = '';
g_div_frame_embed = null;
g_div_frame_embed_save = '';
g_div_frame_embed = null;
g_txtarea_code_src = null;
g_div_helper_cmd = [null, null];
g_div_helper_args = null;
@@ -104,8 +104,12 @@ progress::-webkit-progress-value
//This is the module pointer : can be either the NaCl or Em one depending on the context.
g_embed_module = null;

g_mesh_code_base = "//This is a comment\nsc#f8f afcb 1 1 1 0";
g_scene_code_base = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1) addlight 0.0 position (8 2 6) color #ffff";
var g_mesh_code_base = [];
var CodeDictionnary = [];

g_code_id = 0;
g_mesh_code_base[0] = "//This is a comment\nsc#f8f afcb 1 1 1 0";
g_mesh_code_base[1] = "//This is a comment\naddlight 0.0 position (4 -1 -4) color (.0 .2 .5 1)\naddlight 0.0 position (8 2 6) color #ffff";
function machinchose() { return 'test machin '; }
function GetTextAreaCodeSrc() { return g_txtarea_code_src; }
@@ -121,16 +125,24 @@ function machinchose() { return 'test machin '; }
function GetiFrameDivEmbed() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetDivEmbed()); }
function GetiFrameModuleVar() { return (!g_frame_embed) ? (null) : (g_frame_embed.contentWindow.GetEmbedModule()); }
function IsUsingNaCl() { return window.chrome; }
function GetCmdDictionnary() { return CodeDictionnary[g_code_id]; }
</script>

<script src="./utils.js"></script>
<script src="./progress_status.js"></script>
<script src="./type_dictionnary.js"></script>
<script type="text/javascript">
var EasyMeshDict = new TypeDictionnary("EasyMesh");
function GetCmdDictionnary() { return EasyMeshDict; }
CodeDictionnary[0] = new TypeDictionnary("EasyMesh");
</script>
<script src="./easy_mesh_dictionnary.js"></script>
<script type="text/javascript">
g_code_id = 1;
CodeDictionnary[1] = new TypeDictionnary("EasyMesh");
</script>
<script src="./scenesetup.js"></script>
<script type="text/javascript">
g_code_id = 0;
</script>

<script type="text/javascript">
//Base init for all datas
@@ -160,26 +172,31 @@ function machinchose() { return 'test machin '; }

//Put here any cookie update
if (!g_txtarea_code_src.value)
g_txtarea_code_src.value = g_mesh_code_base;
g_txtarea_code_src.value = g_mesh_code_base[g_code_id];

//Fill the TOC
if (!g_div_alphabet.innerHTML)
{
g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[';
var new_toc = BuildTOC(true);
var pattern = new RegExp("^[a-zA-Z\.]");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "<b>$&");
pattern = new RegExp("[a-zA-Z\.]$");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$&</b>");
pattern = new RegExp("([a-zA-Z])([\.])");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$1</b>$2");
pattern = new RegExp("([\.])([a-zA-Z])");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$1<b>$2");
g_div_alphabet.innerHTML += new_toc + ']&nbsp;<br>&nbsp;';
for (var i = 0; i < CodeDictionnary.length; i++)
{
g_code_id = i;
var new_toc = BuildTOC(true);
var pattern = new RegExp("^[a-zA-Z\.]");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "<b>$&");
pattern = new RegExp("[a-zA-Z\.]$");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$&</b>");
pattern = new RegExp("([a-zA-Z])([\.])");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$1</b>$2");
pattern = new RegExp("([\.])([a-zA-Z])");
while (pattern.test(new_toc))
new_toc = new_toc.replace(pattern, "$1<b>$2");
CodeDictionnary[i].m_alphabet = new_toc;
}
g_code_id = 0;
InitEditValues();
}

//NaCl Specific
@@ -208,6 +225,24 @@ function machinchose() { return 'test machin '; }
CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src);
}

function StoreTextAreaValue()
{
g_mesh_code_base[g_code_id] = GetTextAreaCodeSrc().value;
}

function ExchangeSetup()
{
StoreTextAreaValue();
g_code_id = (g_code_id + 1) % 2;
InitEditValues();
}

function InitEditValues()
{
GetTextAreaCodeSrc().value = g_mesh_code_base[g_code_id];
g_div_alphabet.innerHTML = '&nbsp;Table of content<br>&nbsp;[' + CodeDictionnary[g_code_id].m_alphabet + ']&nbsp;<br>&nbsp;';
}

//Handle message from the NaCl module
function ModuleSentMessage(message)
{
@@ -217,8 +252,11 @@ function machinchose() { return 'test machin '; }
//Called by the "Send Mesh Command !" button
function SendMessageToModule()
{
StoreTextAreaValue();
var message = g_mesh_code_base[1] + ' \n';
message += ' custom setmesh "' + g_mesh_code_base[0] + '"';
if (g_embed_module)
g_embed_module.SendMessage(g_scene_code_base + ' ' + GetTextAreaCodeSrc().value);
g_embed_module.SendMessage(message);
else
alert("Module not loaded !");
}
@@ -244,7 +282,16 @@ function machinchose() { return 'test machin '; }
</div>
</p>

<div><button onclick="SendMessageToModule()">Send Mesh Command !</button></div>
<table border="0" cellpadding="0" cellspacing="0" width="772">
<tr>
<td align="left">
<div><button onclick="SendMessageToModule()">Send Mesh Command !</button></div>
</td>
<td align="right">
<div><button onclick="ExchangeSetup()">Edit Scene Setup.</button></div>
</td>
</tr>
</table>

<table border="0" cellpadding="0" cellspacing="0">
<tr>


+ 19
- 0
test/scenesetup.js 查看文件

@@ -0,0 +1,19 @@
//-------------------------------------------------------------------------
//Command vars operations
//-------------------------------------------------------------------------
CmdVar("[ ]", ["Opens a new context,\nevery operations between the braces\nwill only be done to the vertices added\nsince the start of this context."]);
CmdVar("float", ["Fraction value", "0.0"]);
CmdVar("int", ["No decimal value", "0"]);
CmdVar("bool", ["Boolean value", "true/false", "1/0"]);
CmdVar("color", ["Red/Green/Blue/{Alpha}",
"HEXA: #ABC{D}", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#AABBCC{DD}",
"FLOAT:&nbsp;f f f f", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(f f f f)", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(f)"]);
CmdVar("vec3", ["X/Y/Z as float", "&nbsp;f f f", "(f f f)", "(f)"]);

//-------------------------------------------------------------------------
//scene operations
//-------------------------------------------------------------------------
CmdType(["addlight"], "Add a light to the scene.\nUse other commands after this one to fully setup.", [CmdArg("float", "type")]);
CmdType(["position"], "Set a position.\nWhen put after a light, sets its position.", [CmdArg("vec3", "pos")]);
CmdType(["color"], "Set a color.", [CmdArg("color", "color")]);


+ 2
- 1
test/type_dictionnary.js 查看文件

@@ -1,6 +1,7 @@
function TypeDictionnary(m_name)
{
this.m_name = m_name;
this.m_alphabet = '';
this.m_cmds = new Array();
this.m_vars = new Array();
}
@@ -346,4 +347,4 @@ function CmdLookup(div_cmds, div_args, div_cmnt, div_vars, text_src)
}
}
}
}
}

正在加载...
取消
保存