Maya烘培入Unity教程

1,给你的模型打上你需要的灯光,添加贴图材质等等..

2,渲染你的场景,比如用Mental Ray,你喜欢用什么就用什么.

3,选择所有物体并使用”Mesh->Combine”命令.然后给这些物体打开”Create UVs->Automatic Mapping”,进行展UV操作.打开”Window->UV Texture Editor”并检查用于烘培的新的UV.

4,切换到”Rendering”工具栏,并且确保你要渲染的物体是被选择的,打开”Texture/Lighting->Batch Bake(mental ray)”对话框,并用如下的设置,然后点击”Convert and close”:

Objects to bake: Selected
Bake to: Texture // IMPORTANT
Bake shadows: checked // IMPORTANT
Keep original shading network: checked // IMPORTANT
Use bake set override: checked // IMPORTANT
Color mode: light and color // IMPORTANT
Normal direction: surface front // IMPORTANT
Prefix: myLightmap // IMPORTANT this will be the filename of the lightmap TIFF, pick a name you like
X resolution: 2048 // depends on the size of the object usually 2048 is plenty, try various values
Y resolution: same value as “X resolution”
File format: TIFF // others work to as long as Unity can import them
Bits per channel: 8 bits // IMPORTANT
Number of samples: 1
Bake to one map: checked // IMPORTANT
UV range: Normal [0 to 1] // IMPORTANT, other settings lead to distorted maps
Fill texture seams: 3 // IMPORTANT, this is the bleed area in pixels around each UV shape to avoid jaggy edges later in Unity
Override mesh UV assignments: checked
UV set name: Lightmap

5,Maya将帮你渲染出Lightmap(根据你设置的分辨率和渲染选项不同可能消耗比较长的时间),这个图不会在Maya中显示,这个文件看起来会像下面这种:

9,保存场景和切换到Unity,找到Lightmap并导入到Unity中.默认路径”user/[your username]/documents/maya/projects/[maya project name]/renderData/mentalray/lightMap/[prefix].tiff”,选择你的模型,更改材质为”Lightmapped”,并将tiff格式的烘培图文件赋予给它,搞定!

原文:http://forum.unity3d.com/viewtopic.php?t=9606
威阿翻译,转载请注明来处1Vr.Cn

多维材质模型烘培入Unity教程

1,这里我有两个对象(装饰物和沙发),你能看见,一共有8张贴图(7张装饰物的贴图,一张沙发贴图).

2,展UVW设置通道为1并点击保存.

3,用第一个通道的UV来展通道2的UVW.

4,打开烘培图选项,选择”Output into Source”和”Keep Baked Materials”,这个选项将自动更新你原来的材质球而且不使用壳材质.点击”0″键打开烘培窗口.

5,效果如下:

6,按下M键打开材质对话框,查看新烘培的材质,在”Self Illumination Slot”中你能看到现在是Lightmap图.导出为Fbx文件.

7,打开Unity并且导入这个模型因为3dsmax中用了8张贴图,所以Unity将给模型赋予8个材质,lightmap贴图不能随着到如今来.手动从3dsmax文件夹导入光影图.名字是模型名与Lightingmap结尾.本例中有2个烘培图,分别是sofaLightingMap.TGA, and wallLightingMap.TGA.

8,将我们所有的材质都赋予好,现在改变默认材质为”Lightmapped”.我选择”Lighmapped/VertexLit”,然后把对应的烘培图赋予对应的材质.

9,好了,烘培图放置正确!效果还不错吧!

原文:http://forum.unity3d.com/viewtopic.php?t=24665
威阿翻译,转载请注明1Vr.Cn

3dsmax烘培导入Unity中小教程.

1,当你给模型UVW处理完后保存UV为*.uvw文件.

2,创建一个新的uvw并改变它的通道为2.载入你刚才创建的uvw文件,当你用automatic uvw时候,它会给你更好的效果.

3,按下”0″键打开render to texture对话框.选择”Use Existing Channel”,改变通道为”2″,选择添加”Lightingmap”.

4,预览窗口看到的图片不是最终的,实际图片在你选择的保存目录中,通常在”My Documents/3dsmax/sceneassets/images”下.名称和你所选择的物体名相同并有”LightingMap”标志的类型为TGA的文件.

5,打开材质球对话框,用”Pick Material from Object”并复制”Pick Material from Object”到一个空的材质球中,因为*.fbx导出器目前还不支持”Shell Material”.

6,完成后将这个新材质球赋予你的模型,导出这个模型为fbx格式,本例中用cm单位,勾选了embed texture.

7,当你打开你的Unity项目并导入这个模型,你仅能看到只导入了diffuse贴图.而没有LightMap贴图.我的方法是把Lightmap贴图复制添加到这个模型的fbm目录中.

8,将Shader改为Lightmapped,并将Lightmap贴图拖拽到空位处.完成了!

原文:http://forum.unity3d.com/viewtopic.php?t=24665
威阿翻译,转载注明来处1Vr.Cn

Unity公司介绍

基本概况
Unity技术公司主要开发革命性游戏开发工具Unity,能创造高质量的3D互动内容-包括视频游戏,模拟训练,医疗和建筑可视化,同样也可以应用于网络,移动设备和游戏机的开发.

使命
让游戏开发民主化,让人人都可以创造高品质的3D互动作品!

部门分布
丹麦的旧金山,立陶宛和英国等都有办事处.

创办人
大卫黑尔加松(首席执行官)
尼古拉斯弗朗西斯(内容总监)
约阿希姆安特(首席技术官)

客户
有超过130K个注册用户,包含Bigpoint, Cartoon Network, Coca-Cola, Disney, Electronic Arts, LEGO, Microsoft, NASA, Panasonic, Ubisoft, Warner Bros等等大的,小的工作室,独立的开发人员,学生和业余爱好者.想看他们开发了什么,到Unity游戏展示名单吧(http://unity3d.com/gallery/game-list/),

财务与增长

Unity技术公司是一个在美国除掉税收外由50%由私人控股的公司;非游戏相关收入占1/3,其他大部分收入来自像Facebook和MySpace和iPhone–近1000个Unity制作的游戏在AppStore上线,在收费排行榜或者是最高票房游戏上10%-20%都是Unity制作的游戏,像Skee-Ball, Ravensworld: The Fallen King 和 Zombieville USA.

奖项与荣誉

2010年
Unity技术公司被信息周刊称为”最有吸引力的公司”.
Unity技术公司入围旧金山商业时报科技创新企业家奖.
游戏”Max & the Magic Marker”在游戏开发者大会(GDC)获得玩家玩次数最多的游戏奖.
客户D2团队被评为Launcher Dogs:March order 和 Emplace training应用程序在游戏技术的DoD游戏比赛上获得新技术新革新称号.

2009年
Unity技术公司被Gamasutra评为本年度前五的游戏公司之一.
Unity技术公司是一个开始记入游戏杂志”技术革命”的公司.

产品
Unity, Unity Pro, Asset Server, iPhone, iPhone Pro

最广泛的平台支持
目前:iPhone/iPod Touch/iPad, Mac, PC, Web, Wii, Xbox 360
即将:Android, PlayStation3

时间线:
2010
五月:Unity Web Player每月安装量200万以上,而且仍在增长.现在总装机量达到3000万.
五月:Unity安装超过25万,每月都回有30000新装用户,而且逐月在增长,增长率约为15%.
四月:EA出品Tiger Woods Online.
二月:Unity用户超过100000!

2009
Unite ’09开发者会议上推出免费版.
公司规模扩大三倍.
红杉资本将550万美元投资给David Gardner 和 Diane Green.红杉资本是一个非常著名的投资公司,投资过如苹果,EA,Google和NVIDIA.
David Gardner:EA前任Co-Founder和Atari的CEO.
Diane Greene:VMware的创始人和前任CEO.

2008:Unity iPhone推出
2007:Unity 2.0推出
2005:Unity 1.0推出
2001:Unity开始开发!

转载请注明来处1Vr.Cn

邮件:Unity iPhone 1.7完美支持iPad!

本月初,Unity公司发布了Unity iPhone 1.7,在这次更新中含有一个非常重要而且令人兴奋的功能.和往常一样,这样小版本你的更新免费更新给已经购买Unity的人.这个新版提供了苹果最新设备iPad的支持的开发!

新功能特点:

支持iPad发布
开发者现在可以选择为iPhone开发也可以为iPad开发.

iPad模拟器的支持
新版本增加了iPad公司模拟器的支持,即使你没有iPad硬件设备,你也可以开发iPad的应用程序.

支持通用的应用程序

你可以使用Unity iPhone建立通用的应用程序,使你的应用程序可以自动在iPad,iPhone,iPod-touch上工作.

如果你想看其他的新改进,你可以访问:http://unity3d.com/unity/whats-new/iphone-1.7.再次提醒你,这次更新针对购买了Unity的朋友是免费更新的,只要下载新的版本,就可以开始使用新功能!

关于苹果iPhone OS4的一些话

大多数人都已经知道,苹果公司为iPhone OS4推出了新的服务条款(TOS),有一些Unity用户比较关注它.虽然现在我们还没有一个明确的声明,但是我们已经联系到了苹果公司并进行了友好的会谈,而且很明显,这个条款不是针对Unity的.我们也会继续努力,确保符合遵守新的条款.虽然确保遵守新的条款可能要我们再做出其他额外的工作,我们还会努力做好,我们承诺的目标是提供不间断的兼容TOS的工具,你和我们都相信Unity将能做到这一点.

如果你想留意我们官方对这件事情的最新进展,请留意我们公司的博客,并查看我们的首席执行官大卫黑尔加松的博客:http://blogs.unity3d.com/author/david/,我们要感谢所有人的耐心,而且我们也知道这次工作的不确定性,但我们会尽一切努力,确保取得好的成果!

感谢大家使用Unity,祝福大家一切都好!

Unity中雷达效果的制作

想给你游戏中增加个雷达么?Unity中可以很容易增加一个雷达.就像下面这样.当然.你可以让美术把雷达做的更好看一些.

将下面的脚本放在一个游戏对象上,给”blip”设置一个纹理.相当于雷达的信号效果.选择一个纹理作为雷达的背景(radarBG),设置地图在屏幕上的位置,设置一个游戏对象用于你雷达的centerObject(通常是目前的玩家对象).确保所有的”敌人”的标签tag都是”Enemy”.之后你就可以在你的游戏中看到雷达了.

两种语言任选其一.


@script ExecuteInEditMode()
// radar! by PsychicParrot, adapted from a Blitz3d script found in the public domain online somewhere ..

//Modified by Dastardly Banana to add radar size configuration, different colors for enemies in different states (patrolling or chasing), ability to move radar to either one of 9 preset locations or to custom location.

//some lines are particular to our AI script, you will need to change "EnemyAINew" to the name of your AI script, and change "isChasing" to the boolean within that AI script that is true when the enemy is active/can see the player/is chasing the player.

var blip : Texture; // texture to use when the enemy isn't chasing
var blipChasing : Texture; //When Chasing
var radarBG : Texture;

var centerObject : Transform;
var mapScale = 0.3;
var mapSizePercent = 15;

var checkAIscript : boolean = true;
var enemyTag = "Enemy";

enum radarLocationValues {topLeft, topCenter, topRight, middleLeft, middleCenter, middleRight, bottomLeft, bottomCenter, bottomRight, custom}
var radarLocation : radarLocationValues = radarLocationValues.bottomLeft;

private var mapWidth : float;
private var mapHeight : float;
private var mapCenter : Vector2;
var mapCenterCustom : Vector2;

function Start () {
    setMapLocation();  
}

function OnGUI () {
//  GUI.matrix = Matrix4x4.TRS (Vector3.zero, Quaternion.identity, Vector3(Screen.width / 600.0, Screen.height / 450.0, 1));

    // Draw player blip (centerObject)
    bX=centerObject.transform.position.x * mapScale;
    bY=centerObject.transform.position.z * mapScale;  
    GUI.DrawTexture(Rect(mapCenter.x - mapWidth/2,mapCenter.y-mapHeight/2,mapWidth,mapHeight),radarBG);
    
    // Draw blips for Enemies
    DrawBlipsForEnemies();
    
}
  
function drawBlip(go,aTexture){
    
    centerPos=centerObject.position;
    extPos=go.transform.position;
    
    // first we need to get the distance of the enemy from the player
    dist=Vector3.Distance(centerPos,extPos);
    
    dx=centerPos.x-extPos.x; // how far to the side of the player is the enemy?
    dz=centerPos.z-extPos.z; // how far in front or behind the player is the enemy?
    
    // what's the angle to turn to face the enemy - compensating for the player's turning?
    deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y;
    
    // just basic trigonometry to find the point x,y (enemy's location) given the angle deltay
    bX=dist*Mathf.Cos(deltay * Mathf.Deg2Rad);
    bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);
    
    bX=bX*mapScale; // scales down the x-coordinate so that the plot stays within our radar
    bY=bY*mapScale; // scales down the y-coordinate so that the plot stays within our radar
    
    if(dist<=mapWidth*.5/mapScale){
        // this is the diameter of our largest radar circle
       GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,4,4),aTexture);

    }

}

function DrawBlipsForEnemies(){
    //You will need to replace isChasing with a variable from your AI script that is true when     the enemy is chasing the player, or doing watever you want it to be doing when it is red on    the radar.
    
    //You will need to replace "EnemyAINew with the name of your AI script
    
    // Find all game objects tagged Enemy
    var gos : GameObject[];
    gos = GameObject.FindGameObjectsWithTag(enemyTag);

    var distance = Mathf.Infinity;
    var position = transform.position;

    // Iterate through them and call drawBlip function
    for (var go : GameObject in gos)  {
          var blipChoice : Texture = blip;
          if(checkAIscript){
                var aiScript : EnemyAI = go.GetComponent("EnemyAI");
            if(aiScript.isChasing)
                    blipChoice = blipChasing;
        }
        drawBlip(go,blipChoice);
    }

}

function setMapLocation () {
    mapWidth = Screen.width*mapSizePercent/100.0;
    mapHeight = mapWidth;

    //sets mapCenter based on enum selection
    if(radarLocation == radarLocationValues.topLeft){
        mapCenter = Vector2(mapWidth/2, mapHeight/2);
    } else if(radarLocation == radarLocationValues.topCenter){
        mapCenter = Vector2(Screen.width/2, mapHeight/2);
    } else if(radarLocation == radarLocationValues.topRight){
        mapCenter = Vector2(Screen.width-mapWidth/2, mapHeight/2);
    } else if(radarLocation == radarLocationValues.middleLeft){
        mapCenter = Vector2(mapWidth/2, Screen.height/2);
    } else if(radarLocation == radarLocationValues.middleCenter){
        mapCenter = Vector2(Screen.width/2, Screen.height/2);
    } else if(radarLocation == radarLocationValues.middleRight){
        mapCenter = Vector2(Screen.width-mapWidth/2, Screen.height/2);
    } else if(radarLocation == radarLocationValues.bottomLeft){
        mapCenter = Vector2(mapWidth/2, Screen.height - mapHeight/2);
    } else if(radarLocation == radarLocationValues.bottomCenter){
        mapCenter = Vector2(Screen.width/2, Screen.height - mapHeight/2);
    } else if(radarLocation == radarLocationValues.bottomRight){
        mapCenter = Vector2(Screen.width-mapWidth/2, Screen.height - mapHeight/2);
    } else if(radarLocation == radarLocationValues.custom){
        mapCenter = mapCenterCustom;
    }
    
}

using UnityEngine;
using System.Collections;

public class Radar : MonoBehaviour
{

    public enum RadarTypes : int {Textured, Round, Transparent};
    public enum RadarLocations : int {TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight, Left, Center, Right, Custom};
    
    // Display Location
    public RadarLocations radarLocation = RadarLocations.BottomCenter;
    public Vector2 radarLocationCustom;
    public RadarTypes radarType = RadarTypes.Round;
    public Color radarBackgroundA = new Color(255, 255, 0);
    public Color radarBackgroundB = new Color(0, 255, 255);
    public Texture2D radarTexture;
    public float radarSize = 0.20f;  // The amount of the screen the radar will use
    public float radarZoom = 0.60f;
    
    // Center Object information
    public bool   radarCenterActive;
    public Color  radarCenterColor = new Color(255, 255, 255);
    public string radarCenterTag;
    
    // Blip information
    public bool   radarBlip1Active;
    public Color  radarBlip1Color = new Color(0, 0, 255);
    public string radarBlip1Tag;

    public bool   radarBlip2Active;
    public Color  radarBlip2Color = new Color(0, 255, 0);
    public string radarBlip2Tag;

    public bool   radarBlip3Active;
    public Color  radarBlip3Color = new Color(255, 0, 0);
    public string radarBlip3Tag;

    public bool   radarBlip4Active;
    public Color  radarBlip4Color = new Color(255, 0, 255);
    public string radarBlip4Tag;
    
    // Internal vars
    private GameObject _centerObject;
    private int        _radarWidth;
    private int        _radarHeight;
    private Vector2    _radarCenter;
    private Texture2D  _radarCenterTexture;
    private Texture2D  _radarBlip1Texture;
    private Texture2D  _radarBlip2Texture;
    private Texture2D  _radarBlip3Texture;
    private Texture2D  _radarBlip4Texture;

    // Initialize the radar
    void Start ()
    {
        // Determine the size of the radar
        _radarWidth = (int)(Screen.width * radarSize);
        _radarHeight = _radarWidth;
        
        // Get the location of the radar
        setRadarLocation();

        // Create the blip textures
        _radarCenterTexture = new Texture2D(3, 3, TextureFormat.RGB24, false);
        _radarBlip1Texture = new Texture2D(3, 3, TextureFormat.RGB24, false);
        _radarBlip2Texture = new Texture2D(3, 3, TextureFormat.RGB24, false);
        _radarBlip3Texture = new Texture2D(3, 3, TextureFormat.RGB24, false);
        _radarBlip4Texture = new Texture2D(3, 3, TextureFormat.RGB24, false);
        
        CreateBlipTexture(_radarCenterTexture, radarCenterColor);
        CreateBlipTexture(_radarBlip1Texture, radarBlip1Color);
        CreateBlipTexture(_radarBlip2Texture, radarBlip2Color);
        CreateBlipTexture(_radarBlip3Texture, radarBlip3Color);
        CreateBlipTexture(_radarBlip4Texture, radarBlip4Color);
        
        // Setup the radar background texture
        if (radarType != RadarTypes.Textured)
        {
            radarTexture = new Texture2D(_radarWidth, _radarHeight, TextureFormat.RGB24, false);
            CreateRoundTexture(radarTexture, radarBackgroundA, radarBackgroundB);
        }
        
        // Get our center object
        GameObject[] gos;
        gos = GameObject.FindGameObjectsWithTag(radarCenterTag);
        _centerObject = gos[0];
    }
    
    // Update is called once per frame
    void OnGUI ()
    {
        GameObject[] gos;

        // Draw th radar background
        if (radarType != RadarTypes.Transparent)
        {
            Rect radarRect = new Rect(_radarCenter.x - _radarWidth / 2, _radarCenter.y - _radarHeight / 2, _radarWidth, _radarHeight);
            GUI.DrawTexture(radarRect, radarTexture);
        }

        // Draw blips
        if (radarBlip1Active)
        {
            // Find all game objects
            gos = GameObject.FindGameObjectsWithTag(radarBlip1Tag);
  
            // Iterate through them and call drawBlip function
            foreach (GameObject go in gos)
            {
                drawBlip(go, _radarBlip1Texture);
            }
        }
        if (radarBlip2Active)
        {
            gos = GameObject.FindGameObjectsWithTag(radarBlip2Tag);
  
            foreach (GameObject go in gos)
            {
                drawBlip(go, _radarBlip2Texture);
            }
        }
        if (radarBlip3Active)
        {
            gos = GameObject.FindGameObjectsWithTag(radarBlip3Tag);
  
            foreach (GameObject go in gos)
            {
                drawBlip(go, _radarBlip3Texture);
            }
        }
        if (radarBlip4Active)
        {
            gos = GameObject.FindGameObjectsWithTag(radarBlip4Tag);
  
            foreach (GameObject go in gos)
            {
                drawBlip(go, _radarBlip4Texture);
            }
        }

        // Draw center oject
        if (radarCenterActive)
        {
            Rect centerRect = new Rect(_radarCenter.x - 1.5f, _radarCenter.y - 1.5f, 3, 3);
            GUI.DrawTexture(centerRect, _radarCenterTexture);
        }
    }
    
    // Draw a blip for an object
    void drawBlip(GameObject go, Texture2D blipTexture)
    {
        if (_centerObject)
        {
            Vector3 centerPos = _centerObject.transform.position;
            Vector3 extPos = go.transform.position;
    
            // Get the distance to the object from the centerObject
            float dist = Vector3.Distance(centerPos, extPos);

            // Get the object's offset from the centerObject
            float bX = centerPos.x - extPos.x;
            float bY = centerPos.z - extPos.z;
    
            // Scale the objects position to fit within the radar
            bX = bX * radarZoom;
            bY = bY * radarZoom;
    
            // For a round radar, make sure we are within the circle
            if(dist <= (_radarWidth - 2) * 0.5 / radarZoom)
            {
                Rect clipRect = new Rect(_radarCenter.x - bX - 1.5f, _radarCenter.y + bY - 1.5f, 3, 3);
                GUI.DrawTexture(clipRect, blipTexture);
            }
        }
    }

    // Create the blip textures
    void CreateBlipTexture(Texture2D tex, Color c)
    {
        Color[] cols = {c, c, c, c, c, c, c, c, c};
        tex.SetPixels(cols, 0);
        tex.Apply();
    }
    
    // Create a round bullseye texture
    void CreateRoundTexture(Texture2D tex, Color a, Color b)
    {
        Color c = new Color(0, 0, 0);
        int size = (int)((_radarWidth / 2) / 4);
        
        // Clear the texture
        for (int x = 0; x < _radarWidth; x++)
        {
            for (int y = 0; y < _radarWidth; y++)
            {
                tex.SetPixel(x, y, c);
            }
        }
        
        for (int r = 4; r > 0; r--)
        {
            if (r % 2 == 0)
            {
                c = a;
            }
            else
            {
                c = b;
            }
            DrawFilledCircle(tex, (int)(_radarWidth / 2), (int)(_radarHeight / 2), (r * size), c);
        }
        
        tex.Apply();
    }
    
    // Draw a filled colored circle onto a texture
    void DrawFilledCircle(Texture2D tex, int cx, int cy, int r, Color c)
    {
        for (int x = -r; x < r ; x++)
        {
            int height = (int)Mathf.Sqrt(r * r - x * x);

            for (int y = -height; y < height; y++)
                tex.SetPixel(x + cx, y + cy, c);
        }
    }

    // Figure out where to put the radar
    void setRadarLocation()
    {
        // Sets radarCenter based on enum selection
        if(radarLocation == RadarLocations.TopLeft)
        {
            _radarCenter = new Vector2(_radarWidth / 2, _radarHeight / 2);
        }
        else if(radarLocation == RadarLocations.TopCenter)
        {
            _radarCenter = new Vector2(Screen.width / 2, _radarHeight / 2);
        }
        else if(radarLocation == RadarLocations.TopRight)
        {
            _radarCenter = new Vector2(Screen.width - _radarWidth / 2, _radarHeight / 2);
        }
        else if(radarLocation == RadarLocations.Left)
        {
            _radarCenter = new Vector2(_radarWidth / 2, Screen.height / 2);
        }
        else if(radarLocation == RadarLocations.Center)
        {
            _radarCenter = new Vector2(Screen.width / 2, Screen.height / 2);
        }
        else if(radarLocation == RadarLocations.Right)
        {
            _radarCenter = new Vector2(Screen.width - _radarWidth / 2, Screen.height / 2);
        }
        else if(radarLocation == RadarLocations.BottomLeft)
        {
            _radarCenter = new Vector2(_radarWidth / 2, Screen.height - _radarHeight / 2);
        }
        else if(radarLocation == RadarLocations.BottomCenter)
        {
            _radarCenter = new Vector2(Screen.width / 2, Screen.height - _radarHeight / 2);
        }
            else if(radarLocation == RadarLocations.BottomRight)
        {
            _radarCenter = new Vector2(Screen.width - _radarWidth / 2, Screen.height - _radarHeight / 2);
        }
            else if(radarLocation == RadarLocations.Custom)
        {
            _radarCenter = radarLocationCustom;
        }
    }

    
}