查看: 2753|回复: 5
打印 上一主题 下一主题

[Sandy3D] sandy3d例子

[复制链接]

46

主题

0

听众

630

积分

初级设计师

Rank: 3Rank: 3

纳金币
386
精华
8

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2013-12-5 14:07:29 |只看该作者 |倒序浏览
import sandy.core.data.*;
import sandy.core.group.*;
import sandy.primitive.*;
import sandy.view.*;
import sandy.core.*;
import sandy.skin.*;
import sandy.util.*;
import sandy.core.transform.*;
import sandy.events.*;
// 定义一些有用的全局变量We define some useful global variables
var screen:Clipscreen; // 演示用表面Presentation surface
var world:World3D = World3D.getInstance(); // 我们的3维场景Our 3D world
//我们在init函数里初始化并渲染场景 In the init() function we initialize and render the world
function init( Void ):Void {
//创建clipScreen用作渲染3维世界的表面 Create a clipScreen as presentation surface for the World3D to draw on
screen = new ClipScreen( this.createEmptyMovieClip('screen', 1), 300, 300 );
// 创建一个摄影机,以便能够看到我们的世界 Create a camera, so we can see our world.
// 为他指定焦距和显示屏幕 Give it a focal distance ( equivalent ) and a reference to the viewing screen.
var cam:Camera3D = new Camera3D( 700, screen );
// 把摄影机定位到研z轴负方向。Position the camera at a negative distance along the z axis
// 默认它是观看坐标原点的 By default it is looking at the origin of the world coordinate system [0,0,0]
cam.setPosition(0,0,-500);
// 把摄影机付给场景 Attach the camera to the world
world.addCamera( cam );
//场景根组,用作场景中所有物体的支点  Create the root group, the branch node for all objects in our world
var bg:Group = new Group();
// 付给场景,该节点用来绘制其他子节点 and attach it to the world. this node is responsible
// for drawing all its ( possibly transformed child nodes
world.setRootGroup( bg );
// 创建场景并与根组关联 Create the scene and attach it to the rootGroup
createScene( bg );
// 最后开始渲染 场景Finally we start rendering the world
world.render();
}
//自定义创建场景函数
function createScene( bg:Group ):Void {
// 开始,创建一个长方体Start by creating a Box primitive.
// By setting all edges to 50 pixels, we'll get a cube
var cube:Object3D = new Box( 50, 50, 50, 'quad' );
//我们可以创建一个皮肤,使立方体看起来更好一些。 We can create a skin to make the cube look a little better
//这里我们使用一个混合皮肤,一个半透明绿色和黑细线 Here we use a mixed skin with a semi transparent green color and black thin lines
var skin:Skin = new MixedSkin( 0x00FF00, 80, 0, 100, 1 );
// 应用皮肤给立方体 Apply the skin to the cube.
cube.setSkin( skin );
// 添加立方体到rootGroup Add the cube as a child to the rootGroup
bg.addChild( cube );
}
init();

分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

无效楼层,该帖已经被删除

0

主题

2

听众

3238

积分

中级设计师

Rank: 5Rank: 5

纳金币
0
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2014-2-28 12:24:31 |只看该作者
感谢分享
回复

使用道具 举报

0

主题

1

听众

2458

积分

中级设计师

Rank: 5Rank: 5

纳金币
0
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

地板
发表于 2014-3-26 20:46:59 |只看该作者
楼主就是给力
回复

使用道具 举报

0

主题

1

听众

490

积分

设计实习生

Rank: 2

纳金币
0
精华
0

最佳新人

5#
发表于 2014-3-29 13:55:45 |只看该作者
Hen hao !
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

关闭

站长推荐上一条 /1 下一条

手机版|纳金网 ( 闽ICP备08008928号

GMT+8, 2024-5-18 15:53 , Processed in 0.088199 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部