Skip to content

Commit f33006a

Browse files
committed
Parse pass tokens.
1 parent 3f6b119 commit f33006a

File tree

2 files changed

+148
-1
lines changed

2 files changed

+148
-1
lines changed

engine/model/model_mda.cpp

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ bool chr::MDAModel::ParseProfile( Profile &profile, std::stringstream &ss )
211211
{
212212
ss.ignore( std::numeric_limits< std::streamsize >::max(), '\n' );
213213
}
214+
else if ( token == "evaluate" )
215+
{
216+
if ( !( ss >> token ) )
217+
{
218+
Com_Printf( "Expected expression after 'evaluate!\n" );
219+
return false;
220+
}
221+
222+
profile.evaluation = token;
223+
profile.evaluation.erase( std::remove( profile.evaluation.begin(), profile.evaluation.end(), '\"' ),
224+
profile.evaluation.end() );
225+
}
214226
else if ( token == "skin" )
215227
{
216228
if ( !( ss >> token ) || token != "{" )
@@ -315,6 +327,139 @@ bool chr::MDAModel::ParsePass( Pass &pass, std::stringstream &ss )
315327

316328
pass.map = GL_FindImage( token.c_str(), it_skin );
317329
}
330+
else if ( token == "alphafunc" )
331+
{
332+
if ( !( ss >> token ) )
333+
{
334+
Com_Printf( "Expected type after 'alphafunc'!\n" );
335+
return false;
336+
}
337+
338+
if ( token == "gt0" ) { pass.alpha = Pass::AlphaFunc::GT0; }
339+
else if ( token == "ge128" ) { pass.alpha = Pass::AlphaFunc::GE128; }
340+
else if ( token == "lt128" ) { pass.alpha = Pass::AlphaFunc::LT128; }
341+
else
342+
{
343+
Com_Printf( "Unknown alphafunc type (%s)!\n", token.c_str() );
344+
}
345+
}
346+
else if ( token == "rgbgen" )
347+
{
348+
if ( !( ss >> token ) )
349+
{
350+
Com_Printf( "Expected type after 'rgbgen'!\n" );
351+
return false;
352+
}
353+
354+
if ( token == "none" ) { pass.rgb = Pass::RGBGen::NONE; }
355+
else if ( token == "identity" ) { pass.rgb = Pass::RGBGen::IDENTITY; }
356+
else if ( token == "diffusezero" ) { pass.rgb = Pass::RGBGen::DIFFUSE_ZERO; }
357+
else if ( token == "ambient" ) { pass.rgb = Pass::RGBGen::AMBIENT; }
358+
else
359+
{
360+
Com_Printf( "Unknown rgbgen type (%s)!\n", token.c_str() );
361+
}
362+
}
363+
else if ( token == "blendmode" )
364+
{
365+
if ( !( ss >> token ) )
366+
{
367+
Com_Printf( "Expected type after 'blendmode'!\n" );
368+
return false;
369+
}
370+
371+
if ( token == "none" ) { pass.blend = Pass::BlendMode::NONE; }
372+
else if ( token == "normal" ) { pass.blend = Pass::BlendMode::NORMAL; }
373+
else if ( token == "multiply" ) { pass.blend = Pass::BlendMode::MULTIPLY; }
374+
else if ( token == "add" ) { pass.blend = Pass::BlendMode::ADD; }
375+
else
376+
{
377+
Com_Printf( "Unknown blend mode (%s)!\n", token.c_str() );
378+
}
379+
}
380+
else if ( token == "cull" )
381+
{
382+
if ( !( ss >> token ) )
383+
{
384+
Com_Printf( "Expected type after 'cull'!\n" );
385+
return false;
386+
}
387+
388+
if ( token == "none" ) { pass.cull = Pass::CullMode::NONE; }
389+
else if ( token == "front" ) { pass.cull = Pass::CullMode::FRONT; }
390+
else if ( token == "back" ) { pass.cull = Pass::CullMode::BACK; }
391+
else
392+
{
393+
Com_Printf( "Unknown cull mode (%s)!\n", token.c_str() );
394+
}
395+
}
396+
else if ( token == "uvgen" )
397+
{
398+
if ( !( ss >> token ) )
399+
{
400+
Com_Printf( "Expected type after 'uvgen'!\n" );
401+
return false;
402+
}
403+
404+
if ( token == "sphere" ) { pass.uvgen = Pass::UVGen::SPHERE; }
405+
else
406+
{
407+
Com_Printf( "Unknown uvgen mode (%s)!\n", token.c_str() );
408+
}
409+
}
410+
else if ( token == "uvmod" )
411+
{
412+
if ( !( ss >> token ) )
413+
{
414+
Com_Printf( "Expected type after 'uvmod'!\n" );
415+
return false;
416+
}
417+
418+
if ( token == "scroll" )
419+
{
420+
pass.uvMod = Pass::UVMod::SCROLL;
421+
if ( !( ss >> pass.uvModScroll.x >> pass.uvModScroll.y ) )
422+
{
423+
Com_Printf( "Expected 'x y' after 'scroll'!\n" );
424+
return false;
425+
}
426+
}
427+
else
428+
{
429+
Com_Printf( "Unknown uvmod mode (%s)!\n", token.c_str() );
430+
}
431+
}
432+
else if ( token == "depthfunc" )
433+
{
434+
if ( !( ss >> token ) )
435+
{
436+
Com_Printf( "Expected type after 'depthfunc'!\n" );
437+
return false;
438+
}
439+
440+
if ( token == "none" ) { pass.depth = Pass::DepthFunc::NONE; }
441+
else if ( token == "equal" ) { pass.depth = Pass::DepthFunc::EQUAL; }
442+
else if ( token == "less" ) { pass.depth = Pass::DepthFunc::LESS; }
443+
else
444+
{
445+
Com_Printf( "Unknown depthfunc mode (%s)!\n", token.c_str() );
446+
}
447+
}
448+
else if ( token == "depthwrite" )
449+
{
450+
if ( !( ss >> token ) )
451+
{
452+
Com_Printf( "Expected value after 'depthwrite'!\n" );
453+
return false;
454+
}
455+
456+
if ( token == "1" ) { pass.depthWrite = true; }
457+
else if ( token == "0" ) { pass.depthWrite = false; }
458+
else
459+
{
460+
Com_Printf( "Unknown depthwrite mode (%s)!\n", token.c_str() );
461+
}
462+
}
318463
else
319464
{
320465
Com_Printf( "Unknown token (%s), ignoring!\n", token.c_str() );

engine/model/model_mda.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace chr
5151
LESS,
5252
};
5353
DepthFunc depth{ DepthFunc::NONE };
54+
bool depthWrite{};
5455

5556
enum class UVGen
5657
{
@@ -64,7 +65,8 @@ namespace chr
6465
NONE,
6566
SCROLL,
6667
};
67-
UVMod uvmod{ UVMod::NONE };
68+
UVMod uvMod{ UVMod::NONE };
69+
Vector2 uvModScroll{};
6870

6971
enum class RGBGen
7072
{

0 commit comments

Comments
 (0)