corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * Copyright (c) 2006-2014, openmetaverse.org |
||
3 | * All rights reserved. |
||
4 | * |
||
5 | * - Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * |
||
8 | * - Redistributions of source code must retain the above copyright notice, this |
||
9 | * list of conditions and the following disclaimer. |
||
10 | * - Neither the name of the openmetaverse.org nor the names |
||
11 | * of its contributors may be used to endorse or promote products derived from |
||
12 | * this software without specific prior written permission. |
||
13 | * |
||
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
||
18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
24 | * POSSIBILITY OF SUCH DAMAGE. |
||
25 | */ |
||
26 | |||
27 | using System; |
||
28 | using System.Collections.Generic; |
||
29 | |||
30 | namespace OpenMetaverse.Rendering |
||
31 | { |
||
32 | [RendererName("Simple Cube Renderer")] |
||
33 | public class SimpleRenderer : IRendering |
||
34 | { |
||
35 | public SimpleMesh GenerateSimpleMesh(Primitive prim, DetailLevel lod) |
||
36 | { |
||
37 | Path path = GeneratePath(); |
||
38 | Profile profile = GenerateProfile(); |
||
39 | |||
40 | SimpleMesh mesh = new SimpleMesh(); |
||
41 | mesh.Prim = prim; |
||
42 | mesh.Path = path; |
||
43 | mesh.Profile = profile; |
||
44 | mesh.Vertices = GenerateVertices(); |
||
45 | mesh.Indices = GenerateIndices(); |
||
46 | |||
47 | return mesh; |
||
48 | } |
||
49 | |||
50 | public SimpleMesh GenerateSimpleSculptMesh(Primitive prim, System.Drawing.Bitmap sculptTexture, DetailLevel lod) |
||
51 | { |
||
52 | return GenerateSimpleMesh(prim, lod); |
||
53 | } |
||
54 | |||
55 | public FacetedMesh GenerateFacetedMesh(Primitive prim, DetailLevel lod) |
||
56 | { |
||
57 | Path path = GeneratePath(); |
||
58 | Profile profile = GenerateProfile(); |
||
59 | |||
60 | FacetedMesh mesh = new FacetedMesh(); |
||
61 | mesh.Prim = prim; |
||
62 | mesh.Path = path; |
||
63 | mesh.Profile = profile; |
||
64 | mesh.Faces = GenerateFaces(prim.Textures); |
||
65 | |||
66 | return mesh; |
||
67 | } |
||
68 | |||
69 | public FacetedMesh GenerateFacetedSculptMesh(Primitive prim, System.Drawing.Bitmap sculptTexture, DetailLevel lod) |
||
70 | { |
||
71 | return GenerateFacetedMesh(prim, lod); |
||
72 | } |
||
73 | |||
74 | public void TransformTexCoords(List<Vertex> vertices, Vector3 center, Primitive.TextureEntryFace teFace, Vector3 primScale) |
||
75 | { |
||
76 | // Lalala... |
||
77 | } |
||
78 | |||
79 | private Path GeneratePath() |
||
80 | { |
||
81 | Path path = new Path(); |
||
82 | path.Points = new List<PathPoint>(); |
||
83 | return path; |
||
84 | } |
||
85 | |||
86 | private Profile GenerateProfile() |
||
87 | { |
||
88 | Profile profile = new Profile(); |
||
89 | profile.Faces = new List<ProfileFace>(); |
||
90 | profile.Positions = new List<Vector3>(); |
||
91 | return profile; |
||
92 | } |
||
93 | |||
94 | private List<Vertex> GenerateVertices() |
||
95 | { |
||
96 | List<Vertex> vertices = new List<Vertex>(8); |
||
97 | |||
98 | Vertex v = new Vertex(); |
||
99 | |||
100 | // FIXME: Implement these |
||
101 | v.Normal = Vector3.Zero; |
||
102 | v.TexCoord = Vector2.Zero; |
||
103 | |||
104 | v.Position = new Vector3(0.5f, 0.5f, -0.5f); |
||
105 | vertices.Add(v); |
||
106 | v.Position = new Vector3(0.5f, -0.5f, -0.5f); |
||
107 | vertices.Add(v); |
||
108 | v.Position = new Vector3(-0.5f, -0.5f, -0.5f); |
||
109 | vertices.Add(v); |
||
110 | v.Position = new Vector3(-0.5f, 0.5f, -0.5f); |
||
111 | vertices.Add(v); |
||
112 | v.Position = new Vector3(0.5f, 0.5f, 0.5f); |
||
113 | vertices.Add(v); |
||
114 | v.Position = new Vector3(0.5f, -0.5f, 0.5f); |
||
115 | vertices.Add(v); |
||
116 | v.Position = new Vector3(-0.5f, -0.5f, 0.5f); |
||
117 | vertices.Add(v); |
||
118 | v.Position = new Vector3(-0.5f, 0.5f, 0.5f); |
||
119 | vertices.Add(v); |
||
120 | |||
121 | return vertices; |
||
122 | } |
||
123 | |||
124 | private List<ushort> GenerateIndices() |
||
125 | { |
||
126 | ushort[] indices = new ushort[] { |
||
127 | 0, 1, 2, |
||
128 | 0, 2, 3, |
||
129 | 4, 7, 6, |
||
130 | 4, 6, 5, |
||
131 | 0, 4, 5, |
||
132 | 0, 5, 1, |
||
133 | 1, 5, 6, |
||
134 | 1, 6, 2, |
||
135 | 2, 6, 7, |
||
136 | 2, 7, 3, |
||
137 | 4, 0, 3, |
||
138 | 4, 3, 7, |
||
139 | }; |
||
140 | |||
141 | return new List<ushort>(indices); |
||
142 | } |
||
143 | |||
144 | private List<Face> GenerateFaces(Primitive.TextureEntry te) |
||
145 | { |
||
146 | Face face = new Face(); |
||
147 | face.Edge = new List<int>(); |
||
148 | face.TextureFace = te.DefaultTexture; |
||
149 | face.Vertices = GenerateVertices(); |
||
150 | face.Indices = GenerateIndices(); |
||
151 | |||
152 | List<Face> faces = new List<Face>(1); |
||
153 | faces.Add(face); |
||
154 | |||
155 | return faces; |
||
156 | } |
||
157 | } |
||
158 | } |