﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-日出</title><link>http://www.cppblog.com/flipcode/</link><description>编我故事角色，写我每段插曲
flipcode@qq.com</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 09:37:23 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 09:37:23 GMT</pubDate><ttl>60</ttl><item><title>开放世界</title><link>http://www.cppblog.com/flipcode/archive/2021/07/03/217729.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Sat, 03 Jul 2021 12:35:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2021/07/03/217729.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217729.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2021/07/03/217729.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217729.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217729.html</trackback:ping><description><![CDATA[<div>我的开放世界, wow一样大的地图</div>
<br />
<img width="1024" height="576" alt="" src="http://www.cppblog.com/images/cppblog_com/flipcode/lara_1.jpg" border="0" /><br />
<br />
<img width="1024" height="576" alt="" src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20210703203605_1.jpg" border="0" /><br />
<img width="1024" height="576" alt="" src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20210703222041_1.jpg" border="0" /><br />
<img width="1024" height="576" alt="" src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20210703203626_1.jpg" border="0" /><br />
<img width="1024" height="576" alt="" src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20210703205227_1.jpg" border="0" />
<img src ="http://www.cppblog.com/flipcode/aggbug/217729.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2021-07-03 20:35 <a href="http://www.cppblog.com/flipcode/archive/2021/07/03/217729.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>云雾修改</title><link>http://www.cppblog.com/flipcode/archive/2020/04/02/217224.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Thu, 02 Apr 2020 03:48:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/04/02/217224.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217224.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/04/02/217224.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217224.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217224.html</trackback:ping><description><![CDATA[云雾的作法很多，现在常用的是raymarching步进的方法。这里我用了另一个方案（类似视差贴图的实现，算法这位道友写的很清楚:<a href="https://zhuanlan.zhihu.com/p/83355147">https://zhuanlan.zhihu.com/p/83355147</a>）<br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/cloud3.png" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/fog.png" alt="" /><img src ="http://www.cppblog.com/flipcode/aggbug/217224.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-04-02 11:48 <a href="http://www.cppblog.com/flipcode/archive/2020/04/02/217224.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>云雾效果</title><link>http://www.cppblog.com/flipcode/archive/2020/03/27/217217.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Fri, 27 Mar 2020 10:07:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/03/27/217217.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217217.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/03/27/217217.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217217.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217217.html</trackback:ping><description><![CDATA[<img src="http://www.cppblog.com/images/cppblog_com/flipcode/cloud.png" alt="" /><br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/fogplane2.png" alt="" /><br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/fogplane3.png" alt="" /><br /><br />深度雾可以在后期处理通过深度图反算得到世界坐标， 然后再用位置减去水平面位置，再除雾距得到雾化比进行处理。<br />不用后期也可以，直接摆放渲染平面，然后在shader中用当前平面深度减去深度图深度，再除雾距得到雾化比进行处理。上图就是这种方式实现的载图，对应shader如下：<br /><br /><div><span style="white-space:pre">		</span>void vertexDataFunc( inout appdata_full v, out Input o )</div><div><span style="white-space:pre">		</span>{</div><div><span style="white-space:pre">			</span>UNITY_INITIALIZE_OUTPUT( Input, o );</div><div><span style="white-space:pre">			</span>UNITY_TRANSFER_DITHER_CROSSFADE( o, v.vertex );</div><div></div><div><span style="white-space:pre">			</span>float2 tex_pos;</div><div><span style="white-space:pre">			</span>tex_pos.x = v.vertex.x;</div><div><span style="white-space:pre">			</span>tex_pos.y = v.vertex.z;</div><div></div><div><span style="white-space:pre">			</span>float rnd = sin(_Time.y*0.01f) + cos(_Time.y*0.01f)*10;</div><div><span style="white-space:pre">			</span>o.wavecoord = float4(tex_pos + rnd, tex_pos*2.0 + rnd);</div><div><span style="white-space:pre">		</span>}</div><div></div><div><span style="white-space:pre">		</span>void surf( Input i , inout SurfaceOutputStandard o )</div><div><span style="white-space:pre">		</span>{</div><div><span style="white-space:pre">			</span>//UNITY_APPLY_DITHER_CROSSFADE(i);</div><div><span style="white-space:pre">			</span>float _ScrollSpeed = 0.7f;</div><div><span style="white-space:pre">			</span>fixed scrollValue = fixed2(_ScrollSpeed * sin(_Time.y), _ScrollSpeed * sin(_Time.y));</div><div><span style="white-space:pre">			</span>fixed4 c = tex2D(_MainTex, i.wavecoord.xy);</div><div><span style="white-space:pre">			</span>o.Albedo = c.rgb * _FogColor.rgb;</div><div></div><div><span style="white-space:pre">			</span>o.Emission = _FogColor.rgb;</div><div><span style="white-space:pre">			</span>float4 ase_screenPos = float4( i.screenPos.xyz , i.screenPos.w + 0.00000001 );</div><div><span style="white-space:pre">			</span>float eyeDepth = LinearEyeDepth(UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture,UNITY_PROJ_COORD(ase_screenPos))));</div><div><span style="white-space:pre">			</span>float clampResult = clamp((abs((<div style="display: inline-block;">eyeDepth</div> - ase_screenPos.w)) * (0.1f+ _FogIntensity * 0.4f)), 0, _FogMaxIntensity);</div><div><span style="white-space:pre">			</span>o.Alpha = clampResult;</div><div><span style="white-space:pre">		</span>}<br />另外迷雾太大，无法看清游戏，可以让相机拉远显示迷雾，靠近则让迷雾变淡处理，简单地将_FogMaxIntensity修改下即可:<br />_FogMaxIntensity = _FogMaxIntensity * pow(ase_screenPos.w * 0.01f, 3);</div><img src ="http://www.cppblog.com/flipcode/aggbug/217217.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-03-27 18:07 <a href="http://www.cppblog.com/flipcode/archive/2020/03/27/217217.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>类似三国志14中hexagon的贴地绘制</title><link>http://www.cppblog.com/flipcode/archive/2020/03/26/217215.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Thu, 26 Mar 2020 12:55:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/03/26/217215.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217215.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/03/26/217215.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217215.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217215.html</trackback:ping><description><![CDATA[<img src="http://www.cppblog.com/images/cppblog_com/flipcode/hexdraw.png" alt="" /><br />有很多实现方案， 有人会想着用贴花去做，其实很没必要，一种廉价又简单的方式可以实现：将ps当前位置转换到hexagon的uv空间再采样hexagon贴图即可， 即在地表绘制的ps中（或在后处理里），取得（或通过深度求得）世界位置并减去当前位置所在格子中心点的世界位置，得到相对格子的偏移，然后再转为uv坐标。那么hexagon的属性怎么得到？用另一张point贴图在cpu中修改后传入给shader即可(以上图片中所示就是我用的这种方式实现的样例)。<img src ="http://www.cppblog.com/flipcode/aggbug/217215.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-03-26 20:55 <a href="http://www.cppblog.com/flipcode/archive/2020/03/26/217215.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>hexagon箭头绘制</title><link>http://www.cppblog.com/flipcode/archive/2020/03/26/217214.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Thu, 26 Mar 2020 12:33:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/03/26/217214.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217214.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/03/26/217214.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217214.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217214.html</trackback:ping><description><![CDATA[三国志14在寻路时可以显示出所行走路径，思考了下，可以用以下方式做到:<br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/pathType.png" alt="" /><br />实现方式:<br /><div>// uv=x,y, rotation = z</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public static readonly kPathArrow[,] combineType =</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 右上，右上&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;右，&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;右下，&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;左下，&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;左，&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 左上</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(0, 60), new kPathArrow(5, 180),&nbsp; &nbsp; new kPathArrow(2, 180), new kPathArrow(6, 120), new kPathArrow(7, 0), new kPathArrow(3, 0)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 右</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(5, 180), new kPathArrow(1, 180),&nbsp; &nbsp; new kPathArrow(4, 180), new kPathArrow(7, 180), new kPathArrow(6, 0), new kPathArrow(8, 180)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 右下</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(2, 180), new kPathArrow(4, 180),&nbsp; &nbsp; new kPathArrow(0, 180), new kPathArrow(3, 180), new kPathArrow(8, 0), new kPathArrow(6, 60)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 左下</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(6, 120), new kPathArrow(7, 180),&nbsp; &nbsp; new kPathArrow(3, 180), new kPathArrow(0, -120), new kPathArrow(5, 0), new kPathArrow(2, 0)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 左</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(7, 0), new kPathArrow(6, 0),&nbsp; &nbsp; new kPathArrow(8, 0),&nbsp; &nbsp; new kPathArrow(5, 0), new kPathArrow(1, 0), new kPathArrow(4, 0)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 左上</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {new kPathArrow(3, 0), new kPathArrow(8, 180),&nbsp; &nbsp;new kPathArrow(6, 60), new kPathArrow(2, 0), new kPathArrow(4, 0), new kPathArrow(0, 0)},</div><div>&nbsp; &nbsp; &nbsp; &nbsp; };</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; private Vector3 RotVertex(Vector3 point, float rot)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 pos = point;</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float cs = Mathf.Cos(rot);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float sn = Mathf.Sin(rot);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos.x = point.x * cs + point.z * sn;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos.z = -point.x * sn + point.z * cs;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return pos;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; //----------------------------------------------------------------------------------------------</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public void AddPathTile(int x, int z, int idx)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int enterDir = idx / (int)kHexGrid.HexDirection.MAX;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int outDir = idx % (int)kHexGrid.HexDirection.MAX;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; kPathArrow pathArrow = combineType[enterDir, outDir];</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int rowUV = pathArrow.idx / 3;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int colUV = pathArrow.idx % 3;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float rot = pathArrow.angle * Mathf.PI/180.0f;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 center = kHexGrid.ToWorldPos(x, z);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector2 centerUV = new Vector2(0.5f, 0.5f);</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector2 uvStart = new Vector2(colUV * 1 / 3.0f, rowUV * 1 / 3.0f);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (kHexGrid.HexDirection dir = kHexGrid.HexDirection.NE; dir &lt;= kHexGrid.HexDirection.NW; dir++)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 v1 = center + new Vector3(0,0.01f,0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 v2 = kHexGrid.cornerPos[(int)dir] + new Vector3(0, 0.01f, 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 v3 = kHexGrid.cornerPos[(int)dir + 1] + new Vector3(0, 0.01f, 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (rot &gt; 0.0001f || rot &lt; -0.0001f)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v2 = RotVertex(v2, rot);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; v3 = RotVertex(v3, rot);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AddTriangle(v1, center + v2, center + v3,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uvStart + centerUV * 1/3.0f, uvStart + kHexGrid.cornerUV[(int)dir] * 1 / 3.0f, uvStart + kHexGrid.cornerUV[(int)dir + 1] * 1 / 3.0f,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Color.white);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div>丑图效果:<br /><br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/hexagonarrow.png" alt="" />所用贴图<img src="http://www.cppblog.com/images/cppblog_com/flipcode/pathArrow.png" width="512" height="512" alt="" /><img src ="http://www.cppblog.com/flipcode/aggbug/217214.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-03-26 20:33 <a href="http://www.cppblog.com/flipcode/archive/2020/03/26/217214.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>max练习</title><link>http://www.cppblog.com/flipcode/archive/2020/01/09/max.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Thu, 09 Jan 2020 02:35:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/01/09/max.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217072.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/01/09/max.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217072.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217072.html</trackback:ping><description><![CDATA[<img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly1.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly2.jpg" alt="" width="512" height="288" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly3.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly5.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly6.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly7.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly8.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly9.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly10.jpg" width="512" height="288" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/poly11.jpg" width="512" height="288" alt="" /><img src ="http://www.cppblog.com/flipcode/aggbug/217072.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-01-09 10:35 <a href="http://www.cppblog.com/flipcode/archive/2020/01/09/max.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>自己建模场景</title><link>http://www.cppblog.com/flipcode/archive/2020/01/09/max_unity.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Thu, 09 Jan 2020 01:59:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/01/09/max_unity.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217071.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/01/09/max_unity.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217071.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217071.html</trackback:ping><description><![CDATA[<div>自己用max建模弄的一个小场景，感觉基本够用了，记录下<img src="http://www.cppblog.com/images/cppblog_com/flipcode/arpg_model.png" alt="" /></div><img src ="http://www.cppblog.com/flipcode/aggbug/217071.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-01-09 09:59 <a href="http://www.cppblog.com/flipcode/archive/2020/01/09/max_unity.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>unity slg的方形和六边形测试</title><link>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_slg.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Fri, 03 Jan 2020 10:09:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_slg.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217059.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_slg.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217059.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217059.html</trackback:ping><description><![CDATA[<div>unity slg的方形和六边形测试, 其中主要是坐标转换，下面是我自己想出来的一种比较简便高效的处理方法，实现方法如下:<br /><div></div><div>&nbsp; &nbsp;</div><div>&nbsp; &nbsp; // 记录下: 这是我看图总结出的比较简便的算法:)(flipcode@qq.com)：</div><div>&nbsp; &nbsp; &nbsp; &nbsp; // 注意，传入的xWorld要/edgeLength</div><div>&nbsp; &nbsp; &nbsp; &nbsp; public static Vector2 ToHexGrid(float xWorld, float yWorld)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float edgeLength = 1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float halfGridWidth = edgeLength * 0.866025404f;</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iGY = (int)(yWorld / (1.5 * edgeLength));</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool odd = ((iGY &amp; 1) != 0);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 奇：</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (odd)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xWorld -= halfGridWidth;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int iGX = (int)(xWorld / (2 * halfGridWidth));</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 得到格子左下角坐标:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float OGX = iGX * (2 * halfGridWidth);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float OGY = iGY * (1.5f * edgeLength);</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float refX = OGX + halfGridWidth;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float refY = OGY + edgeLength * 0.5f;</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 可能不在本格子内(因为可能位置在格格子下方的左下角或右下角):</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool bOutProbably = yWorld &lt; refY;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (bOutProbably)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 得到Hex中心往下半个外边长的位置:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float dx = Mathf.Abs(xWorld - refX) * (0.5f * edgeLength / halfGridWidth); // 乘( ../.. )使其变成正方形再来判断</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float dy = Mathf.Abs(yWorld - refY);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float dt = dx + dy;</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 在左半边:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (xWorld &lt; refX)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 不在本格子,而是在左下角:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dt &gt; edgeLength * 0.5f)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iGY--; // 不管奇偶，下部都要y--</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 如果是偶数的左下，还要将x--</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (false == odd)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iGX--;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 在右半边</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 不在本格子, 而是在右下角:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (dt &gt; edgeLength * 0.5f)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iGY--; // 不管奇偶，下部都要y--</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// 如果是奇数的右下，还要将x++</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (odd)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iGX++;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return new Vector2(iGX, iGY);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div></div><div></div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; public static Vector3 ToWorldPos(int iGX, int iGY)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool odd = ((iGY &amp; 1) != 0);</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 得到格子左下角坐标:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float OGX = iGX * (2 * halfGridWidth);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float OGY = iGY * (1.5f * edgeLength);</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 奇数行要右移半个宽度：</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (odd)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OGX += halfGridWidth;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 偏移转到格子中心位置:</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector3 pos = new Vector3(OGX + halfGridWidth, 0, OGY + edgeLength);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return pos;\</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }<br /><br />下面是我画的图，非常丑，将就看<br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/slg示意图.png" alt="" /><br />b附上测试图，已带ai移动攻击, 不过图看不到:<img src="http://www.cppblog.com/images/cppblog_com/flipcode/slggrid.png" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/slg6a.png" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/slg666.png" alt="" /></div></div><img src ="http://www.cppblog.com/flipcode/aggbug/217059.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-01-03 18:09 <a href="http://www.cppblog.com/flipcode/archive/2020/01/03/unity_slg.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>unity lwrp</title><link>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_lwrp.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Fri, 03 Jan 2020 10:01:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_lwrp.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/217058.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2020/01/03/unity_lwrp.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/217058.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/217058.html</trackback:ping><description><![CDATA[将我的u3d demo改用轻量管线来弄了下，加了点后期处理<br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/postprocess.png" width="930" height="534" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/postprocess1.png" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20191115184709.png" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20191115185105.png" alt="" /><img src ="http://www.cppblog.com/flipcode/aggbug/217058.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2020-01-03 18:01 <a href="http://www.cppblog.com/flipcode/archive/2020/01/03/unity_lwrp.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>u3d中程序生成树</title><link>http://www.cppblog.com/flipcode/archive/2019/10/29/216959.html</link><dc:creator>flipcode</dc:creator><author>flipcode</author><pubDate>Tue, 29 Oct 2019 08:20:00 GMT</pubDate><guid>http://www.cppblog.com/flipcode/archive/2019/10/29/216959.html</guid><wfw:comment>http://www.cppblog.com/flipcode/comments/216959.html</wfw:comment><comments>http://www.cppblog.com/flipcode/archive/2019/10/29/216959.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flipcode/comments/commentRss/216959.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flipcode/services/trackbacks/216959.html</trackback:ping><description><![CDATA[实现方式是生成了一个二叉树，设定了深度及随机阀值（到达则生成叶子），原理在nv的一个古老的例子: texturemask<br /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20191029100008.png" width="573" height="570" alt="" /><img src="http://www.cppblog.com/images/cppblog_com/flipcode/QQ图片20191029161151.png" width="743" height="328" alt="" /><img src ="http://www.cppblog.com/flipcode/aggbug/216959.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flipcode/" target="_blank">flipcode</a> 2019-10-29 16:20 <a href="http://www.cppblog.com/flipcode/archive/2019/10/29/216959.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>